Search code examples
macosfontsxattr

Old Mac extended attributes in Snow Leopard


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?


Solution

  • 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