A method identified as deprecated has been superseded and may become unsupported in the future.
Returns the names of fonts that the Application Kit tries first when a character has no font specified. (Deprecated in Mac OS X v10.4. The NSFontDescriptor
constant NSFontCascadeListAttribute
offers more powerful font substitution management.)
+ (NSArray *)preferredFontNames
Returns the names of fonts that the Application Kit tries first when a character has no font specified or when the font specified doesn’t have a glyph for that character. If none of these fonts provides a glyph, the remaining fonts on the system are searched for a glyph.
NSFont.h
Sets the list of preferred font names. (Deprecated in Mac OS X v10.4. The NSFontDescriptor
constant NSFontCascadeListAttribute
offers more powerful font substitution management.)
+ (void)setPreferredFontNames:(NSArray *)fontNames
Sets the list of preferred font names to fontNames and records them in the user defaults database for all applications. The Application Kit tries these fonts first when a character has no font specified or when the font specified doesn’t have a glyph for that character. If none of these fonts provides a glyph, the remaining fonts on the system are searched for a glyph.
This method is useful for optimizing glyph rendering for uncommon scripts, by guaranteeing that appropriate fonts are searched first. For example, suppose you have three hundred Latin alphabet fonts and one Cyrillic alphabet font. When you read a document in Russian, you want it to find the Cyrillic font quickly. Ordinarily, the Application Kit will search for the Cyrillic font among all 301 fonts. But if it is in the list of preferred fonts, the Cyrillic font will be one of the first searched.
NSFont.h
Records the given font name as one used in the current print operation. (Deprecated in Mac OS X v10.4. This is now automatically handled by Quartz.)
+ (void)useFont:(NSString *)fontName
Records fontName as one used in the current print operation.
The NSFont
class object keeps track of the fonts used in an NSView
by recording each one that receives a set
message. When the view is called upon to generate conforming PostScript language output (such as during printing), the NSFont
class provides the list of fonts required for the %%DocumentFonts
comment, as required by Adobe’s document structuring conventions.
The useFont:
argument augments this system by providing a way to register fonts that are included in the document but not set using NSFont
’s set
method. For example, you might set a font by executing the setfont
operator within a function created by the pswrap
utility. In such a case, be sure to pair the use of the font with a useFont:
message to register the font for listing in the document comments.
NSFont.h
Returns the AFM font’s dictionary. (Deprecated in Mac OS X v10.4. Use accessor functions listed in “Keys to the AFM Dictionary”
instead.)
- (NSDictionary *)afmDictionary
Always returns nil
.
NSFont.h
Returns the default line height for the receiver. (Deprecated in Mac OS X v10.4. Use the NSLayoutManager
method defaultLineHeightForFont:
instead.)
- (CGFloat)defaultLineHeightForFont
Equivalent to ascent plus descent plus linegap.
NSFont.h
Returns the name of the receiver’s encoding scheme. (Deprecated in Mac OS X v10.4. Use mostCompatibleStringEncoding
instead.)
- (NSString *)encodingScheme
Returns the name of the receiver’s encoding scheme, such as “AdobeStandardEncoding,” “ISOLatin1Encoding,” “FontSpecific,” and so on.
NSFont.h
Returns a Boolean value indicating whether the receiver encodes the given glyph. (Deprecated in Mac OS X v10.4. The value can be deduced by aGlyph < [NSFont numberOfGlyphs]
since only NSNativeShortGlyphPacking
is supported.)
- (BOOL)glyphIsEncoded:(NSGlyph)aGlyph
Returns YES
if the receiver encodes aGlyph, NO
if it doesn’t contain it.
NSFont.h
Returns the best way to encode the receiver’s glyphs into an array of bytes. (Deprecated in Mac OS X v10.4. Only NSNativeShortGlyphPacking
is supported.)
- (NSMultibyteGlyphPacking)glyphPacking
Returns the best way to encode the receiver’s glyphs into an array of bytes. The return value is one of values described in “Constants.”
NSFont.h
Returns a Boolean value indicating whether the receiver is a PostScript base font. (Deprecated in Mac OS X v10.4. This information is not relevant to Mac OS X.)
- (BOOL)isBaseFont
Returns YES
if the receiver is a PostScript base font, NO
if it’s a PostScript composite font composed of other base fonts.
NSFont.h
Calculates and returns a suitable location for the given glyph to be drawn. (Deprecated in Mac OS X v10.4. Context-sensitive interglyph spacing is now performed at the typesetting stage.)
- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph forCharacter:(unichar)aChar struckOverRect:(NSRect)aRect
Calculates and returns a suitable location for aGlyph to be drawn as a diacritic or nonspacing mark relative to aRect, assuming that aGlyph represents aChar. Returns NSZeroPoint
if the location can’t be calculated. The nature of aChar as one appearing above or below its base character determines the location returned. For example, in the first figure below, the gray tilde and box represent aGlyph and aRect, and the black dot is the point returned (defined relative to the origin of the aRect).
To place multiple glyphs with respect to a rectangle, work from the innermost glyphs to the outermost. As you calculate the position of each glyph, enlarge the rectangle to include the bounding rectangle of the glyph in preparation for the next glyph. The second figure shows a tilde, acute accent, and cedilla all placed in their appropriate positions with respect to a rectangle, with the acute accent placed relative to the expanded bounding box of the base rectangle and the tilde.
This method is the last fallback mechanism for performing minimally legible typography when metrics aren’t available. Use it when positionOfGlyph:struckOverGlyph:metricsExist:
indicates that metrics don’t exist for the base glyph specified, or when you are combining glyphs from different fonts (for example, the base glyph is in a different font than the accent). It can account for the layout and placement of most Latin, Greek, and Cyrillic nonspacing marks. You should draw the glyph at the returned location, even if it’s NSZeroRect
.
NSFont.h
Calculates and returns the location of a glyph. (Deprecated in Mac OS X v10.4. Context-sensitive interglyph spacing is now performed at the typesetting stage.)
- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph precededByGlyph:(NSGlyph)prevGlyph isNominal:(BOOL *)flag
Calculates and returns the location of aGlyph relative to prevGlyph, assuming that prevGlyph precedes it in the layout (not necessarily in the character stream). The point returned should be used relative to whatever location is used for prevGlyph. If flag is non-nil
, it’s filled with NO
if kerning tables are available and were used in the calculation; it is filled with YES
if the default spacing is used.
Returns NSZeroPoint
if either aGlyph or prevGlyph is NSControlGlyph
or is invalid. Returns the nominal advancement of prevGlyph if aGlyph is NSNullGlyph
.
This method is useful for sequential glyph placement when glyphs aren’t drawn with a single PostScript operation.
NSFont.h
Calculates and returns a suitable location for the given glyph to be drawn. (Deprecated in Mac OS X v10.4. Context-sensitive interglyph spacing is now performed at the typesetting stage.)
- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph struckOverGlyph:(NSGlyph)baseGlyph metricsExist:(BOOL *)flag
Calculates and returns a suitable location for aGlyph to be drawn as a diacritic or nonspacing mark relative to baseGlyph. The point returned should be used relative to whatever location is used for baseGlyph. If flag is non-nil
it’s filled with YES
if font metrics are available, NO
if they’re not. If flag is returned as NO
, the result isn’t valid and shouldn’t be used. In that case, use positionOfGlyph:struckOverRect:metricsExist:
or positionOfGlyph:forCharacter:struckOverRect:
to calculate a reasonable offset.
– positionsForCompositeSequence:numberOfGlyphs:pointArray:
– positionOfGlyph:struckOverRect:metricsExist:
NSFont.h
Overridden by subclasses to calculate and return a suitable location for a glyph to be drawn. (Deprecated in Mac OS X v10.4. Context-sensitive interglyph spacing is now performed at the typesetting stage.)
- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph struckOverRect:(NSRect)aRect metricsExist:(BOOL *)flag
Overridden by subclasses to calculate and return a suitable location for aGlyph to be drawn as a diacritic or nonspacing mark relative to aRect, provided metrics exist. Returns NSZeroRect
if the location can’t be determined. If flag is non-nil
it’s filled with YES
if font metrics are available, NO
if they’re not. If flag is returned as NO
, the result isn’t valid and shouldn’t be used. In that case, use positionOfGlyph:forCharacter:struckOverRect:
to calculate a reasonable offset.
Because current PostScript font metrics don’t include support for generic placement relative to rectangles, NSFont
’s implementation of this method always returns NSZeroPoint
and returns flag as NO
.
NSFont.h
Calculates and returns a suitable location for a glyph to be drawn. (Deprecated in Mac OS X v10.4. Context-sensitive interglyph spacing is now performed at the typesetting stage.)
- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph withRelation:(NSGlyphRelation)relation toBaseGlyph:(NSGlyph)baseGlyph totalAdvancement:(NSSizePointer)offset metricsExist:(BOOL *)flag
Calculates and returns a suitable location for aGlyph to be drawn relative to baseGlyph, where relation is NSGlyphBelow
or NSGlyphAbove
. The point returned should be used relative to whatever location is used for baseGlyph. This method is useful for calculating the layout of stacked glyphs, found in some non-Western scripts.
If offset is non-NULL
, this method sets it to the larger of the two glyphs’ advancements, allowing for reasonable layout of following glyphs.
If flag is non-nil
, this method sets it to whether font metrics are available: YES
if they are, NO
if they’re not. If metrics aren’t available, the location is calculated as a simple stacking with no gap between baseGlyph and aGlyph. Current Postscript fonts do not contain appropriate font metrics, so this method always sets flag to NO
. If you subclass NSFont
to handle fonts that do contain metrics, override this method.
This method supports only horizontally laid out base glyphs.
NSFont.h
Calculates glyph locations. (Deprecated in Mac OS X v10.4. Context-sensitive interglyph spacing is now performed at the typesetting stage.)
- (NSInteger)positionsForCompositeSequence:(NSGlyph *)glyphs numberOfGlyphs:(NSInteger)numGlyphs pointArray:(NSPointArray)points
Calculates and fills points with the locations for glyphs, assuming the first glyph is a base character and those following are nonspacing marks. These points should all be interpreted as relative to the location of the first glyph in glyphs. The storage block points points to should be large enough for at least numGlyphs points. Returns the number of points that could be calculated.
If the number of points calculated is less than numGlyphs, the number of glyphs provided, you can use positionOfGlyph:struckOverRect:metricsExist:
to determine the positions for the remaining glyphs. When using that method, calculate the base rectangle for each glyph from the bounding rectangles and positions of all preceding glyphs.
NSFont.h
Returns the x-axis offset of the current point when the specified string is drawn with a show
operator in the receiving font. (Deprecated in Mac OS X v10.4. Use the Application Kit string-drawing methods, as described in NSString Additions.)
- (CGFloat)widthOfString:(NSString *)aString
This method is for backward compatibility only. This method performs lossy conversion of aString to the most compatible encoding for the receiving font. Use this method only when you’re sure all of aString can be rendered with the receiving font.
NSFont.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-06-08)