Contents

monospacedSystemFont(ofSize:weight:)

Returns a monospace version of the system font with the specified size and weight.

Declaration

class func monospacedSystemFont(ofSize fontSize: CGFloat, weight: NSFont.Weight) -> NSFont

Parameters

  • fontSize:

    The desired font size specified in points. If you specify 0.0 or a negative number for this parameter, the method returns the system font at the default size.

  • weight:

    The desired weight of font lines, specified as one of the constants in Weight.

Return Value

A font object containing a monospace version of the system font at the specified size and weight.

Discussion

Use the returned font for interface items that require monospaced glyphs. The returned font includes monospaced glyphs for the Latin characters and the symbols commonly found in source code. Glyphs for other symbols are usually wider or narrower than the monospaced characters. To ensure the font uses fixed spacing for all characters, apply the fixedAdvance attribute to the any strings you render.

See Also

Creating System Fonts