Deprecated NSFont Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in OS X v10.4

preferredFontNames

Returns the names of fonts that the Application Kit tries first when a character has no font specified. (Deprecated in OS X v10.4. The NSFontDescriptor constant NSFontCascadeListAttribute offers more powerful font substitution management.)

+ (NSArray *)preferredFontNames
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

setPreferredFontNames:

Sets the list of preferred font names. (Deprecated in OS X v10.4. The NSFontDescriptor constant NSFontCascadeListAttribute offers more powerful font substitution management.)

+ (void)setPreferredFontNames:(NSArray *)fontNames
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

useFont:

Records the given font name as one used in the current print operation. (Deprecated in OS X v10.4. This is now automatically handled by Quartz.)

+ (void)useFont:(NSString *)fontName
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

afmDictionary

Returns the AFM font’s dictionary. (Deprecated in OS X v10.4. Use accessor functions listed in “Keys to the AFM Dictionary” instead.)

- (NSDictionary *)afmDictionary
Discussion

Always returns nil.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

defaultLineHeightForFont

Returns the default line height for the receiver. (Deprecated in OS X v10.4. Use the NSLayoutManager method defaultLineHeightForFont: instead.)

- (CGFloat)defaultLineHeightForFont
Discussion

Equivalent to ascent plus descent plus linegap.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

encodingScheme

Returns the name of the receiver’s encoding scheme. (Deprecated in OS X v10.4. Use mostCompatibleStringEncoding instead.)

- (NSString *)encodingScheme
Discussion

Returns the name of the receiver’s encoding scheme, such as “AdobeStandardEncoding,” “ISOLatin1Encoding,” “FontSpecific,” and so on.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

glyphIsEncoded:

Returns a Boolean value indicating whether the receiver encodes the given glyph. (Deprecated in OS X v10.4. The value can be deduced by aGlyph < [NSFont numberOfGlyphs] since only NSNativeShortGlyphPacking is supported.)

- (BOOL)glyphIsEncoded:(NSGlyph)aGlyph
Discussion

Returns YES if the receiver encodes aGlyph, NO if it doesn’t contain it.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

glyphPacking

Returns the best way to encode the receiver’s glyphs into an array of bytes. (Deprecated in OS X v10.4. Only NSNativeShortGlyphPacking is supported.)

- (NSMultibyteGlyphPacking)glyphPacking
Discussion

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.”

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

isBaseFont

Returns a Boolean value indicating whether the receiver is a PostScript base font. (Deprecated in OS X v10.4. This information is not relevant to OS X.)

- (BOOL)isBaseFont
Discussion

Returns YES if the receiver is a PostScript base font, NO if it’s a PostScript composite font composed of other base fonts.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

positionOfGlyph:forCharacter:struckOverRect:

Calculates and returns a suitable location for the given glyph to be drawn. (Deprecated in 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
Discussion

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).

../Art/nsfont-glyphoverrect.gif

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

positionOfGlyph:precededByGlyph:isNominal:

Calculates and returns the location of a glyph. (Deprecated in 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
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

positionOfGlyph:struckOverGlyph:metricsExist:

Calculates and returns a suitable location for the given glyph to be drawn. (Deprecated in 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
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

positionOfGlyph:struckOverRect:metricsExist:

Overridden by subclasses to calculate and return a suitable location for a glyph to be drawn. (Deprecated in 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
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

positionOfGlyph:withRelation:toBaseGlyph:totalAdvancement:metricsExist:

Calculates and returns a suitable location for a glyph to be drawn. (Deprecated in 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
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

positionsForCompositeSequence:numberOfGlyphs:pointArray:

Calculates glyph locations. (Deprecated in 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
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h

widthOfString:

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 OS X v10.4. Use the Application Kit string-drawing methods, as described in NSString Additions.)

- (CGFloat)widthOfString:(NSString *)aString
Discussion

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.

Availability
  • Available in OS X v10.0 and later.
  • Deprecated in OS X v10.4.
  • Not available to 64-bit applications.
Declared In
NSFont.h