• 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: Application unique/specific font question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application unique/specific font question


  • Subject: Re: Application unique/specific font question
  • From: Matt Neuburg <email@hidden>
  • Date: Tue, 23 Jan 2007 20:10:25 -0800
  • Thread-topic: Application unique/specific font question

On Tue, 23 Jan 2007 15:30:54 -0700, "Marcus S. Zarra" <email@hidden> said:
>Is it possible to load a font from the application bundle rather than
>from the font directory?

Something like this (slight simplification of Shaun Wexler's code):

    NSURL *fontsURL = [NSURL fileURLWithPath: [[[NSBundle mainBundle]
resourcePath] stringByAppendingPathComponent:@"Fonts"]];
    FSRef fsRef;
    FSSpec fsSpec;
    (void) CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
    (void) FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
NULL);
    (void) ATSFontActivateFromFileSpecification
        (&fsSpec, kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &container);

However, do note that by far the biggest problem (in my experience) is
getting the blasted font into the bundle to begin with! If you just use the
built-in copy files phase, the font file is stripped of its resource fork,
which, in many cases, is where the information was. So you have to use a run
script phase instead. Until I figured this out, I couldn't get the above
code to work (because the font file was no longer a valid font file). m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Application unique/specific font question
      • From: Shaun Wexler <email@hidden>
    • Re: Application unique/specific font question
      • From: Buddy Kurz <email@hidden>
  • Prev by Date: Setting the application Icon
  • Next by Date: Re: My Core Data experiences
  • Previous by thread: Re: Application unique/specific font question
  • Next by thread: Re: Application unique/specific font question
  • Index(es):
    • Date
    • Thread