• 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
Loading Typeface from NSBundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Loading Typeface from NSBundle


  • Subject: Loading Typeface from NSBundle
  • From: Pascal Harris <email@hidden>
  • Date: Sat, 04 Feb 2012 00:13:37 +0000

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?

_______________________________________________

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: John Joyce <email@hidden>
  • Prev by Date: NSColorWell / NSColorPanel
  • Next by Date: Re: Loading Typeface from NSBundle
  • Previous by thread: Re: NSColorWell / NSColorPanel
  • Next by thread: Re: Loading Typeface from NSBundle
  • Index(es):
    • Date
    • Thread