• 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: Check font is installed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check font is installed


  • Subject: Re: Check font is installed
  • From: Philip Dow <email@hidden>
  • Date: Mon, 2 Oct 2006 21:05:31 +0200

Hi Keith

I believe you can use [NSFont fontWithName:size:] and if that method returns nil, you'll know you are requesting an uninstalled font--or your font name isn't right. =)

Have a look at the NSFont docs for more details.

-Phil

On Oct 2, 2006, at 8:46 PM, Keith Blount wrote:

Hello,

I'm probably missing the obvious here, but searches on
"installed" and "fonts" only bring up information
about putting together a menu of installed fonts, and
adding "check" to ths search only returns very little
indeed. :)

My program sets up certain default fonts for its
various editors and views in its Preferences. If any
of these fonts are not installed on the user's
machine, however, this can cause my program to act in
very weird ways - it completely messes up the
interface and renders it unusable until the user
alters the Preferences so that the fonts are set to
something that is actually on the system and then
restarts.

What is the best way to check whether a given font is
on the system and return a different font if not?
Would something like this be enough:

NSString *defaultFontName = [[[NSFontManager
sharedFontManager] availableFonts]
containsObject:@"Optima"] ? @"Optima" : @"Helvetica";

Even then, what if the user has deleted "Helvetica"?
Is this safe or is there a better way?

Thanks in advance,
Keith

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.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


_______________________________________________ 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
  • Follow-Ups:
    • Re: Check font is installed
      • From: Keith Blount <email@hidden>
References: 
 >Check font is installed (From: Keith Blount <email@hidden>)

  • Prev by Date: Check font is installed
  • Next by Date: Re: Custom binding problem...can't figure out how to trigger a notification on set
  • Previous by thread: Check font is installed
  • Next by thread: Re: Check font is installed
  • Index(es):
    • Date
    • Thread