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

发布于 2024-12-04 08:56:15 字数 480 浏览 3 评论 0原文

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

在搜索过程中,我发现可以使用 rsrc 属性将字体数据复制到常规 ttf 文件。因此,我运行命令 cp /rsrc -attr.ttf 并尝试链接 @font-face 中的新文件。文本再次以默认字体显示。

stackoverflow 上的另一个讨论建议使用 xattr -p 进行二进制打印和复制数据。 | xxd -r > <字体>-xxd.ttx。再次链接该文件未能更改字体。

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

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.

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.ttf and tried linking the new file in the @font-face. Again, the text showed up in the default font.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌辣 2024-12-11 08:56:15

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

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

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

由于 Rosetta 不再存在,我也没有 Resorcerer,所以我设法创建了一个准系统资源文件编辑器。

https://markdouma.com/developer/ResourceFinagler.zip

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

在此处输入图像描述

在此输入图像描述

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 LWFN icon).

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

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

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

https://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.

enter image description here

enter image description here

醉态萌生 2024-12-11 08:56:15

由于这是搜索如何在现代 macOS 系统上处理资源分支字体时的第一个搜索结果,因此这里是批量转换一大组字体手提箱的解决方案。

,我们可以利用 find 命令将它们全部分组到一个目录中,因为 find 没有看到资源分支并认为文件为空,我们在用户主目录中创建一个新目录并将所有手提箱复制到其中:

mkdir ~/rsrc
find . -type f -empty -exec cp {} ~/rsrc/ \;

首先 mac 我们可以使用 brew 来安装 Fondu

brew install fondu

最后我们移动到包含所有手提箱的目录并在每个文件上运行fondu,例如这个,秘密让fondu工作的方法是通过在文件末尾添加/../namedfork/rsrc来使其读取资源fork,否则会失败。

cd ~/rsrc
find . -type f -empty -exec fondu -force {}/..namedfork/rsrc \;

命令完成后,您应该有一个包含新 .ttf、.bdf 和 .pfb 文件的文件夹。

您可以从此目录中运行以下命令删除手提箱文件:

find . -type f -empty -delete

Since this is one of the first search results when searching how to handle Resource fork fonts on modern macOS systems here is a solution for batch converting a large group of font suitcases.

First we can group them all in a single directory taking advantage of the find command, because find doesn't see the resource fork and consider the file empty, we create a new directory in the user home and copy all the suitcases there:

mkdir ~/rsrc
find . -type f -empty -exec cp {} ~/rsrc/ \;

Then in mac we can use brew to install Fondu

brew install fondu

Finally we move to the directory with all the suitcases and run fondu on each file like this, the secret to get fondu to work is to make it read the resource fork by adding /../namedfork/rsrc at the end of the file, otherwise it fails.

cd ~/rsrc
find . -type f -empty -exec fondu -force {}/..namedfork/rsrc \;

When the command finishes you should have a folder with the new .ttf, .bdf and .pfb files.

You can delete the suitcase files from this directory running:

find . -type f -empty -delete
墨离汐 2024-12-11 08:56:15

这个答案适用于 Apple Silicon Mac,基于上面的 Diego Alifano 的答案。

将资源分支文件复制到更好的位置。

find . -type f -empty -exec cp {} ~/YOUR/FOLDER/HERE/ \;

您无法再使用 brew 安装 Fondu。相反,请从 Fondu 网站下载其 tar 球源:https://fondu.sourceforge.net/index。 html#下载。提取它。

该源代码也不再无需修改即可编译,因为动态系统库不再位于文件系统上; macOS Ventura 13.5 中不存在 /System/Library/Frameworks/CoreServices.framework/CoreServices。打开后,更改名为 Makefile.in 的文件。删除该行:

DARWIN_CORE = $(if $(findstring apple-darwin,$(HOST)),/System/Library/Frameworks/CoreServices.framework/CoreServices,)

然后在 Fondu 源所在目录的终端中执行: ./configure;制作。 Fondu 很小,编译速度应该很快。我不确定这个旧的(看似无人维护的)代码库是否会继续工作;因此,我不关心 make install

在字体文件所在的位置:

find . -type f -empty -exec /PATH/TO/YOUR/MADE/fondu -force {}/..namedfork/rsrc \;

如果您make install它,则不需要提供制作的fondu的路径。并清理现在多余的旧式资源分支: find 。 -type f -empty -delete

This answer is for Apple Silicon Macs and is based on Diego Alifano's answer above.

Copy your resource fork files to some better location.

find . -type f -empty -exec cp {} ~/YOUR/FOLDER/HERE/ \;

You cannot install Fondu using brew anymore. Instead download its tar ball source from Fondu's website: https://fondu.sourceforge.net/index.html#Downloads. Extract it.

This source code also no longer compiles without modifications because dynamic system libraries are no longer located on the file system; /System/Library/Frameworks/CoreServices.framework/CoreServices does not exist in macOS Ventura 13.5. Once you have it open, alter the file called Makefile.in. Remove the line:

DARWIN_CORE = $(if $(findstring apple-darwin,$(HOST)),/System/Library/Frameworks/CoreServices.framework/CoreServices,)

Then execute in terminal in the directory in which the Fondu source was put: ./configure; make. Fondu is small and it should compile rapidly. I am not sure whether this old (seemingly unmaintained) code base will continue working; I therefore don't bother with make install.

In the location where your font files are:

find . -type f -empty -exec /PATH/TO/YOUR/MADE/fondu -force {}/..namedfork/rsrc \;

If you make install'ed it, you won't need to provide the path to the made fondu. And to clean up the now redundant old-style resource forks: find . -type f -empty -delete.

大海や 2024-12-11 08:56:15

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文