Up

# NSFont

### Authors

Ovidiu Predescu (`ovidiu@net-community.com`)

> The font class

Copyright: (C) 1996 Free Software Foundation, Inc.

### Contents -

1. NSFont
2. Software documentation for the NSFont(GNUstep) category

# NSFont

The NSFont class allows control of the fonts used for displaying text anywhere on the screen. The primary methods for getting a particular font are +fontWithName:matrix: and +fontWithName:size: which take the name and size of a particular font and return the NSFont object associated with that font. In addition there are several convenience mathods which make it easier to get certain types of fonts.

In particular, there are several methods to get the standard fonts used by the Application to display text for a partiuclar purpose. See the class methods listed below for more information. These default fonts can be set using the user defaults system. The default font names available are:

- NSBoldFont Helvetica-Bold (System bold font)
- NSControlContentFont System font
- NSFont Helvetica (System Font)
- NSLabelFont System font
- NSMenuFont System font
- NSMenuBarFont System font
- NSMessageFont System font
- NSPaletteFont System bold font
- NSTitleBarFont System bold font
- NSToolTipsFont System font
- NSUserFixedPitchFont Courier
- NSUserFont System font

The default sizes are:

- NSBoldFontSize (none)
- NSControlContentFontSize (none)
- NSFontSize 12 (System Font Size)
- NSLabelFontSize (none)
- NSMenuFontSize (none)
- NSMiniFontSize 6
- NSMessageFontSize (none)
- NSPaletteFontSize (none)
- NSSmallFontSize 9
- NSTitleBarFontSize (none)
- NSToolTipsFontSize (none)
- NSUserFixedPitchFontSize (none)
- NSUserFontSize (none)

Font sizes list with (none) default to NSFontSize.

## NSFont : NSObject

> Declared in:
>   AppKit/NSFont.h

> Conforms to:
>   NSCoding
>   NSCopying

Availability: OpenStep
Description forthcoming.

Instance Variables
Method summary

- -fontInfo
- -fontRef
- +boldSystemFontOfSize:
- +controlContentFontOfSize:
- +fontWithDescriptor:size:
- +fontWithDescriptor:size:textTransform:
- +fontWithDescriptor:textTransform:
- +fontWithName:matrix:
- +fontWithName:size:
- +labelFontOfSize:
- +labelFontSize
- +menuBarFontOfSize:
- +menuFontOfSize:
- +messageFontOfSize:
- +paletteFontOfSize:
- +preferredFontNames
- +setPreferredFontNames:
- +setUserFixedPitchFont:
- +setUserFont:
- +smallSystemFontSize
- +systemFontOfSize:
- +systemFontSize
- +systemFontSizeForControlSize:
- +titleBarFontOfSize:
- +toolTipsFontOfSize:
- +useFont:
- +userFixedPitchFontOfSize:
- +userFontOfSize:
- -advancementForGlyph:
- -afmDictionary
- -afmFileContents
- -ascender
- -boundingRectForFont
- -boundingRectForGlyph:
- -capHeight
- -coveredCharacterSet
- -defaultLineHeightForFont
- -descender
- -displayName
- -encodingScheme
- -familyName
- -fontDescriptor
- -fontName
- -glyphIsEncoded:
- -glyphPacking
- -glyphWithName:
- -isBaseFont
- -isFixedPitch
- -italicAngle
- -matrix
- -maximumAdvancement
- -minimumAdvancement
- -mostCompatibleStringEncoding
- -numberOfGlyphs
- -pointSize
- -positionOfGlyph:forCharacter:struckOverRect:
- -positionOfGlyph:precededByGlyph:isNominal:
- -positionOfGlyph:struckOverGlyph:metricsExist:
- -positionOfGlyph:struckOverRect:metricsExist:
- -positionOfGlyph:withRelation:toBaseGlyph:totalAdvancement:metricsExist:
- -positionsForCompositeSequence:numberOfGlyphs:pointArray:
- -printerFont
- -renderingMode
- -screenFont
- -screenFontWithRenderingMode:
- -set
- -setInContext:
- -textTransform
- -underlinePosition
- -underlineThickness
- -widthOfString:
- -xHeight

