• 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: Unlocalises displayName for NSFont?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Unlocalises displayName for NSFont?
      • From: Fredrik Olsson <email@hidden>
References: 
 >Unlocalises displayName for NSFont? (From: Fredrik Olsson <email@hidden>)
 >Re: Unlocalises displayName for NSFont? (From: Shawn Erickson <email@hidden>)
 >Re: Unlocalises displayName for NSFont? (From: Fredrik Olsson <email@hidden>)

  • Prev by Date: Need Help Displaying a Floating-Point Image
  • Next by Date: Re: Programmatically setting Principle Class
  • Previous by thread: Re: Unlocalises displayName for NSFont?
  • Next by thread: Re: Unlocalises displayName for NSFont?
  • Index(es):
    • Date
    • Thread