开发者

Using OS 9 resource fork fonts in CSS with @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 开发者_如何学Pythonin 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.


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.

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

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