Reading a font from file and making it available to Cocoa
This is another programming related post. Say you have a true type font that’s not part of the OS font set in a file. You’ve read the contents of the file into memory and now want to make it available to Cocoa. How? Turns out that ATSUI comes to the rescue:
ATSFontContainerRef container;
OSStatus status = ATSFontActivateFromMemory((LogicalAddress)[fontData bytes], // buffer with font data
[fontData length], // size of font data
kATSFontContextLocal, // for use only in this application
kATSFontFormatUnspecified, // reserved
NULL, // reserved
kATSOptionFlagsDefault, // reserved