Re: Check font is installed
Re: Check font is installed
- Subject: Re: Check font is installed
- From: Keith Blount <email@hidden>
- Date: Mon, 2 Oct 2006 13:26:36 -0700 (PDT)
Thanks for your answers - much appreciated. Something
as simple as trying to create the font and checking to
see if it is nil in my preferences code didn't even
occur to me - d'oh!
So, wherever a default font can be called, I am now
just checking whether it is nil or not and setting the
font to -systemFontOfSize:whatever if so. Hopefully
this should resolve things - I'll keep my fingers
crossed for no more bug reports about this one. :)
Thanks again and all the best,
Keith
--- Philip Dow <email@hidden> wrote:
> 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 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