< Previous PageNext Page > Hide TOC

Initiating Font Changes

The user normally changes the font of the selection by manipulating the Font panel (also called the Fonts window) and the Font menu. These objects initiate the intended change by sending an action message to the font manager. There are four font-changing action methods:

The first three cause the font manager to query the sender of the message in order to determine which trait to add or remove, or how to modify the font. The last causes the font manager to use the settings in the Font panel to modify the font. The font manager records this information and uses it in later requests to convert fonts, as described in “Responding to Font Changes.”

When the font manager receives an addFontTrait or removeFontTrait message, it queries the sender with a tag message, interpreting the return value as a trait mask for use with convertFontToHaveTrait or convertFontToNotHaveTrait, as described in “Converting Fonts Manually.” The Font menu commands Italic and Bold, for example, have trait mask values of ItalicMask and BoldMask, respectively. See the section “Constants” in the NSFontManager reference documentation for a list of trait mask values.

When the font manager receives a modifyFont message, it queries the sender with a tag message and interprets the return value as a particular kind of conversion to perform, via the various conversion methods described in “Converting Fonts Manually.” For example, a button whose tag value is SizeUpFontAction causes the font manager’s convertFont method to increase the size of the NSFont passed as the argument. See the NSFontManager method modifyFont for a list of conversion tag values.

For modifyFontViaPanel, the font manager sends the application’s Font panel a panelConvertFont message. The Font panel in turn uses the font manager to convert the font provided according to the user’s choices. For example, if the user selects only the font family in the Font panel (perhaps Helvetica), then for whatever fonts are provided to panelConvertFont, only the family is changed: Courier Medium 10.0 point becomes Helvetica Medium 10.0 point, and Times Italic 12.0 point becomes Helvetica Oblique 12.0 point.



< Previous PageNext Page > Hide TOC


© 1997, 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-02-08)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.