简体   繁体   English

如何在fabric.js中获取字体家族的完整列表

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

I'm using fabric.js in my site. 我在我的网站上使用fabric.js。 suppose if I need to add any text in canvas, I write - like- 假设如果我需要在画布中添加任何文本,我会写-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. 但是我需要列表中所有可用的字体(例如-Times New Roman,Helvetica),以便我可以在运行时选择字体,我尝试用Google搜索它,但一无所获。 I wonder if anybody help me. 我想知道是否有人帮助我。 Thank in advance. 预先感谢。

fabricjs doens't provide any fonts for you. fabricjs不为您提供任何字体。 Instead, it uses a html5 canvas and therefore have the font the browser provides for you. 相反,它使用html5画布,因此具有浏览器为您提供的字体。

If you need to list available fonts during runtime you can test out the following . 如果您需要在运行时列出可用字体,则可以测试以下内容

Of you can import you own using font-face . 您可以使用font-face导入自己的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM