Using @font-face with an SVG font embedded in the current HTML page

前端 未结 2 713
清酒与你
清酒与你 2020-12-31 22:50

I have a standalone HTML document I want to distribute, without any external dependencies. I\'m using a non-standard font in this document that only some of my users will ha

2条回答
  •  一个人的身影
    2020-12-31 23:18

    Convert the font to a data URI and embedded it in the CSS declaration: (fiddle)

    
    

    Alphabet

    There's one caveat: you can't use an ID specifier (#MyFont) with a data URI like this. Therefore you can only have a single font in the encoded file, rather than having multiple and referring to them individually. (Not that you'd want to; duplicating the data for multiple embedded fonts in the declaration for each font would be a huge waste of space.)

提交回复
热议问题