Re: Installing a font programmatically?
Re: Installing a font programmatically?
- Subject: Re: Installing a font programmatically?
- From: Glen Simmons <email@hidden>
- Date: Mon, 22 Nov 2004 14:39:54 -0600
Sorry, I didn't explain myself sufficiently. I need for other apps to
be able to access the font, so I do actually need to get the font into
the proper place. So, I'm still looking for insights on what happens if
my app copies the font into the Fonts folder. i.e. would a logout/login
be necessary? What about permissions? etc.
Would this code allow my app to load and use the font without having to
relaunch or logout/login?
Thanks,
Glen
On 22 Nov, 2004, at 2:21 PM, John Stiles wrote:
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:
email@hidden
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