Re: Unlocalises displayName for NSFont?
Re: Unlocalises displayName for NSFont?
- Subject: Re: Unlocalises displayName for NSFont?
- From: Shawn Erickson <email@hidden>
- Date: Fri, 04 Aug 2006 07:22:42 -0700
On Aug 4, 2006, at 7:18 AM, Fredrik Olsson wrote:
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?
That appears to the do basically the same thing that [NSFont
fontName] does. If you don't want the "-" in the results just replace
it with a space.
-Shawn
_______________________________________________
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