Re: Unlocalises displayName for NSFont?
Re: Unlocalises displayName for NSFont?
- Subject: Re: Unlocalises displayName for NSFont?
- From: Aki Inoue <email@hidden>
- Date: Fri, 4 Aug 2006 10:07:50 -0700
Fredrik,
It's unclear your intention here. The font's fullname (accessible
via -displayName) is coming from an independent entry in the font's
name database independent from other names such as family names. In
other words, font designers are free to have names that don't conform
to the rule you're using here to derive the font name (and there are
tons of irregular fonts out there).
What's your intended use of the derived name ?
Aki
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?
// 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
_______________________________________________
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