The font manager responds to a font-changing action method
by sending a changeFont
action
message up the responder chain. A text-bearing object that receives
this message should have the font manager convert the fonts in its
selection by invoking convertFont
for each
font and using the NSFont object returned. The convertFont
method
uses the information recorded by the font-changing action method,
such as addFontTrait
, modifying
the font provided appropriately. (There’s no way to explicitly
set the font-changing action or trait; instead, you use the methods
described in “Converting Fonts Manually.”)
This simple Objective-C example assumes there’s only one font in the selection:
- (void)changeFont:(id)sender |
{ |
NSFont *oldFont = [self selectionFont]; |
NSFont *newFont = [sender convertFont:oldFont]; |
[self setSelectionFont:newFont]; |
return; |
} |
Most text-bearing objects have to scan the selection for ranges
with different fonts and invoke convertFont
for
each one.
Last updated: 2008-02-08