• 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: Using a font without installing it
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using a font without installing it


  • Subject: Re: Using a font without installing it
  • From: Shaun Wexler <email@hidden>
  • Date: Sun, 16 Jan 2005 12:14:19 -0800

On Jan 16, 2005, at 12:43 AM, Stefan Landvogt wrote:

Shauns code that loads all fonts in a certain directory. Call this method in your AppDelegate...

Be aware, that fonts have also copyright, before you distribute them with your application.
I learned by the hard way, that Myriad Web Bold is not public domain...


- (void)loadLocalFonts {
NSString *fontsFolder = [[NSBundle mainBundle] resourcePath]; //[ stringByAppendingPathComponent:@"Fonts"];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
FSSpec fsSpec;
(void)CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
OSStatus status = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL,
NULL, &fsSpec, NULL);
if (noErr == status) {
FMGeneration generationCount = FMGetGeneration();
status = FMActivateFonts(&fsSpec, NULL, NULL,
kFMLocalActivationContext);
generationCount = FMGetGeneration() - generationCount;
}
}
}
}

The generationCount was only necessary because I printed a log message indicating how many new fonts were installed. You could simplify it to this:


- (void)loadLocalFonts
{
NSString *fontsFolder;
if ((fontsFolder = [[NSBundle mainBundle] resourcePath])) {
NSURL *fontsURL;
if ((fontsURL = [NSURL fileURLWithPath:fontsFolder])) {
FSRef fsRef;
FSSpec fsSpec;
(void)CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL) == noErr) {
FMActivateFonts(&fsSpec, NULL, NULL, kFMLocalActivationContext);
}
}
}
}
--
Shaun Wexler
MacFOH
http://www.macfoh.com


_______________________________________________
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


References: 
 >RE: Re: Using a font without installing it (From: "Peter Karlsson" <email@hidden>)
 >Re: Using a font without installing it (From: Shaun Wexler <email@hidden>)
 >Re: Using a font without installing it (From: Andy Lee <email@hidden>)
 >Re: Using a font without installing it (From: Shaun Wexler <email@hidden>)
 >Re: Using a font without installing it (From: Stefan Landvogt <email@hidden>)

  • Prev by Date: Re: Changing Bundle Name
  • Next by Date: Re: Modal Window Question
  • Previous by thread: Re: Using a font without installing it
  • Next by thread: Cocoa & NS ??
  • Index(es):
    • Date
    • Thread