[英]How can I use FontAwesome icons on a html 5 canvas
I have a problem with using FontAwesome icons in my HTML 5 canvas, I tried this: 我在HTML 5画布中使用FontAwesome图标时遇到问题,我试过这个:
ct.fillStyle = "black";
ct.font = "20px Font Awesome";
ct.textAlign = "center";
var h = 'F1E2';
ct.fillText(String.fromCharCode(parseInt(h, 16)), x, y);
I tried importing the FontAwesome CSS file but it didn't work! 我尝试导入FontAwesome CSS文件,但它不起作用! Can anybody help me with this?
任何人都可以帮我吗?
Thanks! 谢谢!
Font Awesome 5 Free
. Font Awesome 5 Free
。 If you're using FA4, you can just use FontAwesome
. FontAwesome
。 Example: 例:
var ctx = canvas.getContext("2d"); document.fonts.ready.then(_ => { ctx.font = '600 48px "Font Awesome 5 Free"'; ctx.fillStyle = "black"; setTimeout(_ => ctx.fillText("\", 45, 45), 200); });
@import url('https://use.fontawesome.com/releases/v5.0.9/css/all.css'); canvas { font-family: 'Font Awesome 5 Free'; font-weight: 600; }
<canvas id="canvas"></canvas>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.