views:

239

answers:

2

Last year I had to convert and old Mac font from around OS 9 for someone to use on a PC. I discovered that back then the font data was stored in the extended attribute com.apple.ResourceFork. The actual file size will show up as 0 in terminal. I was able to get around this by simply printing out the value of that extended attribute using xattr -p com.apple.ResourceFork font > font.ttf.

Now with Snow Leopard and the HFS+ file compression things have changed. If you now try to print out an old style extended attribute you will only get the hex and not the value. New extended attributes appear without any hex unless specified with the -x option. Here's an example:

xattr -l com.apple.FinderInfo Rublof
Rublof: com.apple.ResourceFork:
00000000  00 00 01 00 00 00 9E 50 00 00 9D 50 00 00 00 32  |.......P...P...2|
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
...
Rublof: com.apple.quarantine: 0000;4b75ae02;Mail;39396996-3C5C-48F5-8BDD-775EB40CAD9C|com.apple.mail

Running xattr -p on the ResourceFork will output hex, running it on quarantine you get ASCII. Obviously Apple changed the way they handle extended attributes and perhaps they forgot about people who still keep their OS 9 fonts around.

Is there anything I'm missing here or do I just write a script to convert the hex into ASCII?

+2  A: 

You can also access resource forks by appending "/rsrc" or "/..namedfork/rsrc" to the file name. Try cp Rublof/rsrc Rublof.ttf. That said, resource forks are deprecated, while extended attributes aren't. The "/..namedfork" mechanism might disappear from future releases. If that happens, you can try xxd to convert back to binary:

xattr -p com.apple.ResourceFork Rublof | xxd -r > Rublof.ttf

outis
xxd was the key. Wish I knew my commands better. You also have to add the -p option for xxd to have it handle the input correctly. Still having issues getting the font loaded, but the hex dump from Rublof.ttf matches the resource fork.
dmertl
+1  A: 

Converting the resource fork into a data fork won't do what you need -- it's still in resource fork format, so nothing'll be able to use it. To get it into a cross-platform format, you need a converter like fondu. It'll dig through an old-style Mac font suitcase and extract sfnt resources (TrueType & OpenType fonts) into .ttf and .otf files, POST resources (PostScript fonts) to .pbf files, and NFNT and FONT resources (bitmap fonts) into .bdf files.

BTW, the Mac OS/X package from the SourceForge download section gives me an error when I install it, but seems to install successfully anyway.

Gordon Davisson
Thanks, I'll give that a shot.
dmertl