Re: Installing a font programmatically?
Re: Installing a font programmatically?
- Subject: Re: Installing a font programmatically?
- From: John Stiles <email@hidden>
- Date: Mon, 22 Nov 2004 12:21:33 -0800
You can load the font in code when you app starts up, without
installing it anywhere. Just keep it in your bundle.
Here's some code, copy-and-pasted from my app.
ATSFontContainerRef container;
OSStatus err = ATSFontActivateFromMemory(
data.Ptr<void>(),
data.Size(),
kATSFontContextLocal,
kATSFontFormatUnspecified,
NULL,
kATSOptionFlagsDefault,
&container );
if( err != noErr )
return NULL;
ATSFontRef fontRefs[100];
ItemCount fontCount;
err = ATSFontFindFromContainer(
container,
kATSOptionFlagsDefault,
arrsize(fontRefs),
fontRefs,
&fontCount );
if( err != noErr || fontCount < 1 )
return NULL;
NSString *fontName;
err = ATSFontGetPostScriptName(
fontRefs[0],
kATSOptionFlagsDefault,
reinterpret_cast<CFStringRef*>( &fontName ) );
// now you can use [NSFont fontWithName:fontName size:size];
On Nov 22, 2004, at 11:49 AM, Glen Simmons wrote:
I need to install a font for one of the features of my app to work.
I'd really like to avoid building an installer just to put this one
file in the Fonts folder. Can this be done programmatically in a safe,
clean way? I'm concerned about permissions, availability to apps,
location (~/Fonts vs /Fonts), etc. Any insights would be most
appreciated.
Thanks,
Glen Simmons
Opportunity is missed by most because it is dressed in overalls and
looks like work. -- Thomas Alva Edison
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden