I am trying to change the font attribute for text in fabric.js.
Here is my fiddle: http://jsfiddle.net/mvprzy/szzGa/
I believe this part of the fabric script should work, but isn't:
var fontControl = $('font-control');
fontControl.onchange = function () {
fabric.Text.set('fontFamily', font-control.value);
canvas.renderAll();
};
What am I doing wrong?
First of all you need to include jQuery in the jsfiddle (: After that all I did was make the fabric.IText
a variable and change the on change function to the following based on this SO post
var fontControl = $('#font-control');
$(document.body).on('change', '#font-control', function () {
text.fontFamily = fontControl.val();
canvas.renderAll();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.