Reputation: 93
I Want to add multiple font in Single fabric TextBox
, don't want to add new Textbox
.
var canvas = new fabric.Canvas('c');
var textbox = new fabric.Textbox('Test', {
left: 50,
top: 50,
width: 150,
fontSize: 20
});
canvas.add(textbox).setActiveObject(textbox);
Please give me solution.
Upvotes: 2
Views: 1010
Reputation: 6865
You can use styles
property of Textbox
var textbox = new fabric.Textbox('Test text', {
left: 50,
top: 50,
width: 150,
fontSize: 20,
styles: {
// first line of text i.e Test
0: {
//first letter of first line i.e T
0: { fontFamily: 'Arial'},
//second letter of first line i.e e
1: { fontFamily: 'Impact'}
},
}
});
Here
0
key of styles indicate first line of your text and0
key inside0
object of style indicate first letter.
Upvotes: 3