Font

public class Font: NSObject

Font objects represent fonts to an application, providing access to characteristics of the font and assistance in laying out glyphs relative to one another.

  • The UIFont representation of the receiver. let uif = font.UIFont

    Declaration

    Swift

    public var uiifont: UIFont
  • Initializes a new Font using the specified font name and size. let f = Font("Helvetica", 20) - parameter name: The name of the font. - parameter size: The point-size of the font.

    Declaration

    Swift

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

    Parameters

    name

    The name of the font.

    size

    The point-size of the font.

  • Initializes a new Font using the specified font name and default size of 12.0 pt. let f = Font("Helvetica") - parameter name: The name of the font

    Declaration

    Swift

    public convenience init?(name: String)

    Parameters

    name

    The name of the font

  • Initializes a new Font using a specified UIFont. if let uif = UIFont(name: "Helvetica", size: 24) { let f = Font(font: uif) } - parameter font: A UIFont

    Declaration

    Swift

    public init(font: UIFont)

    Parameters

    font

    A UIFont

  • Returns an array of font family names available on the system. - returns: An array of String objects, each of which contains the name of a font family.

    Declaration

    Swift

    public class func familyNames() -> [AnyObject]

    Return Value

    An array of String objects, each of which contains the name of a font family.

  • Returns an array of font names available in a particular font family. for n in Font.fontNames("Avenir Next") { println(n) } - parameter familyName: The name of the font family. - returns: An array of String objects, each of which contains a font name associated with the specified family.

    Declaration

    Swift

    public class func fontNames(familyName: String) -> [AnyObject]

    Parameters

    familyName

    The name of the font family.

    Return Value

    An array of String objects, each of which contains a font name associated with the specified family.

  • Returns the font object used for standard interface items in the specified size. let f = Font.systemFont(20) - parameter size: The size (in points) to which the font is scaled. - returns: A font object of the specified size.

    Declaration

    Swift

    public class func systemFont(size: Double) -> Font

    Parameters

    size

    The size (in points) to which the font is scaled.

    Return Value

    A font object of the specified size.

  • Returns the font object used for standard interface items that are rendered in boldface type in the specified size. let f = Font.boldSystemFont(20) - parameter size: The size (in points) to which the font is scaled. - returns: A font object of the specified size.

    Declaration

    Swift

    public class func boldSystemFont(size: Double) -> Font

    Parameters

    size

    The size (in points) to which the font is scaled.

    Return Value

    A font object of the specified size.

  • Returns the font object used for standard interface items that are rendered in italic type in the specified size. let f = Font.italicSystemFont(20) - parameter size: The size (in points) to which the font is scaled. - returns: A font object of the specified size.

    Declaration

    Swift

    public class func italicSystemFont(size: Double) -> Font

    Parameters

    size

    The size (in points) to which the font is scaled.

    Return Value

    A font object of the specified size.

  • Returns a font object that is the same as the receiver but which has the specified size instead. let f = Font(name: "Avenir Next") let f2 = f.font(20) - parameter size: The desired size (in points) of the new font object. - returns: A font object of the specified size.

    Declaration

    Swift

    public func font(size: Double) -> Font

    Parameters

    size

    The desired size (in points) of the new font object.

    Return Value

    A font object of the specified size.

  • The font family name. (read-only) A family name is a name such as Times New Roman that identifies one or more specific fonts. The value in this property is intended for an application’s internal usage only and should not be displayed.

    Declaration

    Swift

    public var familyName: String
  • The font face name. (read-only) The font name is a name such as HelveticaBold that incorporates the family name and any specific style information for the font. The value in this property is intended for an application’s internal usage only and should not be displayed. let f = Font(name: "Avenir Next") let n = f.fontName

    Declaration

    Swift

    public var fontName: String
  • The receiver’s point size, or the effective vertical point size for a font with a nonstandard matrix. (read-only) Defaults to 12.0

    Declaration

    Swift

    public var pointSize: Double
  • The top y-coordinate, offset from the baseline, of the receiver’s longest ascender. (read-only) The ascender value is measured in points.

    Declaration

    Swift

    public var ascender: Double
  • The bottom y-coordinate, offset from the baseline, of the receiver’s longest descender. (read-only) The descender value is measured in points. This value may be positive or negative. For example, if the longest descender extends 2 points below the baseline, this method returns -2.0 .

    Declaration

    Swift

    public var descender: Double
  • The receiver’s cap height information. (read-only) This value measures (in points) the height of a capital character.

    Declaration

    Swift

    public var capHeight: Double
  • The x-height of the receiver. (read-only) This value measures (in points) the height of the lowercase character x.

    Declaration

    Swift

    public var xHeight: Double
  • The height of text lines (measured in points). (read-only)

    Declaration

    Swift

    public var lineHeight: Double
  • Returns the standard font size used for labels. - returns: The standard label font size in points.

    Declaration

    Swift

    public var labelFontSize: Double

    Return Value

    The standard label font size in points.

  • Returns the standard font size used for buttons. - returns: The standard button font size in points.

    Declaration

    Swift

    public var buttonFontSize: Double

    Return Value

    The standard button font size in points.

  • Returns the size of the standard system font. - returns: The standard system font size in points.

    Declaration

    Swift

    public var systemFontSize: Double

    Return Value

    The standard system font size in points.

  • Returns the size of the standard small system font. - returns: The standard small system font size in points.

    Declaration

    Swift

    public var smallSystemFontSize: Double

    Return Value

    The standard small system font size in points.

  • Returns a CGFontRef version of the receiver.

    Declaration

    Swift

    public var CGFont: CGFontRef?
  • Returns a CTFontRef version of the receiver.

    Declaration

    Swift

    public var CTFont: CTFontRef