What is the new syntax for SVG fonts?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 08:47:48

问题


I was browsing SVG fonts in MDN, where it is mentioned that <font-face>, <missing-glyph>, <hkern> and <vkern> are depreciated. Only <glyph> is not depreciated. It does not mention anything about a recommended way of specifying the font face properties.

The W3C SVG recommendation also does not say anything about an alternative way of specifying SVG fonts, apart from noting that everything in the <font-face> can be done equivalently in CSS. It does not provide any alternative for <hkern> or <vkern>. I intend to create a standalone SVG file, not to be modified by the site CSS, so I would like to keep the whole font definition in the SVG.

So, what is this obscure new way of specifying SVG fonts?


回答1:


"SVG fonts" as a data file that uses SVG markup to define a font resource has been deprecated; it turned out to be a bad idea, not addressing the issues that typography on the web needed addressed, and almost all browsers have removed support for it again.

Instead, all browsers support OpenType fonts as packed for the web using the WOFF/WOFF2 approach, and OpenType fonts in turn support several different outline types:

  • TrueType (quadratic curves and compound glyphs)
  • Type2 in CFF/CFF2 (cubic curves and arbitrary subroutines)
  • Bitmaps (yes, OpenType fonts can indeed be bitmap fonts, with as many different bitmaps as necessary to cover as many pixel sizes as necessary)
  • SVG

So if you absolutely need to keep your SVG data around, then make yourself an OpenType with SVG outline font, and then pack that for the web as a WOFF (or WOFF2) and you're good to go.



来源:https://stackoverflow.com/questions/43841049/what-is-the-new-syntax-for-svg-fonts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!