Link Search Menu Expand Document

Font

Represents a font.

public class Font 

Initializers

init?(name:size:)

Creates an returns a font object for the specified font name and size.

public init?(name: String, size: Double) 

Properties

familyNames

Returns an array of font family names available on the system.

public static var familyNames: [String] 

fontName

The font face name.

public var fontName: String 

pointSize

The font’s point size, or the effective vertical point size for a font with a non-standard matrix.

public var pointSize: Double 

ascender

The top y-coordinate, offset from the baseline, of the font’s longest ascender.

public var ascender: Double 

descender

The bottom y-coordinate, offset from the baseline, of the font’s longest descender.

public var descender: Double 

leading

The font’s leading information.

public var leading: Double 

capHeight

The font’s cap height information.

public var capHeight: Double 

xHeight

The x-height of the font.

public var xHeight: Double 

labelFontSize

The height, in points, of text lines. The standard font size, in points, for labels.

public static var labelFontSize: Double 

buttonFontSize

The standard font size, in points, for buttons.

public static var buttonFontSize: Double 

smallSystemFontSize

The size, in points, of the standard small system font.

public static var smallSystemFontSize: Double 

systemFontSize

The size, in points, of the standard system font.

public static var systemFontSize: Double 

Methods

preferredFont(forTextStyle:)

Returns an instance of the system font for the specified text style with scaling for the user’s selected content size category.

public static func preferredFont(forTextStyle style: Font.TextStyle) -> Font 

preferredFont(forTextStyle:compatibleWith:)

Returns an instance of the system font for the appropriate text style and traits.

public static func preferredFont(forTextStyle style: Font.TextStyle,
                                   compatibleWith traits: TraitCollection?)
      -> Font 

withSize(_:)

public func withSize(_ fontSize: Double) -> Font 

systemFont(ofSize:)

Returns the font object for standard interface items in the specified size.

public static func systemFont(ofSize fontSize: Double) -> Font 

systemFont(ofSize:weight:)

Returns the font object for standard interface items in the specifed size and weight.

public static func systemFont(ofSize fontSize: Double, weight: Font.Weight)
      -> Font 

boldSystemFont(ofSize:)

Returns the font object for standard interface items in boldface type in the specified size.

public static func boldSystemFont(ofSize fontSize: Double) -> Font 

italicSystemFont(ofSize:)

Returns the font object for standard interface items in italic type in the specified size.

public static func italicSystemFont(ofSize fontSize: Double) -> Font 

monospacedSystemFont(ofSize:weight:)

Returns the fixed-width font for standard interface text in the specified size.

public static func monospacedSystemFont(ofSize fontSize: Double,
                                          weight: Font.Weight) -> Font 

monospacedDigitSystemFont(ofSize:weight:)

Returns the standard system font with all digits of consistent width.

public static func monospacedDigitSystemFont(ofSize fontSize: Double,
                                               weight: Font.Weight) -> Font 

fontNames(forFontFamily:)

Returns an array of font names available in a particular font family.

public static func fontNames(forFontFamily family: String) -> [String]