### boldSystemFontOfSize:

+ (NSFont*) boldSystemFontOfSize: (float)fontSize;
Availability: OpenStep

Returns the default bold font for use in menus and heading in standard gui components. If fontSize is <= 0, the default size is used.

See Also: +fontWithName:size:

### controlContentFontOfSize:

+ (NSFont*) controlContentFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### fontWithDescriptor: size:

+ (NSFont*) fontWithDescriptor: (NSFontDescriptor*)descriptor size: (CGFloat)size;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### fontWithDescriptor: size: textTransform:

+ (NSFont*) fontWithDescriptor: (NSFontDescriptor*)descriptor size: (CGFloat)size textTransform: (NSAffineTransform*)transform;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### fontWithDescriptor: textTransform:

+ (NSFont*) fontWithDescriptor: (NSFontDescriptor*)descriptor textTransform: (NSAffineTransform*)transform;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### fontWithName: matrix:

+ (NSFont*) fontWithName: (NSString*)aFontName matrix: (const float*)fontMatrix;
Availability: OpenStep

Returns an autoreleased font with name aFontName and matrix fontMatrix.

The fontMatrix is a standard size element matrix as used in PostScript to describe the scaling of the font, typically it just includes the font size as [fontSize 0 0 fontSize 0 0]. You can use the constant NSFontIdentityMatrix in place of [1 0 0 1 0 0]. If NSFontIdentityMatrix, then the font will automatically flip itself when set in a flipped view.

### fontWithName: size:

+ (NSFont*) fontWithName: (NSString*)aFontName size: (float)fontSize;
Availability: OpenStep

Returns an autoreleased font with name aFontName and size fontSize.

Fonts created using this method will automatically flip themselves when set in a flipped view.

### labelFontOfSize:

+ (NSFont*) labelFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### labelFontSize

+ (float) labelFontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### menuBarFontOfSize:

+ (NSFont*) menuBarFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### menuFontOfSize:

+ (NSFont*) menuFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### messageFontOfSize:

+ (NSFont*) messageFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### paletteFontOfSize:

+ (NSFont*) paletteFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### preferredFontNames

+ (NSArray*) preferredFontNames;
Availability: OpenStep

Returns an array of the names of preferred fonts.

See Also: +setPreferredFontNames:

### setPreferredFontNames:

+ (void) setPreferredFontNames: (NSArray*)fontNames;
Availability: OpenStep

Sets an array of the names of preferred fonts to fontsNames/

See Also: +preferredFontNames

### setUserFixedPitchFont:

+ (void) setUserFixedPitchFont: (NSFont*)aFont;
Availability: OpenStep
Description forthcoming.

### setUserFont:

+ (void) setUserFont: (NSFont*)aFont;
Availability: OpenStep
Description forthcoming.

### smallSystemFontSize

+ (float) smallSystemFontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### systemFontOfSize:

+ (NSFont*) systemFontOfSize: (float)fontSize;
Availability: OpenStep

Returns the default font for use in menus and heading in standard gui components. If fontSize is <= 0, the default size is used.

See Also: +boldSystemFontOfSize: userFontOfSize: userFixedPitchFontOfSize: +fontWithName:size:

### systemFontSize

+ (float) systemFontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### systemFontSizeForControlSize:

+ (float) systemFontSizeForControlSize: (NSControlSize)controlSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### titleBarFontOfSize:

+ (NSFont*) titleBarFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### toolTipsFontOfSize:

+ (NSFont*) toolTipsFontOfSize: (float)fontSize;
Availability: MacOS-X 10.0.0
Description forthcoming.

### useFont:

+ (void) useFont: (NSString*)aFontName;
Availability: OpenStep
Description forthcoming.

### userFixedPitchFontOfSize:

