Re: Unlocalises displayName for NSFont?
Re: Unlocalises displayName for NSFont?
- Subject: Re: Unlocalises displayName for NSFont?
- From: Fredrik Olsson <email@hidden>
- Date: Fri, 04 Aug 2006 16:18:36 +0200
Shawn Erickson skrev:
On Aug 4, 2006, at 6:35 AM, Fredrik Olsson wrote:
displayName for NSFont instances returns a localized name (As the
docs says). I have tried to use NSFontDescriptor to get the
non-localized name (As in English), but none of the font attributes I
have tried gives an obvious answer.
Am I peeking the right places, or should I take the result of
fontName and run it through some localizer forcing it to english, and
how would I do that?
It isn't clear exactly what you want but did you look at the following?
-[NSFont familyName] or -[NSFont fontName]
Yes I did, hey boh do not give quite what I want. displayName can
forexample give "Arial Fet" (Localized to Swedish) when I expect "Arial
Bold". I am no font expert, but it looks to me that displayName returns
the fonts family and optionally append face if present.
So I whipped up this little solution:
- (id)_plainFontNameForFont:(NSFont *)font
{
NSString *family = [font familyName];
NSString *face = [[font fontDescriptor]
objectForKey:NSFontFaceAttribute];
if (face) {
return [NSString stringWithFormat:@"%@ %@", family, face, nil];
}
return family;
}
Is this a legal solution, or does it just happen to work on the test
cases I have came up with?
// Fredrik Olsson
_______________________________________________
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