• 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: NSFont system help or documentation needed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFont system help or documentation needed


  • Subject: Re: NSFont system help or documentation needed
  • From: Dustin Voss <email@hidden>
  • Date: Tue, 16 Dec 2003 16:54:28 -0800

On 16 Dec, 2003, at 10:31 AM, Robert Clair wrote:

Is there any better source of documentation or information on NSFont, NSFontManager, NSFontPanel, etc. ? A lot of this is non-obvious and badly/un documented.

[snip problem n, keyboard-font synchronization notification]

Problem N-1:

I have a popup for font families, I wanted one for Typeface. Each font has three names - [myFont fontName] which gives something like "TimesRoman", [myFont family] which gives "Times" and [myFont displayName] which gives "Times Regular". There is no reasonable way to parse the fontName's - some have the face separated by a "-", some by space, some just by caps. [NSFontManager availableFonts] returns an array of fontNames. But I couldn't find a way to go from fontName to displayName. The only way I could figure out to do this was, for every fontName returned by availableFonts -

1) create an instance of the font using [NS fontWithName:size:]
2) get the family name and compare it with the currently selected family
3) strip the family name off of the display name and add it to the popup
4) keep an array of the fontNames corresponding to the items in the Typeface popup to actually select the font ( using the displayName to get the font does not work reliably - it works most of the time but fails miserably for some fonts, even if you remember to strip out "Regular".)

This works and is fast enough to go in a dialog box validation routine, but still it feels like a kludge. There ought to be a better way.

There is a better way.

1. Take the font families returned by NSFontManager's availableFontFamilies.
2. Call NSFontManager's availableMembersOfFontFamily: on each family name.
3. This will return an array of member information arrays. Index 1 of each member information array will be the typeface of that member of the font family: "Roman", "Bold", etc.

I understand some of why this is designed this way, the difficulties of dealing with multiple selection, etc, but a lot of this seems overly byzantine. Why should you have to resort to private hackery to get the font currently shown by the font panel ??

I myself would just as soon avoid the font panel entirely. I don't like it; it's not very Mac-like. Neither is the color panel, come to that.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >NSFont system help or documentation needed (From: Robert Clair <email@hidden>)

  • Prev by Date: Re: windows title bar at left
  • Next by Date: Re: Using custom NSValueTransformer objects in single-window applications
  • Previous by thread: NSFont system help or documentation needed
  • Next by thread: sending mail
  • Index(es):
    • Date
    • Thread