• 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
Trying to understand [NSFontManager modifyFont:]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying to understand [NSFontManager modifyFont:]


  • Subject: Trying to understand [NSFontManager modifyFont:]
  • From: Graham Cox <email@hidden>
  • Date: Mon, 06 Aug 2012 10:46:30 +1000

The documentation for [NSFontManager modifyFont:] doesn't make sense to me. It says:



When a responder replies by providing a font to convert in a convertFont: message, the receiver converts the font in the manner specified by sender. The conversion is determined by sending a tag message to sender and invoking a corresponding method:

Sender’s Tag				Method Used
NSNoFontChangeAction		None; the font is returned unchanged.
NSViaPanelFontAction		The Font panel’s panelConvertFont:.
NSAddTraitFontAction		convertFont:toHaveTrait:.
NSRemoveTraitFontAction	convertFont:toNotHaveTrait:.
NSSizeUpFontAction			convertFont:toSize:.
NSSizeDownFontAction		convertFont:toSize:.
NSHeavierFontAction			convertWeight:ofFont:.
NSLighterFontAction			convertWeight:ofFont:.



Consider the case of wanting toggle the "bold" trait of a font. I set the sender's tag to NSAddTraitFontAction, but how do I specify the bold trait, rather than any other trait, e.g. italic? The tag of the sender doesn't have enough information to set the traits mask and there is no other place this information could be supplied that I can see.

What I'm trying to do is to add a toolbar button that can toggle the traits of a font, so it has segments for bold, italic, etc. If I make the button invoke [NSFontManager addFontTrait:], then I can turn ON bold, but I can't turn it off. In fact, I'm puzzled as to how the standard "Bold" text menu item works, because it too simply calls addFontTrait: (according to the action set in IB) and has a tag indicating bold. How then does it REMOVE the bold trait? Is the Font Manager manipulating the action of the menu item when it validates it? Would make sense but I can find no documentation to that effect.

How can I achieve my aim?

--Graham





_______________________________________________

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: Trying to understand [NSFontManager modifyFont:]
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: How to display tool-tip on demand
  • Next by Date: Re: How to display tool-tip on demand
  • Previous by thread: Re: How to display tool-tip on demand
  • Next by thread: Re: Trying to understand [NSFontManager modifyFont:]
  • Index(es):
    • Date
    • Thread