• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Loading Typeface from NSBundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Loading Typeface from NSBundle
      • From: Jens Alfke <email@hidden>
References: 
 >Loading Typeface from NSBundle (From: Pascal Harris <email@hidden>)

  • Prev by Date: Loading Typeface from NSBundle
  • Next by Date: Re: Loading Typeface from NSBundle
  • Previous by thread: Loading Typeface from NSBundle
  • Next by thread: Re: Loading Typeface from NSBundle
  • Index(es):
    • Date
    • Thread