gpt4 book ai didi

css - Web 浏览器可以从 webfonts 渲染嵌入的位图吗?

转载 作者:行者123 更新时间:2023-11-27 23:25:41 26 4
gpt4 key购买 nike

我一直在引用调查结果 in this threadin this question当尝试获取使用嵌入式位图通过 @font-face 呈现它们的自定义字体时,并且在我对我知道正确配置的字体的实验中,我发现以下结果显示 日本语言 使用 Windows 10 和 Vivaldi(Chrome 等),启用并配置了 ClearType(不确定这是否重要):

span {
font-family: "SimSun"; // or just omitted, since this is a fallback font
}

Defaulting to system font

@font-face { font-family: "font"; font-weight: normal; src: url('simsun_0.ttc'); }
span {
font-family: "font";
}

Explicitly declaring same font loaded with font-face

simsum_0.ttc 是我从C:/Windows/Fonts/ 中提取并放置在css 所在文件夹中的字体。我还验证了这个文件确实有嵌入的位图并且配置正确。

从那以后我就安装了我正在使用的字体并通过它的系统名称引用它,然后正确加载位图。有没有办法让浏览器从通过 @font-face 加载的字体加载位图?是否有任何关于此限制或可能的解决方法的文档或规范?

更多示例

这对自定义字体也同样适用 - 这是 Chrome 中使用 .otf 字体的示例。在系统上安装时通过其名称加载的字体:

Called via name

并通过@font-faceurl 加载相同的字体:

Called via font-face

最佳答案

Chrome 和 Firefox(可能还有其他)在系统中不可用的字体上运行 OTS,这会从字体中删除 EBDT 和 EBLC 表(存储位图的地方)。

来自OTS readme :

The OpenType Sanitizer (OTS) parses and serializes OpenType files (OTF, TTF) and WOFF and WOFF2 font files, validating them and sanitizing them as it goes.

The C library is integrated into Chromium and Firefox, and also simple command line tools to check files offline in a Terminal.

The CSS font-face property is great for web typography. Having to use images in order to get the correct typeface is a great sadness; one should be able to use vectors.

However, on many platforms the system-level TrueType font renderers have never been part of the attack surface before, and putting them on the front line is a scary proposition... Especially on platforms like Windows, where it's a closed-source blob running with high privilege.

2014 年,有 interest in adding color bitmap tables to Chromium , 和 support was added to pass-through the color bitmap (CBDT & CBLC) tables to OTS ,因此如果浏览器请求,似乎也可以为这些添加支持。

我看到的使这成为可能的步骤是:

  1. 添加将 EBDT 和 EBLC 表传递到 OTS 的功能。 This is the current location of the code that passes the color tables through .
  2. 请求每个元素(Chromium、Firefox 等)允许传递。
  3. 等待所有更新的代码被推送到下游。

这种支持可能有更复杂的实现(@font-face 中的选项等),但这似乎是最简单的,因为颜色表已经支持(某种程度上)同理。

关于css - Web 浏览器可以从 webfonts 渲染嵌入的位图吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57796685/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com