NSFont

NSFont Mac OS X 10.0

This class represents a single font in an application. NSAttributedString uses NSFont as an attribute that specifies which font a string should be drawn in. NSFont provides access to all of the characteristics of a font, such as the ascender and descender height, italic angle, underline thickness, and more.

figs/cocn_1532.gif

@interface NSFont : NSObject <NSCoding, NSCopying>
 // Convenience Constructors
   + (NSFont *)fontWithName:(NSString *)fontName matrix:(const float *)fontMatrix;
   + (NSFont *)fontWithName:(NSString *)fontName size:(float)fontSize;
 // Class Methods
   + (float)labelFontSize;
   + (float)smallSystemFontSize;
   + (float)systemFontSize;
   + (NSFont *)boldSystemFontOfSize:(float)fontSize;
   + (NSFont *)controlContentFontOfSize:(float)fontSize;
   + (NSFont *)labelFontOfSize:(float)fontSize;
   + (NSFont *)menuFontOfSize:(float)fontSize;
   + (NSFont *)messageFontOfSize:(float)fontSize;
   + (NSFont *)paletteFontOfSize:(float)fontSize;
   + (NSArray *)preferredFontNames;
   + (void)setPreferredFontNames:(NSArray *)fontNameArray;
   + (void)setUserFixedPitchFont:(NSFont *)aFont;
   + (void)setUserFont:(NSFont *)aFont;
   + (NSFont *)systemFontOfSize:(float)fontSize;
   + (NSFont *)titleBarFontOfSize:(float)fontSize;
   + (NSFont *)toolTipsFontOfSize:(float)fontSize;
   + (void)useFont:(NSString *)fontName;
   + (NSFont *)userFixedPitchFontOfSize:(float)fontSize;
   + (NSFont *)userFontOfSize:(float)fontSize;
 // Instance Methods
   - (void)set;
   - (float)ascender;
   - (float)capHeight;
   - (float)defaultLineHeightForFont;
   - (float)descender;
   - (NSString *)encodingScheme;
   - (NSMultibyteGlyphPacking)glyphPacking;
   - (NSGlyph)glyphWithName:(NSString *)aName;
   - (BOOL)isFixedPitch;
   - (float)italicAngle;
   - (NSSize)maximumAdvancement;
   - (NSStringEncoding)mostCompatibleStringEncoding;
   - (unsigned)numberOfGlyphs;
   - (int)positionsForCompositeSequence:(NSGlyph *)someGlyphs numberOfGlyphs:(int)numGlyphs
        pointArray:(NSPointArray)points;
   - (float)underlinePosition;
   - (float)underlineThickness;
   - (float)xHeight;
   - (NSSize)advancementForGlyph:(NSGlyph)ag;
   - (NSDictionary *)afmDictionary;
   - (NSRect)boundingRectForFont;
   - (NSRect)boundingRectForGlyph:(NSGlyph)aGlyph;
   - (NSCharacterSet *)coveredCharacterSet;
   - (NSString *)displayName;
   - (NSString *)familyName;
   - (NSString *)fontName;
   - (BOOL)glyphIsEncoded:(NSGlyph)aGlyph;
   - (BOOL)isBaseFont;
   - (const float *)matrix;
   - (float)pointSize;
   - (NSPoint)positionOfGlyph:(NSGlyph)aGlyph forCharacter:(unichar)aChar struckOverRect:(NSRect)aRect;
   - (NSPoint)positionOfGlyph:(NSGlyph)aGlyph struckOverRect:(NSRect)aRect metricsExist:(BOOL *)exist;
   - (NSPoint)positionOfGlyph:(NSGlyph)curGlyph precededByGlyph:(NSGlyph)prevGlyph isNominal:(BOOL *)nominal;
   - (NSPoint)positionOfGlyph:(NSGlyph)curGlyph  struckOverGlyph:(NSGlyph)prevGlyph metricsExist:(BOOL *)exist;
   - (NSPoint)positionOfGlyph:(NSGlyph)thisGlyph withRelation:(NSGlyphRelation)rel toBaseGlyph:(NSGlyph)baseGlyph
        totalAdvancement:(NSSizePointer)adv metricsExist:(BOOL *)exist;
   - (NSFont *)printerFont;
   - (NSFont *)screenFont;
   - (float)widthOfString:(NSString *)string;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
 // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes