fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
http://fabricjs.com
Other
28.9k stars 3.5k forks source link

Add textbox with different text size #5524

Closed EnguerranMeens closed 5 years ago

EnguerranMeens commented 5 years ago

Hi,

I have a question, i want to add ITEXT from a script but with two word with different fontsize. I search some solution like add html balise with style but it seem won't work. Can you help me ?

Thank you,

Enguerran

asturur commented 5 years ago

Hey, i hope you solved this already.

Anyway when adding an iText youcan specify a style object:

var myText = new fabric.IText('word1 word2', {
  styles: {
   // line 0
    0:
    {
      // char at position 0  on line 0
      0: { fontSize: 15 },
      // char at position 1  on line 0
      1: { fontSize: 15 },
    }
  }
})