This is NSFontManager.rtf in view mode; [Download] [Up]
paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc. All Rights Reserved. s4 li100 fi0 ri1007 ql f0 b fs36 fs100 fs36 NSFontManager pard s14 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject fs20 fs28 s7 f0 b fs24 Conforms To:tab b0 fs28 f1 NSObject (NSObject) fs20 fs28 s8 f0 b fs24 Declared In:tab b0 fs28 f1 AppKit/NSFontManager.h fs20 fs28 pard s19 li100 fi0 ri1007 ql f0 b fs28 fs20 fs28 Class Description fs14 fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 fs28 NSFontManager declares the programmatic interface to objects that manage font conversion in an application. NSFontManager is the center of activity for font conversion. NSFontManager accepts messages from font conversion user-interface objects such as the Font menu or the Font panel (see NSFontPanel for more details) and appropriately converts the current font in the selection by sending a b changeFont:b0 message up the responder chain. fs16 fs28 When an object receives a b changeFont:b0 message, it should message NSFontManager (by sending it a b convertFont:b0 message), asking it to convert the font in whatever way the user has specified. Thus, any object containing a font that can be changed should respond to the b changeFont:b0 message by sending a b convertFont:b0 message back to the NSFontManager for each font in the selection. fs16 fs28 To use NSFontManager, you simply insert a Font menu into your application'27s menu using the appropriate interface construction tools (such as Interface Builder). You can also obtain a Font menu by sending a b getFontMenu:b0 message to NSFontManager and then inserting the menu it returns into the application'27s main menu. Once the Font menu is installed, your application automatically gains the functionality of both the Font menu and the Font panel. fs16 fs28 NSFontManager'27s delegate can restrict which font names will appear in the Font Panel. See 'aaMethods Implemented by the Delegate'ba at the end of this class specification for more information. fs16 fs28 NSFontManager can be used to convert a font or find out the attributes of a font. It can also be overridden to convert fonts in some application-specific manner. The default implementation of font conversion is very conservative: The font isn'27t converted unless all traits of the font can be maintained across the conversion. fs16 fs28 Generally, you obtain an instance of NSFontManager by sending a b sharedFontManagerb0 message to the NSFontManager class object. NSFontManager will return a font manager object that is shared within your application. NSFontManager normally returns a pre-defined font manager object, but the actual object which is returned can be changed by previously invoking the b setFontManagerFactoryb0 factory to some other kind of object. fs16 fs28 pard s18 li477 fi0 ri1007 ql f0 b fs24 fs4 fs24 Font Traits pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 fs28 Fonts work mainly in terms of i traitsi0 , or characteristics, such as bold, italic, condensed, and so on. Traits are described by a collection of constants such as b NSItalicFontMaskb0 , b NSBoldFontMaskb0 , and so on. The full complement of traits are defined in fs28 AppKit/NSFontManager.hfs28 . The values of traits are defined in bitwise form so they can be or'27ed together, although some traits, such as b NSBoldFontMaskb0 and b NSUnboldFontMaskb0 naturally conflict and have the effect of turning each other off. You use one of the b convertFontb0 'bc methods to obtain a font of the desired characteristics from an existing font. fs16 fs28 The b convertFont:toHaveTrait:b0 and the b convertFont:toNotHaveTrait:b0 methods deal with only one trait at a time. To convert a font to have (or not have) multiple traits, you must invoke these methods for each separate trait you wish to add to or remove from the font. Alternatively, use the b fontWithFamily:traits:weight:size:b0 method to specify multiple traits in one invocation.tab fs16 fs28 The i sizei0 of a font in the method definitions below is defined in 'aapoints'ba, which, in the current milieu, are actually PostScript units'd0a PostScript unit being defined as 1/72 of an inch, or 0.0139 of an inch. In metric equivalents, a PostScript unit is 0.3528 millimetres. PostScript 'aapoints'ba are minimally different from 'aaprinter'27s points'ba, so for all intents and purposes you can think of PostScript units and points as interchangeable. fs16 fs28 The i weighti0 of a font as used in these methods is simply a value representing a point in a continuum of font weights from lightest to heaviest. There'27s no simple one-to-one mapping of some integer value to, say, a b boldb0 weight. If you query the font for its weight value, increment the value, and use it as a new weight, you'27ll not necessarily obtain a different face (such as a transition from medium to bold) in a new instance of the font. fs16 fs28 pard s19 li100 fi0 ri1007 ql f0 b fs24 fs28 Managing the FontManager fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 + (void)b setFontManagerFactory:b0 (Class)i classIdi0 tab Sets the class used to create the NSFontManager. fi-6552 fs16 fs28 fi-6552 + (void)b setFontPanelFactory:b0 (Class)i classIdi0 tab Sets the class used to create the FontPanel. fi-6552 fs16 fs28 fi-6552 + (NSFontManager *)b sharedFontManagerb0 tab Returns a shared FontManager. pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Converting Fonts fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (NSFont *)b convertFont:b0 (NSFont *)i fontObjecti0 tab Converts i fontObjecti0 according to the user'27s selections from the Font panel or the Font menu. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b convertFont:b0 (NSFont *)i fontObjecti0 tab Returns a Font object whose traits are the same as those of s11 li7030 fi-6553 fi-5796 b toFamily:b0 (NSString *)i familyi0 tab tab i fontObjecti0 except as specified by i familyi0 . tab s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b convertFont:b0 (NSFont *)i fontObjecti0 tab Returns a Font object whose traits are the same as those of s11 li7030 fi-6553 fi-5796 b toFace:b0 (NSString *)i typefacei0 tab tab i fontObjecti0 except as specified by i typefacei0 . tab s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b convertFont:b0 (NSFont *)i fontObjecti0 tab Returns a Font object whose traits are the same as those of s11 li7030 fi-6553 fi-5796 b toHaveTrait:b0 (NSFontTraitMask)i traiti0 tab tab i fontObjecti0 except as altered by the addition of the traits specified by i traiti0 . s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b convertFont:b0 (NSFont *)i fontObjecti0 tab Returns a Font object whose traits are the same as those of s11 li7030 fi-6553 fi-5796 b toNotHaveTrait:b0 (NSFontTraitMask)i traiti0 tab tab i fontObjecti0 except as altered by the removal of the traits specified by i traiti0 . s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b convertFont:b0 (NSFont *)i fontObjecti0 tab Returns a Font object whose traits are the same as those of s11 li7030 fi-6553 fi-5796 b toSize:b0 (float)i sizei0 tab tab i fontObjecti0 except as specified by i sizei0 . tab s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b convertWeight:b0 (BOOL)i upFlagi0 tab Attempts to increase (if i upFlagi0 is YES) or decrease (if s11 li7030 fi-6553 fi-5796 b ofFont:b0 (NSFont *)i fontObjecti0 tab tab i upFlagi0 is NO) the weight of the font specified by i fontObjecti0 . s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b fontWithFamily:b0 (NSString *)i familyi0 tab Tries to find a font that matches the specified s11 li7030 fi-6553 fi-5796 b traits:b0 (NSFontTraitMask)i traitsi0 tab tab characteristics. b weight:b0 (int)i weighti0 tab b size:b0 (float)i sizei0 tab pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Setting and Getting Parameters fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (SEL)b actionb0 tab Gets the action sent by the FontManager. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSArray *)b availableFontsb0 tab Provides an array listing all available fonts. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSMenu *)b fontMenu:b0 (BOOL)i createi0 tab Returns the Font menu, creating one if it doesn'27t exist and i createi0 is YES. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFontPanel *)b fontPanel:b0 (BOOL)i createi0 tab Returns the Font panel, creating one if it doesn'27t exist and i createi0 is YES. fi-6552 fs16 fs28 fi-6552 {f3 -} (BOOL)b isEnabledb0 tab Returns whether the Font panel and menu are enabled. fi-6552 fs16 fs28 fi-6552 {f3 -} (BOOL)b isMultipleb0 tab Returns whether the selection contains multiple fonts. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFont *)b selectedFontb0 tab Returns the first font in the current selection fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setAction:b0 (SEL)i aSelectori0 tab Sets the action to that specified by i aSelectori0 to be sent by the FontManager when the user selects a new font. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setEnabled:b0 (BOOL)i flagi0 tab Enables or disables the Font panel and menu depending on i flagi0 . fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setFontMenu:b0 (NSMenu *)i newMenui0 tab Sets the font menu to i newMenui0 . fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setSelectedFont:b0 (NSFont *)i fontObjecti0 tab Notifies FontManager of the selection'27s current font from s11 li7030 fi-6553 fi-5796 b isMultiple:b0 (BOOL)i flagi0 tab tab i fontObjecti0 with i flagi0 indicating whether the selection has multiple fonts. s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (NSFontTraitMask)b traitsOfFont:b0 (NSFont *)i fontObject s11 li7030 fi-6553 fi-5796 i0 tab Returns the font traits of i fontObjecti0 . s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (int)b weightOfFont:b0 (NSFont *)i fontObjecti0 tab Returns the font weighti i0 of i fontObjecti0 . pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Target and Action Methods fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (BOOL)b sendActionb0 tab Dispatches the action message up the responder chain. pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Assigning a Delegate fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (id)b delegateb0 tab Returns the FontManager'27s delegate. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setDelegate:b0 (id)i anObjecti0 tab Sets the FontManager'27s delegate to i anObjecti0 . pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Methods Implemented by the Delegate fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (BOOL)b fontManager:b0 (id)i senderi0 b willIncludeFont:b0 (NSString *)i fontName s11 li7030 fi-6553 fi-5796 i0 tab Responds to a message informing the FontManager'27s delegate that the FontPanel is about to include i fontNamei0 in the list displayed to the user; if this method returns NO, the font isn'27t added; otherwise, it is. }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.