FontMetricsProtocol

public protocol FontMetricsProtocol

A PangoFontMetrics structure holds the overall metric information for a font.

The information in a PangoFontMetrics structure may be restricted to a script. The fields of this structure are private to implementations of a font backend. See the documentation of the corresponding getters for documentation of their meaning.

For an overview of the most important metrics, see:

<picture> <source srcset=“fontmetrics-dark.png” media=“(prefers-color-scheme: dark)”> <img alt=“Font metrics” src=“fontmetrics-light.png”> </picture>

The FontMetricsProtocol protocol exposes the methods and properties of an underlying PangoFontMetrics instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see FontMetrics. Alternatively, use FontMetricsRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying PangoFontMetrics instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • font_metrics_ptr Default implementation

    Typed pointer to the underlying PangoFontMetrics instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the PangoFontMetrics instance.

    Declaration

    Swift

    var font_metrics_ptr: UnsafeMutablePointer<PangoFontMetrics>! { get }
  • Required Initialiser for types conforming to FontMetricsProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

FontMetrics Record: FontMetricsProtocol extension (methods and fields)

  • getApproximateCharWidth() Extension method

    Gets the approximate character width for a font metrics structure.

    This is merely a representative value useful, for example, for determining the initial size for a window. Actual characters in text will be wider and narrower than this.

    Declaration

    Swift

    @inlinable
    func getApproximateCharWidth() -> Int
  • getApproximateDigitWidth() Extension method

    Gets the approximate digit width for a font metrics structure.

    This is merely a representative value useful, for example, for determining the initial size for a window. Actual digits in text can be wider or narrower than this, though this value is generally somewhat more accurate than the result of pango_font_metrics_get_approximate_char_width() for digits.

    Declaration

    Swift

    @inlinable
    func getApproximateDigitWidth() -> Int
  • getAscent() Extension method

    Gets the ascent from a font metrics structure.

    The ascent is the distance from the baseline to the logical top of a line of text. (The logical top may be above or below the top of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.)

    Declaration

    Swift

    @inlinable
    func getAscent() -> Int
  • getDescent() Extension method

    Gets the descent from a font metrics structure.

    The descent is the distance from the baseline to the logical bottom of a line of text. (The logical bottom may be above or below the bottom of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.)

    Declaration

    Swift

    @inlinable
    func getDescent() -> Int
  • getHeight() Extension method

    Gets the line height from a font metrics structure.

    The line height is the recommended distance between successive baselines in wrapped text using this font.

    If the line height is not available, 0 is returned.

    Declaration

    Swift

    @inlinable
    func getHeight() -> Int
  • getStrikethroughPosition() Extension method

    Gets the suggested position to draw the strikethrough.

    The value returned is the distance above the baseline of the top of the strikethrough.

    Declaration

    Swift

    @inlinable
    func getStrikethroughPosition() -> Int
  • getStrikethroughThickness() Extension method

    Gets the suggested thickness to draw for the strikethrough.

    Declaration

    Swift

    @inlinable
    func getStrikethroughThickness() -> Int
  • getUnderlinePosition() Extension method

    Gets the suggested position to draw the underline.

    The value returned is the distance above the baseline of the top of the underline. Since most fonts have underline positions beneath the baseline, this value is typically negative.

    Declaration

    Swift

    @inlinable
    func getUnderlinePosition() -> Int
  • getUnderlineThickness() Extension method

    Gets the suggested thickness to draw for the underline.

    Declaration

    Swift

    @inlinable
    func getUnderlineThickness() -> Int
  • ref() Extension method

    Increase the reference count of a font metrics structure by one.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func ref() -> Pango.FontMetricsRef!
  • unref() Extension method

    Decrease the reference count of a font metrics structure by one.

    If the result is zero, frees the structure and any associated memory.

    Declaration

    Swift

    @inlinable
    func unref()
  • approximateCharWidth Extension method

    Gets the approximate character width for a font metrics structure.

    This is merely a representative value useful, for example, for determining the initial size for a window. Actual characters in text will be wider and narrower than this.

    Declaration

    Swift

    @inlinable
    var approximateCharWidth: Int { get }
  • approximateDigitWidth Extension method

    Gets the approximate digit width for a font metrics structure.

    This is merely a representative value useful, for example, for determining the initial size for a window. Actual digits in text can be wider or narrower than this, though this value is generally somewhat more accurate than the result of pango_font_metrics_get_approximate_char_width() for digits.

    Declaration

    Swift

    @inlinable
    var approximateDigitWidth: Int { get }
  • ascent Extension method

    Gets the ascent from a font metrics structure.

    The ascent is the distance from the baseline to the logical top of a line of text. (The logical top may be above or below the top of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.)

    Declaration

    Swift

    @inlinable
    var ascent: Int { get }
  • descent Extension method

    Gets the descent from a font metrics structure.

    The descent is the distance from the baseline to the logical bottom of a line of text. (The logical bottom may be above or below the bottom of the actual drawn ink. It is necessary to lay out the text to figure where the ink will be.)

    Declaration

    Swift

    @inlinable
    var descent: Int { get }
  • height Extension method

    Gets the line height from a font metrics structure.

    The line height is the recommended distance between successive baselines in wrapped text using this font.

    If the line height is not available, 0 is returned.

    Declaration

    Swift

    @inlinable
    var height: Int { get }
  • strikethroughPosition Extension method

    Gets the suggested position to draw the strikethrough.

    The value returned is the distance above the baseline of the top of the strikethrough.

    Declaration

    Swift

    @inlinable
    var strikethroughPosition: Int { get }
  • strikethroughThickness Extension method

    Gets the suggested thickness to draw for the strikethrough.

    Declaration

    Swift

    @inlinable
    var strikethroughThickness: Int { get }
  • underlinePosition Extension method

    Gets the suggested position to draw the underline.

    The value returned is the distance above the baseline of the top of the underline. Since most fonts have underline positions beneath the baseline, this value is typically negative.

    Declaration

    Swift

    @inlinable
    var underlinePosition: Int { get }
  • underlineThickness Extension method

    Gets the suggested thickness to draw for the underline.

    Declaration

    Swift

    @inlinable
    var underlineThickness: Int { get }