Re: Application unique/specific font question
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