ContextProtocol

public protocol ContextProtocol : ObjectProtocol

A PangoContext stores global information used to control the itemization process.

The information stored by PangoContext includes the fontmap used to look up fonts, and default values such as the default language, default gravity, or default font.

To obtain a PangoContext, use [methodPango.FontMap.create_context].

The ContextProtocol protocol exposes the methods and properties of an underlying PangoContext 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 Context. Alternatively, use ContextRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying PangoContext instance.

    Declaration

    Swift

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

    Typed pointer to the underlying PangoContext instance.

    Default Implementation

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

    Declaration

    Swift

    var context_ptr: UnsafeMutablePointer<PangoContext>! { get }
  • Required Initialiser for types conforming to ContextProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Context Class: ContextProtocol extension (methods and fields)

  • changed() Extension method

    Forces a change in the context, which will cause any PangoLayout using this context to re-layout.

    This function is only useful when implementing a new backend for Pango, something applications won’t do. Backends should call this function if they have attached extra data to the context and such data is changed.

    Declaration

    Swift

    @inlinable
    func changed()
  • getBaseDir() Extension method

    Retrieves the base direction for the context.

    See [methodPango.Context.set_base_dir].

    Declaration

    Swift

    @inlinable
    func getBaseDir() -> PangoDirection
  • getBaseGravity() Extension method

    Retrieves the base gravity for the context.

    See [methodPango.Context.set_base_gravity].

    Declaration

    Swift

    @inlinable
    func getBaseGravity() -> PangoGravity
  • getFontDescription() Extension method

    Retrieve the default font description for the context.

    Declaration

    Swift

    @inlinable
    func getFontDescription() -> Pango.FontDescriptionRef!
  • getFontMap() Extension method

    Gets the PangoFontMap used to look up fonts for this context.

    Declaration

    Swift

    @inlinable
    func getFontMap() -> Pango.FontMapRef!
  • getGravity() Extension method

    Retrieves the gravity for the context.

    This is similar to [methodPango.Context.get_base_gravity], except for when the base gravity is PANGO_GRAVITY_AUTO for which [funcPango.Gravity.get_for_matrix] is used to return the gravity from the current context matrix.

    Declaration

    Swift

    @inlinable
    func getGravity() -> PangoGravity
  • getGravityHint() Extension method

    Retrieves the gravity hint for the context.

    See [methodPango.Context.set_gravity_hint] for details.

    Declaration

    Swift

    @inlinable
    func getGravityHint() -> PangoGravityHint
  • getLanguage() Extension method

    Retrieves the global language tag for the context.

    Declaration

    Swift

    @inlinable
    func getLanguage() -> Pango.LanguageRef!
  • getMatrix() Extension method

    Gets the transformation matrix that will be applied when rendering with this context.

    See [methodPango.Context.set_matrix].

    Declaration

    Swift

    @inlinable
    func getMatrix() -> Pango.MatrixRef!
  • getMetrics(desc:language:) Extension method

    Get overall metric information for a particular font description.

    Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language.

    The PangoFontDescription is interpreted in the same way as by [funcitemize], and the family name may be a comma separated list of names. If characters from multiple of these families would be used to render the string, then the returned fonts would be a composite of the metrics for the fonts loaded for the individual families.

    Declaration

    Swift

    @inlinable
    func getMetrics(desc: FontDescriptionRef? = nil, language: LanguageRef? = nil) -> Pango.FontMetricsRef!
  • getMetrics(desc:language:) Extension method

    Get overall metric information for a particular font description.

    Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language.

    The PangoFontDescription is interpreted in the same way as by [funcitemize], and the family name may be a comma separated list of names. If characters from multiple of these families would be used to render the string, then the returned fonts would be a composite of the metrics for the fonts loaded for the individual families.

    Declaration

    Swift

    @inlinable
    func getMetrics<FontDescriptionT, LanguageT>(desc: FontDescriptionT?, language: LanguageT?) -> Pango.FontMetricsRef! where FontDescriptionT : FontDescriptionProtocol, LanguageT : LanguageProtocol
  • getRoundGlyphPositions() Extension method

    Returns whether font rendering with this context should round glyph positions and widths.

    Declaration

    Swift

    @inlinable
    func getRoundGlyphPositions() -> Bool
  • getSerial() Extension method

    Returns the current serial number of context.

    The serial number is initialized to an small number larger than zero when a new context is created and is increased whenever the context is changed using any of the setter functions, or the PangoFontMap it uses to find fonts has changed. The serial may wrap, but will never have the value 0. Since it can wrap, never compare it with “less than”, always use “not equals”.

    This can be used to automatically detect changes to a PangoContext, and is only useful when implementing objects that need update when their PangoContext changes, like PangoLayout.

    Declaration

    Swift

    @inlinable
    func getSerial() -> Int
  • list(families:nFamilies:) Extension method

    List all families for a context.

    Declaration

    Swift

    @inlinable
    func list(families: UnsafeMutablePointer<UnsafeMutablePointer<UnsafeMutablePointer<PangoFontFamily>?>?>!, nFamilies: UnsafeMutablePointer<gint>!)
  • loadFont(desc:) Extension method

    Loads the font in one of the fontmaps in the context that is the closest match for desc.

    Declaration

    Swift

    @inlinable
    func loadFont<FontDescriptionT>(desc: FontDescriptionT) -> Pango.FontRef! where FontDescriptionT : FontDescriptionProtocol
  • loadFontset(desc:language:) Extension method

    Load a set of fonts in the context that can be used to render a font matching desc.

    Declaration

    Swift

    @inlinable
    func loadFontset<FontDescriptionT, LanguageT>(desc: FontDescriptionT, language: LanguageT) -> Pango.FontsetRef! where FontDescriptionT : FontDescriptionProtocol, LanguageT : LanguageProtocol
  • setBaseDir(direction:) Extension method

    Sets the base direction for the context.

    The base direction is used in applying the Unicode bidirectional algorithm; if the direction is PANGO_DIRECTION_LTR or PANGO_DIRECTION_RTL, then the value will be used as the paragraph direction in the Unicode bidirectional algorithm. A value of PANGO_DIRECTION_WEAK_LTR or PANGO_DIRECTION_WEAK_RTL is used only for paragraphs that do not contain any strong characters themselves.

    Declaration

    Swift

    @inlinable
    func setBaseDir(direction: PangoDirection)
  • setBase(gravity:) Extension method

    Sets the base gravity for the context.

    The base gravity is used in laying vertical text out.

    Declaration

    Swift

    @inlinable
    func setBase(gravity: PangoGravity)
  • setFontDescription(desc:) Extension method

    Set the default font description for the context

    Declaration

    Swift

    @inlinable
    func setFontDescription<FontDescriptionT>(desc: FontDescriptionT) where FontDescriptionT : FontDescriptionProtocol
  • set(fontMap:) Extension method

    Sets the font map to be searched when fonts are looked-up in this context.

    This is only for internal use by Pango backends, a PangoContext obtained via one of the recommended methods should already have a suitable font map.

    Declaration

    Swift

    @inlinable
    func set<FontMapT>(fontMap: FontMapT) where FontMapT : FontMapProtocol
  • setGravity(hint:) Extension method

    Sets the gravity hint for the context.

    The gravity hint is used in laying vertical text out, and is only relevant if gravity of the context as returned by [methodPango.Context.get_gravity] is set to PANGO_GRAVITY_EAST or PANGO_GRAVITY_WEST.

    Declaration

    Swift

    @inlinable
    func setGravity(hint: PangoGravityHint)
  • set(language:) Extension method

    Sets the global language tag for the context.

    The default language for the locale of the running process can be found using [funcPango.Language.get_default].

    Declaration

    Swift

    @inlinable
    func set<LanguageT>(language: LanguageT) where LanguageT : LanguageProtocol
  • set(matrix:) Extension method

    Sets the transformation matrix that will be applied when rendering with this context.

    Note that reported metrics are in the user space coordinates before the application of the matrix, not device-space coordinates after the application of the matrix. So, they don’t scale with the matrix, though they may change slightly for different matrices, depending on how the text is fit to the pixel grid.

    Declaration

    Swift

    @inlinable
    func set(matrix: MatrixRef? = nil)
  • set(matrix:) Extension method

    Sets the transformation matrix that will be applied when rendering with this context.

    Note that reported metrics are in the user space coordinates before the application of the matrix, not device-space coordinates after the application of the matrix. So, they don’t scale with the matrix, though they may change slightly for different matrices, depending on how the text is fit to the pixel grid.

    Declaration

    Swift

    @inlinable
    func set<MatrixT>(matrix: MatrixT?) where MatrixT : MatrixProtocol
  • Sets whether font rendering with this context should round glyph positions and widths to integral positions, in device units.

    This is useful when the renderer can’t handle subpixel positioning of glyphs.

    The default value is to round glyph positions, to remain compatible with previous Pango behavior.

    Declaration

    Swift

    @inlinable
    func setRoundGlyphPositions(roundPositions: Bool)
  • Breaks a piece of text into segments with consistent directional level and font.

    Each byte of text will be contained in exactly one of the items in the returned list; the generated list of items will be in logical order (the start offsets of the items are ascending).

    cached_iter should be an iterator over attrs currently positioned at a range before or containing start_index; cached_iter will be advanced to the range covering the position just after start_index + length. (i.e. if itemizing in a loop, just keep passing in the same cached_iter).

    Declaration

    Swift

    @inlinable
    func itemize<AttrListT>(text: UnsafePointer<CChar>!, startIndex: Int, length: Int, attrs: AttrListT, cachedIter: AttrIteratorRef? = nil) -> GLib.ListRef! where AttrListT : AttrListProtocol
  • Breaks a piece of text into segments with consistent directional level and font.

    Each byte of text will be contained in exactly one of the items in the returned list; the generated list of items will be in logical order (the start offsets of the items are ascending).

    cached_iter should be an iterator over attrs currently positioned at a range before or containing start_index; cached_iter will be advanced to the range covering the position just after start_index + length. (i.e. if itemizing in a loop, just keep passing in the same cached_iter).

    Declaration

    Swift

    @inlinable
    func itemize<AttrIteratorT, AttrListT>(text: UnsafePointer<CChar>!, startIndex: Int, length: Int, attrs: AttrListT, cachedIter: AttrIteratorT?) -> GLib.ListRef! where AttrIteratorT : AttrIteratorProtocol, AttrListT : AttrListProtocol
  • Like pango_itemize(), but with an explicitly specified base direction.

    The base direction is used when computing bidirectional levels. [funcitemize] gets the base direction from the PangoContext (see [methodPango.Context.set_base_dir]).

    Declaration

    Swift

    @inlinable
    func itemizeWith<AttrListT>(baseDir: PangoDirection, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, attrs: AttrListT, cachedIter: AttrIteratorRef? = nil) -> GLib.ListRef! where AttrListT : AttrListProtocol
  • Like pango_itemize(), but with an explicitly specified base direction.

    The base direction is used when computing bidirectional levels. [funcitemize] gets the base direction from the PangoContext (see [methodPango.Context.set_base_dir]).

    Declaration

    Swift

    @inlinable
    func itemizeWith<AttrIteratorT, AttrListT>(baseDir: PangoDirection, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, attrs: AttrListT, cachedIter: AttrIteratorT?) -> GLib.ListRef! where AttrIteratorT : AttrIteratorProtocol, AttrListT : AttrListProtocol
  • baseDir Extension method

    Retrieves the base direction for the context.

    See [methodPango.Context.set_base_dir].

    Declaration

    Swift

    @inlinable
    var baseDir: PangoDirection { get nonmutating set }
  • baseGravity Extension method

    Retrieves the base gravity for the context.

    See [methodPango.Context.set_base_gravity].

    Declaration

    Swift

    @inlinable
    var baseGravity: PangoGravity { get nonmutating set }
  • fontDescription Extension method

    Retrieve the default font description for the context.

    Declaration

    Swift

    @inlinable
    var fontDescription: Pango.FontDescriptionRef! { get nonmutating set }
  • fontMap Extension method

    Gets the PangoFontMap used to look up fonts for this context.

    Declaration

    Swift

    @inlinable
    var fontMap: Pango.FontMapRef! { get nonmutating set }
  • gravity Extension method

    Retrieves the gravity for the context.

    This is similar to [methodPango.Context.get_base_gravity], except for when the base gravity is PANGO_GRAVITY_AUTO for which [funcPango.Gravity.get_for_matrix] is used to return the gravity from the current context matrix.

    Declaration

    Swift

    @inlinable
    var gravity: PangoGravity { get }
  • gravityHint Extension method

    Retrieves the gravity hint for the context.

    See [methodPango.Context.set_gravity_hint] for details.

    Declaration

    Swift

    @inlinable
    var gravityHint: PangoGravityHint { get nonmutating set }
  • language Extension method

    Retrieves the global language tag for the context.

    Declaration

    Swift

    @inlinable
    var language: Pango.LanguageRef! { get nonmutating set }
  • matrix Extension method

    Gets the transformation matrix that will be applied when rendering with this context.

    See [methodPango.Context.set_matrix].

    Declaration

    Swift

    @inlinable
    var matrix: Pango.MatrixRef! { get nonmutating set }
  • roundGlyphPositions Extension method

    Returns whether font rendering with this context should round glyph positions and widths.

    Declaration

    Swift

    @inlinable
    var roundGlyphPositions: Bool { get nonmutating set }
  • serial Extension method

    Returns the current serial number of context.

    The serial number is initialized to an small number larger than zero when a new context is created and is increased whenever the context is changed using any of the setter functions, or the PangoFontMap it uses to find fonts has changed. The serial may wrap, but will never have the value 0. Since it can wrap, never compare it with “less than”, always use “not equals”.

    This can be used to automatically detect changes to a PangoContext, and is only useful when implementing objects that need update when their PangoContext changes, like PangoLayout.

    Declaration

    Swift

    @inlinable
    var serial: Int { get }