0

This is more of a "conversion kata" than a real stumper, as in the worst case I can use my Mac to perform the conversion, but I really want to understand why the Linux tooling I used could not pull off the conversion, so I can help others migrating off of macOS to Linux. Though possibly in this case, I suspect the answer might eventually be to convert the font file in macOS and then bring the converted files over to Linux. On a Fedora 39 distro, up to date on all OS patches as of today.

Over at a mirror site of the original Macintosh Programmer's Workshop (MPW) font is a BinHex'd, StuffIt'd file of a typical Macintosh Classic OS font file of its day. I picked it because I thought it would be a small, easy use case, and I want to Nerd Font'ify it for nostalgic nerd kicks. I want to convert its bitmap portion (in 9, 10 and 12 point) to a PCF file, and its TrueType portion to a TTF file.

Unix FILE(1) reports the .hqx file is a BinHex binary text, version 4.0, ASCII text.

Using the macutils' hexbin utility to render the binary StuffIt file was straightforward, using the call hexbin -fl ./MPW_Font.sit.hqx, which yielded an MPW_Font.sit file. Unix FILE(1) dutifully reports the .sit file as StuffIt Archive.

Using Unarchiver unar utility to unpack the StuffIt archive file was also straightfoward, using the call unar MPW_Font.sit, which generates a directory called MPW Font, and three files:

  1. MPW Font ReadMe, a PDF file, which opens readily enough.
  2. MPW.frk, this looks like what Unarchiver creates for a pseudo-AFP (Apple Filing Protocol)-compatible resource fork for a Unix system running netatalk, except that usually the .frk suffixed name is of a directory instead of a file.
  3. MPW.rsrc, md5sum-confirmed identical to MPW.frk, and a resource fork.

Since both files #2 and #3 were exactly the same, I focused upon MPW.rsrc. Unix FILE(1) reports it as a AppleDouble encoded Macintosh file. So it is a resource file in AppleDouble format. This is where I'm pretty much stuck, because any attempt to break the resource file out of the AppleDouble container fails.

The rsrcdump utility parses the AppleDouble file as a resource file just fine:

$ rsrcdump --extract MPW.rsrc
NFNT  30637     2576  
NFNT  28920     3034  
NFNT  25312     4002  
FOND   5735      678  MPW
movp      0       14  
sfnt   4969    61904  MPW
vers      1       46  
kvst    128       36  
Wrote "MPW.json"

That JSON shows the dump of the raw binary data of the resource forks, and so I'm reasonably certain there is no corruption. The fondu utility does not recognize the file as what it calls a "bare resource fork":

$ fondu -show MPW.rsrc 
Can't find an appropriate resource fork in MPW.rsrc

Since fondu also understands MacBinary, then I try the netatalk branch branch-netatalk-2-2 megatron utility (it isn't available after that version, so the branch is useful to build and extract the utility), calling it as macbinary to convert from AppleDouble to MacBinary, which also fails:

$ macbinary MPW.rsrc 
MPW.rsrc is not an adouble file.

I then try FontForge, but it does not recognize the MPW.rsrc file in its Open File dialog. Observing that Mac Classic font suitcase files can be read on OS X by FontForge if suffixed with .suit, I tried creating a copy of MPW.rsrc with that suffix, and FontForge does not recognize it on Linux (guessing the libraries FontForge uses to handle those files only exist on the OS X version) when I select "All Fonts" for the filter. If I set the filter to "All Files" and forcibly open either the .rsrc or .suit files, I get the error:

MPW.rsrc is not in a known format (or uses featuers of that format fontforge does not support, or is so badly corrupted as to be undreadable)

I tried running macbinconv.exe under WINE to break the resource fork out of its AppleDouble container, but it failed as well with the error:

$ wine ~/.local/bin/macbinconv.exe -dfrf none MPW.rsrc -info md5
002c:fixme:winediag:loader_init wine-staging 9.1 is a testing version containing experimental patches.
002c:fixme:winediag:loader_init Please mention your exact version when filing bug reports on winehq.org.
Error: invalid string position!

Several other invocations of macbinconv.exe also failed with the same error:

wine ~/.local/bin/macbinconv.exe -ad none MPW.rsrc -info md5
wine ~/.local/bin/macbinconv.exe -ad none MPW.rsrc -mb MPW.bin
wine ~/.local/bin/macbinconv.exe -dfrf none MPW.rsrc -mb md5

I'm now wondering how to check whether the StuffIt extraction by unar generated truly valid AppleDouble files, where the header that would fool Unix FILE(1) into thinking it is AppleDouble, but the encoding is off and throwing off everything further down into the pipeline. But if anyone else cracks how to either generate a valid AppleDouble file or break the resource fork out of its AppleDouble container into a MacBinary file, then I think I can figure out the remaining path to convert to the PCF and TTF fonts, and then I'll share here how I did that for others.

UPDATE: Installing the Windows version of StuffIt Expander into WINE, then running it against the .sit file, generated the sub-directory .rsrc, and within it a file called MPW. Unix FILE(1) reports this is a Mac OSX datafork font, 'NFNT', map offset 0x11b82, map length 0xb6, data length 0x11a82, at 16 0x00000c9a, nextResourceMap 0x31f77e8, fileRef 0x2690, list offset 0x1c, name offset 0xae, 6 types, 0x4e464e54 'NFNT' * 3 resource offset 0x32. Running fondu like so generates BDF and TTF files which fontforge happily opens:

$ fondu -show MPW
Creating MPW-9.bdf
Creating MPW-10.bdf
Creating MPW-12.bdf
Creating MPW.ttf

We now know that there is at least one form of .sit that unar generates AppleDouble container files that we cannot convert further, and the current StuffIt Expander under emulation works sufficiently well to generate the appropriate files for font conversions.

0

You must log in to answer this question.

Browse other questions tagged .