+ (NSFont*) userFixedPitchFontOfSize: (float)fontSize;
Availability: OpenStep

Returns the default fixed pitch font for use in locations other than standard gui components. If fontSize is <= 0, the default size is used.

See Also: +setUserFixedPitchFont: +userFontOfSize: +boldSystemFontOfSize: +systemFontOfSize: +fontWithName:size:

### userFontOfSize:

+ (NSFont*) userFontOfSize: (float)fontSize;
Availability: OpenStep

Returns the default font for use in locations other than standard gui components. If fontSize is <= 0, the default size is used.

See Also: +setUserFont: +boldSystemFontOfSize: systemFontOfSize: userFixedPitchFontOfSize: +fontWithName:size:

### advancementForGlyph:

- (NSSize) advancementForGlyph: (NSGlyph)aGlyph;
Availability: OpenStep
Description forthcoming.

### afmDictionary

- (NSDictionary*) afmDictionary;
Availability: OpenStep
Description forthcoming.

### afmFileContents

- (NSString*) afmFileContents;
Availability: OpenStep

This method returns `nil` in the GNUstep implementation

### ascender

- (float) ascender;
Availability: OpenStep
Description forthcoming.

### boundingRectForFont

- (NSRect) boundingRectForFont;
Availability: OpenStep
Description forthcoming.

### boundingRectForGlyph:

- (NSRect) boundingRectForGlyph: (NSGlyph)aGlyph;
Availability: OpenStep
Description forthcoming.

### capHeight

- (float) capHeight;
Availability: OpenStep
Description forthcoming.

### coveredCharacterSet

- (NSCharacterSet*) coveredCharacterSet;
Availability: MacOS-X 10.0.0
Description forthcoming.

### defaultLineHeightForFont

- (float) defaultLineHeightForFont;
Availability: OpenStep
Description forthcoming.

### descender

- (float) descender;
Availability: OpenStep
Description forthcoming.

### displayName

- (NSString*) displayName;
Availability: OpenStep
Description forthcoming.

### encodingScheme

- (NSString*) encodingScheme;
Availability: OpenStep
Description forthcoming.

### familyName

- (NSString*) familyName;
Availability: OpenStep
Description forthcoming.

### fontDescriptor

- (NSFontDescriptor*) fontDescriptor;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### fontName

- (NSString*) fontName;
Availability: OpenStep
Description forthcoming.

### glyphIsEncoded:

- (BOOL) glyphIsEncoded: (NSGlyph)aGlyph;
Availability: OpenStep
Description forthcoming.

### glyphPacking

- (NSMultibyteGlyphPacking) glyphPacking;
Availability: OpenStep
Description forthcoming.

### glyphWithName:

- (NSGlyph) glyphWithName: (NSString*)glyphName;
Availability: OpenStep
Description forthcoming.

### isBaseFont

- (BOOL) isBaseFont;
Availability: OpenStep
Description forthcoming.

### isFixedPitch

- (BOOL) isFixedPitch;
Availability: OpenStep
Description forthcoming.

### italicAngle

- (float) italicAngle;
Availability: OpenStep
Description forthcoming.

### matrix

- (const float*) matrix;
Availability: OpenStep
Description forthcoming.

### maximumAdvancement

- (NSSize) maximumAdvancement;
Availability: OpenStep
Description forthcoming.

### minimumAdvancement

- (NSSize) minimumAdvancement;
Availability: OpenStep
Description forthcoming.

### mostCompatibleStringEncoding

- (NSStringEncoding) mostCompatibleStringEncoding;
Availability: OpenStep
Description forthcoming.

### numberOfGlyphs

- (unsigned) numberOfGlyphs;
Availability: MacOS-X 10.0.0
Description forthcoming.

### pointSize

- (float) pointSize;
Availability: OpenStep
Description forthcoming.

### positionOfGlyph: forCharacter: struckOverRect:

- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph forCharacter: (unichar)aChar struckOverRect: (NSRect)aRect;
Availability: OpenStep
Description forthcoming.

