2

I'm trying to update my code so it will compile x86_64, unfortunately the code below is the main culprit (which happens to be roughly ten years old). I know it should be a CTFont type class, although I have no idea how to adapt this old code to the current. Any help would be appreciated. I've also included a reference to this code and some of its predecessors, which also happen to be deprecated. thanks!

- (void)loadLocalFonts
{
   NSString *fontsFolder;    
   if ((fontsFolder = [[NSBundle mainBundle] resourcePath])) {
       NSURL *fontsURL;
       if ((fontsURL = [NSURL fileURLWithPath:fontsFolder])) {
           FSRef fsRef;
           FSSpec fsSpec;
           (void)CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
           if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
NULL) == noErr) {
               FMActivateFonts(&fsSpec, NULL, NULL, kFMLocalActivationContext);
           }
       }
   }
}

Reference: Using Custom Fonts In Your Cocoa Applications

justin
  • 104,054
  • 14
  • 179
  • 226
  • The answer to your question could be pretty broad. What does your `loadLocalFonts` function do? If you want to present a selection of fonts to choose from, bring up a font panel (via [`NSFontPanel`](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSFontPanel_Class/Reference/Reference.html)) and change fonts via the [`NSFontManager`](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSFontManager_Class/Reference/Reference.html). – Michael Dautermann Jan 11 '12 at 07:29
  • @MichaelDautermann -- how is it broad? i gave the exact code i'm using and an example, which is very specific. NSFontManager has nothing to do with my questions. i'm trying to display a custom font in the gui, which currently uses FMActivateFonts... –  Jan 11 '12 at 07:31

1 Answers1

1

Thanks for the comment back. I wasn't sure exactly what you were doing there.

To me it looked like you were loading a selection (or font family) from your resource folder and activating them (whatever that used to be ... Font Manager FM_____ calls feel like 10 years ago at this point :-)

Anyways, check out this potentially useful question that has answers that may help you out. Looks like it might be as easy as making the font available via a ATSApplicationFontsPath key in the info.list file (the higher rated answer there).

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • thanks, i'll take a look. i think the only line that needs changed is the one i mentioned -- i'm hoping. –  Jan 11 '12 at 07:49