macos 通过@font-face 在 CSS 中使用 OS 9 资源分支字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7412462/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:25:23  来源:igfitidea点击:

Using OS 9 resource fork fonts in CSS with @font-face

htmlcssmacosfontsfont-face

提问by Sameer

I have some old OS 9 fonts which contain the font data in the resource fork. When I try to link such a font in a @font-face and open up the HTML in a browser, the text still appears in the default font.

我有一些旧的 OS 9 字体,其中包含资源叉中的字体数据。当我尝试在 @font-face 中链接这样的字体并在浏览器中打开 HTML 时,文本仍然以默认字体显示。

On searching around, I found that the font data can be copied to a regular ttf file using the rsrc attribute. So I ran the command cp <font>/rsrc <font>-attr.ttfand tried linking the new file in the @font-face. Again, the text showed up in the default font.

在四处搜索时,我发现可以使用 rsrc 属性将字体数据复制到常规 ttf 文件中。所以我运行命令cp <font>/rsrc <font>-attr.ttf并尝试在@font-face 中链接新文件。同样,文本以默认字体显示。

Another discussion on stackoverflow suggested binary printing and copying of the data using xattr -p <font> | xxd -r > <font>-xxd.ttx. Once again, linking this file failed to change the font.

另一个关于 stackoverflow 的讨论建议使用xattr -p <font> | xxd -r > <font>-xxd.ttx. 再一次,链接此文件未能更改字体。

Just to make sure that the HTML was correct, I linked a newer ttf font from the same directory and it worked correctly. Does anyone know if the old fonts can be used in @font-face, with or without any conversion. Thank you.

为了确保 HTML 是正确的,我从同一目录链接了一个较新的 ttf 字体并且它工作正常。有谁知道旧字体是否可以在@font-face 中使用,无论是否进行任何转换。谢谢你。

回答by NSGod

Font Suitcases can potentially hold 2 different kinds of fonts: bitmap fonts and TrueType fonts. Bitmap fonts would be 'NFNT'resources along with the necessary 'FOND'(font family information). On the other hand, TrueType fonts would be 'sfnt'resource entries along with the necessary 'FOND'(font family information). Normally, font suitcases that hold bitmap font data are only one half of the font; to be usable you need to have the additional PostScript Outline font files (these will have an LWFNicon).

Font Suitcases 可能包含两种不同的字体:位图字体和 TrueType 字体。位图字体将是'NFNT'资源以及必要的'FOND'(字体系列信息)。另一方面,TrueType 字体将是'sfnt'资源条目以及必要的'FOND'(字体系列信息)。通常,存放位图字体数据的字体手提箱只有字体的一半;要使用,您需要有额外的 PostScript Outline 字体文件(这些文件会有一个LWFN图标)。

Otherwise, the font suitcase can represent a TrueType font, which compared to a "PostScript Type 1 Font Suitcase", is truly self-contained.

否则,字体手提箱可以代表 TrueType 字体,与“PostScript Type 1 字体手提箱”相比,它是真正独立的。

To convert from a resource-file-based Mac TrueType font to a Windows TrueType font, you just need to extract the 'sfnt'resource entries).

要将基于资源文件的 Mac TrueType 字体转换为 Windows TrueType 字体,您只需提取'sfnt'资源条目)。

Since Rosetta is no more, I'm without Resorcerer, so I've managed to whip up a barebones resource file editor.

由于 Rosetta 已不复存在,我没有 Resorcerer,因此我设法打造了一个准系统资源文件编辑器。

http://www.markdouma.com/developer/ResourceFinagler.zip

http://www.markdouma.com/developer/ResourceFinagler.zip

I just added a few lines so that you can now select the individual 'sfnt'resources like shown in the image below, and drag them to the Finder to create the individual Windows TrueType fonts.

我刚刚添加了几行,以便您现在可以选择'sfnt'如下图所示的单个资源,并将它们拖到 Finder 以创建单个 Windows TrueType 字体。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

回答by duskwuff -inactive-

The font data in an old Mac OS font suitcase is not in TTF format -- copying the resource fork to a TTF file will give you Mac OS resource data in a file named "font.ttf", which isn't right. You'll need to use a tool like FontForge (free/open-source) to do the conversion.

旧 Mac OS 字体手提箱中的字体数据不是 TTF 格式——将资源分支复制到 TTF 文件将在名为“font.ttf”的文件中为您提供 Mac OS 资源数据,这是不正确的。您需要使用 FontForge(免费/开源)等工具进行转换。