### positionOfGlyph: precededByGlyph: isNominal:

- (NSPoint) positionOfGlyph: (NSGlyph)curGlyph precededByGlyph: (NSGlyph)prevGlyph isNominal: (BOOL*)nominal;
Availability: OpenStep
Description forthcoming.

### positionOfGlyph: struckOverGlyph: metricsExist:

- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph struckOverGlyph: (NSGlyph)baseGlyph metricsExist: (BOOL*)flag;
Availability: OpenStep
Description forthcoming.

### positionOfGlyph: struckOverRect: metricsExist:

- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph struckOverRect: (NSRect)aRect metricsExist: (BOOL*)flag;
Availability: OpenStep
Description forthcoming.

### positionOfGlyph: withRelation: toBaseGlyph: totalAdvancement: metricsExist:

- (NSPoint) positionOfGlyph: (NSGlyph)aGlyph withRelation: (NSGlyphRelation)relation toBaseGlyph: (NSGlyph)baseGlyph totalAdvancement: (NSSize*)offset metricsExist: (BOOL*)flag;
Availability: OpenStep
Description forthcoming.

### positionsForCompositeSequence: numberOfGlyphs: pointArray:

- (int) positionsForCompositeSequence: (NSGlyph*)glyphs numberOfGlyphs: (int)numGlyphs pointArray: (NSPoint*)points;
Availability: OpenStep
Description forthcoming.

### printerFont

- (NSFont*) printerFont;
Availability: OpenStep
Description forthcoming.

### renderingMode

- (NSFontRenderingMode) renderingMode;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### screenFont

- (NSFont*) screenFont;
Availability: OpenStep
Description forthcoming.

### screenFontWithRenderingMode:

- (NSFont*) screenFontWithRenderingMode: (NSFontRenderingMode)mode;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### set

- (void) set;
Availability: OpenStep
Sets the receiver as the font used for text drawing operations. If the current view is a flipped view, the reciever automatically flips itself to display correctly in the flipped view, as long as the font was created without explicitly setting the font matrix

### setInContext:

- (void) setInContext: (NSGraphicsContext*)ctxt;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### textTransform

- (NSAffineTransform*) textTransform;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### underlinePosition

- (float) underlinePosition;
Availability: OpenStep
Description forthcoming.

### underlineThickness

- (float) underlineThickness;
Availability: OpenStep
Description forthcoming.

### widthOfString:

- (float) widthOfString: (NSString*)string;
Availability: OpenStep
Description forthcoming.

### xHeight

- (float) xHeight;
Availability: OpenStep
Description forthcoming.

## Instance Variables for NSFont Class

### _fontRef

@protected void* _fontRef;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### cachedFlippedFont

@protected NSFont* cachedFlippedFont;
Availability: OpenStep
Description forthcoming.

### cachedScreenFont

@protected NSFont* cachedScreenFont;
Availability: OpenStep
Description forthcoming.

### fontInfo

@protected id fontInfo;
Availability: OpenStep
Description forthcoming.

### fontName

@protected NSString* fontName;
Availability: OpenStep
Description forthcoming.

### matrix

@protected float matrix;
Availability: OpenStep
Description forthcoming.

### matrixExplicitlySet

@protected BOOL matrixExplicitlySet;
Availability: OpenStep
Description forthcoming.

### role

@protected int role;
Availability: OpenStep
Description forthcoming.

### screenFont

@protected BOOL screenFont;
Availability: OpenStep
Description forthcoming.

# Software documentation for the NSFont(GNUstep) category

## NSFont(GNUstep)

> Declared in:
>   AppKit/NSFont.h

Availability: MacOS-X 10.0.0
Description forthcoming.
Method summary

- -fontInfo
- -fontRef

### fontInfo

- (GSFontInfo*) fontInfo;
Availability: MacOS-X 10.0.0
Description forthcoming.

### fontRef

- (void*) fontRef;
Availability: MacOS-X 10.0.0
Description forthcoming.

Up