Typeface

public class Typeface

The Typeface class specifies the typeface and intrinsic style of a font. This is used in the renderer, along with optionally Renderer settings like typeSize, slantAngle, scaleX, to specify how text appears when drawn (and measured).

  • Creates a typeface from the specified file. The data for the font is directly read from the file when needed.

    Declaration

    Swift

    public init?(path: String)

    Parameters

    path

    The path of the font file.

  • Creates a new typeface from the data of the font.

    Declaration

    Swift

    public init?(data: Data)

    Parameters

    data

    The data of the font.

  • Creates a new typeface from the input stream by copying its data into a memory buffer. It may take some time to create the typeface if the stream holds larger data.

    Declaration

    Swift

    public init?(stream: InputStream)

    Parameters

    stream

    The input stream that contains the data of the font.

  • A Boolean value that indicates whether the typeface supports OpenType font variations.

    Declaration

    Swift

    public var isVariable: Bool { get }
  • Returns a variation instance of this typeface with the specified design coordinates.

    Declaration

    Swift

    public func variationInstance(forCoordinates coordinates: [CGFloat]) -> Typeface?

    Parameters

    coordinates

    The variation design coordinates.

    Return Value

    A variation instance of this typeface with the specified design coordinates.

  • The variation axes of this typeface.

    Declaration

    Swift

    public var variationAxes: [VariationAxis] { get }
  • The named instance records of this typeface.

    Declaration

    Swift

    public var namedStyles: [NamedStyle] { get }
  • The design variation coordinates of this typeface.

    Declaration

    Swift

    public var variationCoordinates: [CGFloat] { get }
  • The names associated with palette entries if this typeface supports OpenType color palettes.

    Declaration

    Swift

    public var paletteEntryNames: [String] { get }
  • The predefined palettes in this typeface if it supports OpenType color palettes.

    Declaration

    Swift

    public var predefinedPalettes: [ColorPalette] { get }
  • The colors associated with this typeface if it supports OpenType color palettes.

    Declaration

    Swift

    public var associatedColors: [UIColor] { get }
  • Returns a color instance of this typeface with the specified colors array.

    Declaration

    Swift

    public func colorInstance(forColors colors: [UIColor]) -> Typeface?

    Parameters

    colors

    The colors array.

    Return Value

    A color instance of this typeface with the specified colors array.

  • The family name of this typeface.

    Declaration

    Swift

    public var familyName: String { get }
  • The style name of this typeface.

    Declaration

    Swift

    public var styleName: String { get }
  • The full name of this typeface.

    Declaration

    Swift

    public var fullName: String { get }
  • The typographic weight of this typeface. The weight value determines the thickness associated with a given character in a typeface.

    Declaration

    Swift

    public var weight: Weight { get }
  • The typographic width of this typeface. The width value determines whether a typeface is expanded or condensed when it is displayed.

    Declaration

    Swift

    public var width: Width { get }
  • The typographic slope of this typeface. The slope value determines whether a typeface is plain or slanted when it is displayed.

    Declaration

    Swift

    public var slope: Slope { get }
  • The number of font units per EM square for this typeface.

    Declaration

    Swift

    public var unitsPerEm: Int { get }
  • The typographic ascender of this typeface expressed in font units.

    Declaration

    Swift

    public var ascent: Int { get }
  • The typographic descender of this typeface expressed in font units.

    Declaration

    Swift

    public var descent: Int { get }
  • The typographic leading of this typeface expressed in font units.

    Declaration

    Swift

    public var leading: Int { get }
  • The number of glyphs in this typeface.

    Declaration

    Swift

    public var glyphCount: Int { get }
  • The font bounding box expressed in font units. The box is large enough to contain any glyph from the font.

    Declaration

    Swift

    public var boundingBox: CGRect { get }
  • The position, in font units, of the underline for this typeface.

    Declaration

    Swift

    public var underlinePosition: Int { get }
  • The thickness, in font units, of the underline for this typeface.

    Declaration

    Swift

    public var underlineThickness: Int { get }
  • The position, in font units, of the strikeout for this typeface.

    Declaration

    Swift

    public var strikeoutPosition: Int { get }
  • The thickness, in font units, of the strikeout for this typeface.

    Declaration

    Swift

    public var strikeoutThickness: Int { get }
  • Returns the data of the table specified by the tag.

    Declaration

    Swift

    public func dataOfTable(_ tag: SFNTTag) -> Data?

    Parameters

    tag

    The tag of the table.

    Return Value

    The data of the intended table, or nil if no such table exists.

  • Returns the glyph id for the specified code point.

    Declaration

    Swift

    public func glyphID(forCodePoint codePoint: UTF32Char) -> GlyphID

    Parameters

    codePoint

    The code point for which the glyph id is obtained.

    Return Value

    The glyph id for the specified code point.

  • Retrieves the advance for the specified glyph.

    Declaration

    Swift

    public func advance(forGlyph glyphID: GlyphID, typeSize: CGFloat, vertical: Bool) -> CGFloat

    Parameters

    glyphID

    The glyph id for which to retrieve the advance.

    typeSize

    The size for which the advance is retrieved.

    vertical

    The flag which indicates the type of advance, either horizontal or vertical.

    Return Value

    The advance for the specified glyph.

  • Generates the path for the specified glyph.

    Declaration

    Swift

    public func path(forGlyph glyphID: GlyphID, typeSize: CGFloat, transform: CGAffineTransform?) -> CGPath?

    Parameters

    glyphID

    The glyph id for which the path is generated.

    typeSize

    The size for which the glyph path is required.

    transform

    The transform applied to the path. Can be nil if no transformation is required.

    Return Value

    The path for the specified glyph.

  • Specifies the slope of a typeface.

    See more

    Declaration

    Swift

    public enum Slope : Int
  • Specifies the thickness of a typeface, in terms of lightness or heaviness of the strokes.

    See more

    Declaration

    Swift

    public enum Weight : Int
  • Specifies the wideness of a typeface, in terms of the width of characters in relation to their heights.

    See more

    Declaration

    Swift

    public enum Width : Int