how to get whole list of font family in fabric.js

笑着哭i 提交于 2019-12-25 01:55:26

问题


I'm using fabric.js in my site. suppose if I need to add any text in canvas, I write - like-

var text1 = new fabric.Text('Fabric', {
  left: 90,
  top: 570,
  angle: -5,
  fontFamily: 'Helvetica',
  fontSize: 20,
  fill: 'red'
})

but I need all available fonts (like - times new roman, Helvetica) in a list so that I can select the font at run time, I tried to google it but I got nothing. I wonder if anybody help me. Thank in advance.


回答1:


fabricjs doens't provide any fonts for you. Instead, it uses a html5 canvas and therefore have the font the browser provides for you.

If you need to list available fonts during runtime you can test out the following.

Of you can import you own using font-face.



来源:https://stackoverflow.com/questions/22787104/how-to-get-whole-list-of-font-family-in-fabric-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!