Loading fonts from bundles (again!)
Loading fonts from bundles (again!)
- Subject: Loading fonts from bundles (again!)
- From: Michael Norris <email@hidden>
- Date: Tue, 28 Jan 2003 13:02:47 +1300
Hiya
I'm currently writing an app that draws characters to an NSView
subclass using a font located in the application's main bundle. I'm
using the following code that I found on Mamasam:
NSBundle * appBundle = [NSBundle mainBundle];
NSString * fontsPath = [appBundle pathForResource:myFontName
ofType:@"suit"];
FSRef fsRef;
FSSpec fsSpec;
int osstatus = FSPathMakeRef( [fontsPath UTF8String], &fsRef, NULL);
if ( osstatus == noErr) {
osstatus=FSGetCatalogInfo(&fsRef,kFSCatInfoNone,NULL,NULL,&fsSpec,NULL);
}
osstatus = FMActivateFonts( &fsSpec, NULL, NULL,
kFMLocalActivationContext);
Most of it works fine - the font path is found, the fsSpec is
successfully made.
But FMActivateFonts returns an error code of -39...
According to the Macerrors.h, -39 is an eofErr... Which is just plain
weird. It tends to suggest there's something wrong with the font: but
the font works fine if you plonk it in the Fonts folder.
Something broken in OS X 10.2.3, perhaps? Or, more likely, something
I'm doing wrong?
-mike
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.