• 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: How to get bold and plain fonts?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get bold and plain fonts?


  • Subject: Re: How to get bold and plain fonts?
  • From: Kyle Sluder <email@hidden>
  • Date: Sat, 30 May 2015 22:44:52 -0500

On Sat, May 30, 2015, at 09:42 PM, Graham Cox wrote:
> I’m using -[NSFontManager availableFontNamesWithTraits:] and I want to
> get the names of all of the fonts that have both a regular (plain) and
> bold option.
>
> I’ve tried various things, but this seems like it should work:
>
> 	NSArray* fonts = [[NSFontManager sharedFontManager] availableFontNamesWithTraits:NSBoldFontMask | NSUnboldFontMask];

Here, you're asking for "all fonts that consider themselves to be both
bold and unbold". This set is going to be empty (unless you have a
particularly broken font installed).

>
> Except it returns no results. According to the docs if I pass 0 for
> traits, it should return all the plain fonts, and it’s equivalent to
> NSUnboldFontMask | NSUnitalicFontMask. That returns no results.
>

This is a known bug.

If you want to query for fonts with certain traits, you're much better
off using NSFontDescriptor.

--Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: How to get bold and plain fonts?
      • From: Graham Cox <email@hidden>
    • Re: How to get bold and plain fonts?
      • From: Graham Cox <email@hidden>
References: 
 >How to get bold and plain fonts? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: How to get bold and plain fonts?
  • Next by Date: Re: How to get bold and plain fonts?
  • Previous by thread: Re: How to get bold and plain fonts?
  • Next by thread: Re: How to get bold and plain fonts?
  • Index(es):
    • Date
    • Thread