load font from bundle problem
load font from bundle problem
- Subject: load font from bundle problem
- From: Tavis <email@hidden>
- Date: Sat, 19 Jul 2003 01:56:41 -0700
hi does anyone know why i cannot use a font I load from the bundle?
Here is my code
CFBundleRef myAppBundle = NULL;
CFURLRef myAppResourcesURL = NULL;
FSRef myResourceDirRef;
FSSpec myResourceDirSpec;
int status;
NSArray *fonts;
NSEnumerator *enumerator;
NSString *font;
//first i load my font in from the bundle
myAppBundle = CFBundleGetMainBundle ();
if (NULL != myAppBundle) {
myAppResourcesURL = CFBundleCopyResourcesDirectoryURL (myAppBundle);
if (NULL != myAppResourcesURL) {
(void) CFURLGetFSRef (myAppResourcesURL, &myResourceDirRef);
status = FSGetCatalogInfo (&myResourceDirRef, kFSCatInfoNone, NULL,
NULL, &myResourceDirSpec, NULL);
if ( noErr == status ) {
status = FMActivateFonts (&myResourceDirSpec, NULL, NULL,
kFMLocalActivationContext);
}
}
}
//now i dump the list of fints to nslog and mine is there
fonts = [[NSFontManager sharedFontManager] availableFonts];
fonts = [[[NSFontManager sharedFontManager] availableFontFamilies]
mutableCopy];
[fonts sortUsingSelector: @selector(compare:)];
enumerator = [fonts objectEnumerator];
while (nil != (font = [enumerator nextObject]))
{
NSLog(font);
}
[fonts release];
//but.. this works.. (a system font)
[jobNameText setFont:[NSFont fontWithName:@"American Typewriter"
size:13]];
//and this crashes the machine (my font i loaded)
[feedbackField setFont:[NSFont fontWithName:@"Bank Gothic BT"
size:13]];
error i get:
Uncaught exception: <NSInvalidArgumentException> *** -[NSTextView
setFont:]: nil NSFont given.
_______________________________________________
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.