Re: Application unique/specific font question
Re: Application unique/specific font question
- Subject: Re: Application unique/specific font question
- From: Shaun Wexler <email@hidden>
- Date: Tue, 23 Jan 2007 23:45:10 -0800
On Jan 23, 2007, at 8:10 PM, Matt Neuburg wrote:
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.
AFAIR, you simply need to set "COPYING_PRESERVES_HFS_DATA" in your
target.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
"Problems cannot be solved by the same level of thinking that created
them." - Albert Einstein
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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