Reputation: 105
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?
Upvotes: 2
Views: 10525
Reputation: 26034
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();
});
Upvotes: 6