Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从画布元素上的字体渲染glyph_Javascript_Html_Canvas_Webfonts - Fatal编程技术网

Javascript 如何从画布元素上的字体渲染glyph

Javascript 如何从画布元素上的字体渲染glyph,javascript,html,canvas,webfonts,Javascript,Html,Canvas,Webfonts,在其CSS文件中指定图示符,如下所示: /* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen readers do not read off random characters that represent icons */ .icon-glass:before { content: "\f000"; } .icon-music:before

在其CSS文件中指定图示符,如下所示:

/*  Font Awesome uses the Unicode Private Use Area (PUA) to ensure 
    screen readers do not read off random characters that represent icons */
.icon-glass:before                { content: "\f000"; }
.icon-music:before                { content: "\f001"; }
我正在尝试将图标从该字体渲染到画布元素,但看不到如何访问这些图示符

ctx.font = "40px FontAwesome";
ctx.fillText("\f000",20,20); // no cigar
如何在JavaScript字符串中指定这些图示符?

您应该使用:

或者Unicode转义的以下语法:

ctx.fillText("\uf000", 20, 20);

这对我来说很有效,使用以下格式:
createjs.Text('\uf178',100px,'red')
。非常感谢。我来这里是想在画布上渲染材质设计图标。对我来说,
String.fromCodePoint(0xF0625)
成功了。其中,
F0909
对应于CSS
content
属性中的值:
.mdi帮助圆圈outline::before{content:\F0625”}
注意,并非所有浏览器都实现String.fromCodePoint(即再次):
ctx.fillText("\uf000", 20, 20);