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?
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
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.
精彩评论