How to apply a custom font in a text text object?

I would like to use a custom font in a text text object, I followed the following link: http://fabricjs.com/fabric-intro-part-4/

But it looks like it is only supported in node.js.

Is there a way to support it on a simple text object on a canvas?

+6
source share
2 answers

CSS usage:

@font-face { font-family: myFirstFont; src: url('Sansation_Light.ttf'), url('Sansation_Light.eot'); /* IE9 */ } 

Create an instance of a text object object:

  var object = new fabric.Text("NEW TEXT", { fontFamily: "myFirstFont", left: 150, top: 100, fontSize: 24, textAlign: "left", fill: "#000000" }); canvas.add(object); canvas.renderAll(); 
+11
source

Using the Simple Css Font @Face Property

0
source

Source: https://habr.com/ru/post/950410/


All Articles