最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to apply custom font in fabric text object? - Stack Overflow

programmeradmin3浏览0评论

I would like to use custom font in fabric text object, I followed the link below: /

But it seems that it's only supported in node.js.

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

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

But it seems that it's only supported in node.js.

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

Share Improve this question edited Jul 24, 2016 at 10:21 jdrake 3434 silver badges17 bronze badges asked Jul 27, 2013 at 6:09 user2624969user2624969 811 silver badge2 bronze badges 2
  • 1 Include custom font in a document, using CSS, just like you would do to render it in HTML. Then specify font family for fabric.Text instance. – kangax Commented Jul 30, 2013 at 14:13
  • HI @kangax.. i working in Curved text using fabric.js how can i used font family for curve text....? any predefined property for font family? – VIVEK-MDU Commented Mar 11, 2014 at 15:07
Add a ment  | 

2 Answers 2

Reset to default 14

Use CSS:

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

Create fabric text object instance :

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

By using Simple Css property Font @Face

发布评论

评论列表(0)

  1. 暂无评论