LanguageProtocol

public protocol LanguageProtocol

The PangoLanguage structure is used to represent a language.

PangoLanguage pointers can be efficiently copied and compared with each other.

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

  • ptr

    Untyped pointer to the underlying PangoLanguage instance.

    Declaration

    Swift

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

    Typed pointer to the underlying PangoLanguage instance.

    Default Implementation

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

    Declaration

    Swift

    var language_ptr: UnsafeMutablePointer<PangoLanguage>! { get }
  • Required Initialiser for types conforming to LanguageProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Language Record: LanguageProtocol extension (methods and fields)

  • getSampleString() Extension method

    Get a string that is representative of the characters needed to render a particular language.

    The sample text may be a pangram, but is not necessarily. It is chosen to be demonstrative of normal text in the language, as well as exposing font feature requirements unique to the language. It is suitable for use as sample text in a font selection dialog.

    If language is nil, the default language as found by [funcPango.Language.get_default] is used.

    If Pango does not have a sample string for language, the classic “The quick brown fox…” is returned. This can be detected by comparing the returned pointer value to that returned for (non-existent) language code “xx”. That is, compare to:

    pango_language_get_sample_string (pango_language_from_string ("xx"))
    

    Declaration

    Swift

    @inlinable
    func getSampleString() -> String!
  • getScripts(numScripts:) Extension method

    Determines the scripts used to to write language.

    If nothing is known about the language tag language, or if language is nil, then nil is returned. The list of scripts returned starts with the script that the language uses most and continues to the one it uses least.

    The value num_script points at will be set to the number of scripts in the returned array (or zero if nil is returned).

    Most languages use only one script for writing, but there are some that use two (Latin and Cyrillic for example), and a few use three (Japanese for example). Applications should not make any assumptions on the maximum number of scripts returned though, except that it is positive if the return value is not nil, and it is a small number.

    The [methodPango.Language.includes_script] function uses this function internally.

    Note: while the return value is declared as PangoScript, the returned values are from the GUnicodeScript enumeration, which may have more values. Callers need to handle unknown values.

    Declaration

    Swift

    @inlinable
    func getScripts(numScripts: UnsafeMutablePointer<gint>! = nil) -> UnsafePointer<PangoScript>!
  • includes(script:) Extension method

    Determines if script is one of the scripts used to write language.

    The returned value is conservative; if nothing is known about the language tag language, true will be returned, since, as far as Pango knows, script might be used to write language.

    This routine is used in Pango’s itemization process when determining if a supplied language tag is relevant to a particular section of text. It probably is not useful for applications in most circumstances.

    This function uses [methodPango.Language.get_scripts] internally.

    Declaration

    Swift

    @inlinable
    func includes(script: PangoScript) -> Bool
  • matches(rangeList:) Extension method

    Checks if a language tag matches one of the elements in a list of language ranges.

    A language tag is considered to match a range in the list if the range is ‘*’, the range is exactly the tag, or the range is a prefix of the tag, and the character after it in the tag is ‘-’.

    Declaration

    Swift

    @inlinable
    func matches(rangeList: UnsafePointer<CChar>!) -> Bool
  • toString() Extension method

    Gets the RFC-3066 format string representing the given language tag.

    Returns (transfer none): a string representing the language tag

    Declaration

    Swift

    @inlinable
    func toString() -> String!
  • attrLanguageNew() Extension method

    Create a new language tag attribute.

    Declaration

    Swift

    @inlinable
    func attrLanguageNew() -> Pango.AttributeRef!
  • Computes a PangoLogAttr for each character in text.

    The attrs array must have one PangoLogAttr for each position in text; if text contains N characters, it has N+1 positions, including the last position at the end of the text. text should be an entire paragraph; logical attributes can’t be computed without context (for example you need to see spaces on either side of a word to know the word is a word).

    Declaration

    Swift

    @inlinable
    func getLogAttrs(text: UnsafePointer<CChar>!, length: Int, level: Int, attrs: UnsafeMutablePointer<PangoLogAttr>!, attrsLen: Int)
  • sampleString Extension method

    Get a string that is representative of the characters needed to render a particular language.

    The sample text may be a pangram, but is not necessarily. It is chosen to be demonstrative of normal text in the language, as well as exposing font feature requirements unique to the language. It is suitable for use as sample text in a font selection dialog.

    If language is nil, the default language as found by [funcPango.Language.get_default] is used.

    If Pango does not have a sample string for language, the classic “The quick brown fox…” is returned. This can be detected by comparing the returned pointer value to that returned for (non-existent) language code “xx”. That is, compare to:

    pango_language_get_sample_string (pango_language_from_string ("xx"))
    

    Declaration

    Swift

    @inlinable
    var sampleString: String! { get }