Re: Loading Typeface from NSBundle
Re: Loading Typeface from NSBundle
- Subject: Re: Loading Typeface from NSBundle
- From: John Joyce <email@hidden>
- Date: Fri, 03 Feb 2012 21:05:32 -0600
On Feb 3, 2012, at 6:13 PM, Pascal Harris wrote:
> I'm trying to load a custom typeface from my application bundle (a TrueType font of my own design). Hunting around on the web reveals only methods which are deprecated to the extent of not working under OS X Lion (FMActivateFonts):
>
> #import <QD/Fonts.h>
>
> -------------------
>
> NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
> if (fontsFolder) {
> NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
> if (fontsURL) {
> FSRef fsRef;
> FSSpec fsSpec;
> (void)CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
> OSStatus status = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL,
> NULL, &fsSpec, NULL);
> if (noErr == status) {
> FMGeneration generationCount = FMGetGeneration();
> status = FMActivateFonts(&fsSpec, NULL, NULL,
> kFMLocalActivationContext);
> generationCount = FMGetGeneration() - generationCount;
> if (generationCount) {
> NSLog(@"app - %@ added %u font file%s", name, generationCount,
> (generationCount == 1 ? "" : "s"));
> }
> }
> }
> }
>
>
> My question is (I hope) simple. How does one load fonts from the Application Bundle in Lion?
>
Does this work for you...?
http://stackoverflow.com/questions/2444717/embed-font-in-a-mac-bundle
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden