Last active
October 27, 2020 20:56
-
-
Save Diegus83/df39b51678a128bb7fb7ba2b602d773b to your computer and use it in GitHub Desktop.
Convert font suitcases (resource forks) in modern macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First extract the suitcases to regular files with dataforks | |
----------------------------------------------------------------- | |
(Source: http://xahlee.info/UnixResource_dir/macosx.html) | |
(Source: http://fondu.sourceforge.net/) | |
(Source: https://stackoverflow.com/questions/7412462/using-os-9-resource-fork-fonts-in-css-with-font-face/64561713#64561713) | |
This is a very old file format where the font information is only contained in the resource fork, not the data fork, so the files seem empty to most modern apps. | |
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][1] 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 | |
To deal with the resulting .pfb files | |
----------------------------------------------------------------- | |
(Source: https://jeromejaglale.com/doc/convert_pfb_pfm_font_to_otf) | |
install fontforge with brew | |
create pfb2otf | |
#!/usr/local/bin/fontforge | |
Open($1); | |
Reencode("unicode"); | |
Generate($fontname+".otf"); | |
Quit(0); | |
create convert | |
#!/bin/bash | |
PATH=/usr/local/bin:$PATH | |
FONTFORGE_LANGUAGE=ff | |
export PATH FONTFORGE_LANGUAGE | |
if (test -f $1); then ./pfb2otf $1; fi | |
make them executable: | |
chmod +x pfb2otf convert | |
place them in the same folder as your PFB and PFM font files | |
launch the conversion | |
for i in *.[pP][fF][bB]; do ./convert $i; done | |
[1]: https://brew.sh/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment