How to use Google fonts in Canvas when Drawing DOM objects in SVG?

后端 未结 2 1831
生来不讨喜
生来不讨喜 2020-12-02 00:43

As per Mozilla\'s documentation, you can draw complex HTML on Canvas like this.

What I can\'t figure out is a way to make Google fonts work with it.

2条回答
  •  囚心锁ツ
    2020-12-02 01:28

    The first thing you can try is to use Google web font loader because you are generating the svg before the font is loaded by the browser

    so you need to make sure that the fonts are loaded and then generate the svg/image

    if that doesn't work you can create text tags in your svg and try these alternatives for fonts https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_fonts

提交回复
热议问题