SVG字体的新语法是什么? [英] What is the new syntax for SVG fonts?

查看:114
本文介绍了SVG字体的新语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览 MDN中的SVG字体,提到 <font-face> <missing-glyph> <hkern> <glyph> 不会被弃用.它没有提及建议的指定字体外观属性的方法.

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.

W3C SVG建议也没有提及任何其他方式除了指出<font-face>中的所有内容都可以等效地在CSS中完成之外,还指定了SVG字体.它没有为<hkern><vkern>提供任何替代方法.我打算创建一个独立的SVG文件,而不要由站点CSS修改,因此我想将整个字体定义保留在SVG中.

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.

那么,这种晦涩的指定SVG字体的新方法是什么?

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

推荐答案

"SVG字体"作为使用SVG标记定义字体资源的数据文件已被弃用;原来,这是一个坏主意,最终没有解决网络上的印刷术需要解决的问题.它是在SVG 1.1中添加的,但在SVG 2.0中迅速再次删除,此后,几乎所有添加了对此支持的浏览器都再次删除了该支持.

"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, and ended up not addressing the issues that typography on the web needed addressing. It was added in SVG 1.1 but promptly removed again in SVG 2.0, and almost all browsers that added support for it have since removed that support again.

相反,所有浏览器现在都支持"webfonts":使用WOFF/WOFF2格式打包到Web的常规OpenType字体,而OpenType字体依次为

Instead, all browsers now support "webfonts": regular OpenType fonts packed for the web using the WOFF/WOFF2 formats, and OpenType fonts in turn support several different outline types:

  • TrueType(二次曲线和复合字形,通常带有ttf扩展名,但扩展名实际上无关紧要)
  • CFF/CFF2中的Type2(三次曲线和任意子例程,通常具有otf扩展名,但再次:扩展名完全不相关)
  • 嵌入式位图(是的,OpenType字体确实可以是真正的位图字体,具有足够数量的不同位图,可以覆盖所需的像素大小)
  • SVG(由于SVG是与TT和CFF/CFF2完全相同的矢量图形语言,因此也可以使用SVG指定字形轮廓数据,这是很有意义的,所以...您可以)
  • TrueType (quadratic curves and compound glyphs, often with ttf extension, but the extension is literally irrelevant)
  • Type2 in CFF/CFF2 (cubic curves and arbitrary subroutines, often with otf extension, but again: the extension is wholly irrelevant)
  • Embedded bitmaps (yes, OpenType fonts can indeed be true bitmap fonts, with as many different bitmaps as necessary to cover as many pixel sizes as necessary)
  • SVG (as SVG is the exact same kind of vector graphics language as TT and CFF/CFF2 are, it made sense to allow glyph outline data to be specified using SVG as well, so... you can)

因此,如果您绝对需要保留SVG数据,则可以将自己设置为OpenType-with-SVG-outlines字体,然后将其打包为现代WOFF2(或更旧的WOFF)在网络上使用,您可以去.

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

这篇关于SVG字体的新语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