Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: PangoApi

[12:14] static extends: object

Generated low-level function wrappers for namespace Pango.

Members

  • lib

Methods

  • getLib ()

  • attr_allow_breaks_new (bool allow_breaks)

    Create a new allow-breaks attribute. If breaks are disabled, the range will be kept in a single run, as far as possible.

    • @p allow_breaks is %TRUE if we line breaks are allowed.
  • attr_baseline_shift_new (int shift)

    Create a new baseline displacement attribute. The effect of this attribute is to shift the baseline of a run, relative to the run of preceding run. Baseline Shift

    • @p shift is either a PangoBaselineShift enumeration value or an absolute value (> 1024) in Pango units, relative to the baseline of the previous run. Positive values displace the text upwards..
  • attr_fallback_new (bool enable_fallback)

    Create a new font fallback attribute. If fallback is disabled, characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text.

    • @p enable_fallback is %TRUE if we should fall back on other fonts for characters the active font is missing.
  • attr_family_new (string family)

    Create a new font family attribute.

    • @p family is the family or comma-separated list of families.
  • attr_font_desc_new (object desc)

    Create a new font description attribute. This attribute allows setting family, style, weight, variant, stretch, and size simultaneously.

    • @p desc is the font description.
  • attr_font_features_new (string features)

    Create a new font features tag attribute. You can use this attribute to select OpenType font features like small-caps, alternative glyphs, ligatures, etc. for fonts that support them.

  • attr_font_scale_new (string scale)

    Create a new font scale attribute. The effect of this attribute is to change the font size of a run, relative to the size of preceding run.

    • @p scale is a PangoFontScale value, which indicates font size change relative to the size of the previous run..
  • attr_gravity_hint_new (string hint)

    Create a new gravity hint attribute.

    • @p hint is the gravity hint value.
  • attr_gravity_new (string gravity)

    Create a new gravity attribute.

    • @p gravity is the gravity value; should not be %PANGO_GRAVITY_AUTO.
  • attr_insert_hyphens_new (bool insert_hyphens)

    Create a new insert-hyphens attribute. Pango will insert hyphens when breaking lines in the middle of a word. This attribute can be used to suppress the hyphen.

    • @p insert_hyphens is %TRUE if hyphens should be inserted.
  • attr_language_new (object language)

    Create a new language tag attribute.

    • @p language is language tag.
  • attr_letter_spacing_new (int letter_spacing)

    Create a new letter-spacing attribute.

    • @p letter_spacing is amount of extra space to add between graphemes of the text, in Pango units.
  • attr_line_height_new (double factor)

    Modify the height of logical line extents by a factor. This affects the values returned by [method@Pango.LayoutLine.get_extents], [method@Pango.LayoutLine.get_pixel_extents] and [method@Pango.LayoutIter.get_line_extents].

    • @p factor is the scaling factor to apply to the logical height.
  • attr_line_height_new_absolute (int height)

    Override the height of logical line extents to be @height. This affects the values returned by [method@Pango.LayoutLine.get_extents], [method@Pango.LayoutLine.get_pixel_extents] and [method@Pango.LayoutIter.get_line_extents].

    • @p height is the line height, in %PANGO_SCALE-ths of a point.
  • attr_list_from_string (string text)

    Deserializes a PangoAttrList from a string. This is the counterpart to [method@Pango.AttrList.to_string]. See that functions for details about the format.

    • @p text is a string.
  • attr_overline_new (string overline)

    Create a new overline-style attribute.

    • @p overline is the overline style.
  • attr_rise_new (int rise)

    Create a new baseline displacement attribute.

    • @p rise is the amount that the text should be displaced vertically, in Pango units. Positive values displace the text upwards..
  • attr_scale_new (double scale_factor)

    Create a new font size scale attribute. The base font for the affected text will have its size multiplied by @scale_factor.

    • @p scale_factor is factor to scale the font.
  • attr_sentence_new ()

    Marks the range of the attribute as a single sentence. Note that this may require adjustments to word and sentence classification around the range.

  • attr_shape_new (ink_rect, logical_rect)

    Create a new shape attribute. A shape is used to impose a particular ink and logical rectangle on the result of shaping a particular glyph. This might be used, for instance, for embedding a picture or a widget inside a PangoLayout.

    • @p ink_rect is ink rectangle to assign to each character.
    • @p logical_rect is logical rectangle to assign to each character.
  • attr_show_new (string flags)

    Create a new attribute that influences how invisible characters are rendered.

    • @p flags is PangoShowFlags to apply.
  • attr_size_new (int size)

    Create a new font-size attribute in fractional points.

    • @p size is the font size, in %PANGO_SCALE-ths of a point.
  • attr_size_new_absolute (int size)

    Create a new font-size attribute in device units.

    • @p size is the font size, in %PANGO_SCALE-ths of a device unit.
  • attr_stretch_new (string stretch)

    Create a new font stretch attribute.

    • @p stretch is the stretch.
  • attr_strikethrough_new (bool strikethrough)

    Create a new strike-through attribute.

    • @p strikethrough is %TRUE if the text should be struck-through.
  • attr_style_new (string style)

    Create a new font slant style attribute.

    • @p style is the slant style.
  • attr_text_transform_new (string transform)

    Create a new attribute that influences how characters are transformed during shaping.

    • @p transform is PangoTextTransform to apply.
  • attr_type_get_name (string type)

    Fetches the attribute type name. The attribute type name is the string passed in when registering the type using [func@Pango.AttrType.register]. The returned value is an interned string (see g_intern_string() for what that means) that should not be modified or freed.

    • @p type is an attribute type ID to fetch the name for.
  • attr_type_register (string name)

    Allocate a new attribute type ID. The attribute type name can be accessed later by using [func@Pango.AttrType.get_name].

    • @p name is an identifier for the type.
  • attr_underline_new (string underline)

    Create a new underline-style attribute.

    • @p underline is the underline style.
  • attr_variant_new (string variant)

    Create a new font variant attribute (normal or small caps).

    • @p variant is the variant.
  • attr_weight_new (string weight)

    Create a new font weight attribute.

    • @p weight is the weight.
  • attr_word_new ()

    Marks the range of the attribute as a single word. Note that this may require adjustments to word and sentence classification around the range.

  • find_base_dir (string text, int length)

    Searches a string the first character that has a strong direction, according to the Unicode bidirectional algorithm.

    • @p text is the text to process. Must be valid UTF-8.
    • @p length is length of @text in bytes (may be -1 if @text is nul-terminated).
  • font_description_from_string (string str)

    Creates a new font description from a string representation. The string must have the form [FAMILY-LIST] [STYLE-OPTIONS] [SIZE] [VARIATIONS] [FEATURES] where FAMILY-LIST is a comma-separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace-separated list of words where each word describes one of style, variant, weight, stretch, or gravity, and SIZE is a decimal number (size in points) or optionally followed by the unit modifier "px" for absolute size. The following words are understood as styles: "Normal", "Roman", "Oblique", "Italic". The following words are understood as variants: "Small-Caps", "All-Small-Caps", "Petite-Caps", "All-Petite-Caps", "Unicase", "Title-Caps". The following words are understood as weights: "Thin", "Ultra-Light", "Extra-Light", "Light", "Semi-Light", "Demi-Light", "Book", "Regular", "Medium", "Semi-Bold", "Demi-Bold", "Bold", "Ultra-Bold", "Extra-Bold", "Heavy", "Black", "Ultra-Black", "Extra-Black". The following words are understood as stretch values: "Ultra-Condensed", "Extra-Condensed", "Condensed", "Semi-Condensed", "Semi-Expanded", "Expanded", "Extra-Expanded", "Ultra-Expanded". The following words are understood as gravity values: "Not-Rotated", "South", "Upside-Down", "North", "Rotated-Left", "East", "Rotated-Right", "West". The following words are understood as color values: "With-Color", "Without-Color". VARIATIONS is a comma-separated list of font variations of the form @‍axis1=value,axis2=value,... FEATURES is a comma-separated list of font features of the form #‍feature1=value,feature2=value,... The =value part can be ommitted if the value is 1. Any one of the options may be absent. If FAMILY-LIST is absent, then the family_name field of the resulting font description will be initialized to %NULL. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0. A typical example: Cantarell Italic Light 15 @‍wght=200 #‍tnum=1

    • @p str is string representation of a font description..
  • gravity_get_for_matrix (matrix)

    Finds the gravity that best matches the rotation component in a PangoMatrix.

    • @p matrix is a PangoMatrix.
  • gravity_get_for_script (string script, string base_gravity, string hint)

    Returns the gravity to use in laying out a PangoItem. The gravity is determined based on the script, base gravity, and hint. If @base_gravity is %PANGO_GRAVITY_AUTO, it is first replaced with the preferred gravity of @script. To get the preferred gravity of a script, pass %PANGO_GRAVITY_AUTO and %PANGO_GRAVITY_HINT_STRONG in.

    • @p script is PangoScript to query.
    • @p base_gravity is base gravity of the paragraph.
    • @p hint is orientation hint.
  • gravity_get_for_script_and_width (string script, bool wide, string base_gravity, string hint)

    Returns the gravity to use in laying out a single character or PangoItem. The gravity is determined based on the script, East Asian width, base gravity, and hint, This function is similar to [func@Pango.Gravity.get_for_script] except that this function makes a distinction between narrow/half-width and wide/full-width characters also. Wide/full-width characters always stand upright, that is, they always take the base gravity, whereas narrow/full-width characters are always rotated in vertical context. If @base_gravity is %PANGO_GRAVITY_AUTO, it is first replaced with the preferred gravity of

    • @script. ``
    • @p script is PangoScript to query.
    • @p wide is %TRUE for wide characters as returned by g_unichar_iswide().
    • @p base_gravity is base gravity of the paragraph.
    • @p hint is orientation hint.
  • gravity_to_rotation (string gravity)

    Converts a PangoGravity value to its natural rotation in radians. Note that [method@Pango.Matrix.rotate] takes angle in degrees, not radians. So, to call [method@Pango.Matrix,rotate] with the output of this function you should multiply it by (180. / G_PI).

    • @p gravity is gravity to query, should not be %PANGO_GRAVITY_AUTO.
  • itemize (object context, string text, int start_index, int length, object attrs, object cached_iter)

    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).
    • @p context is a structure holding information that affects the itemization process..
    • @p text is the text to itemize. Must be valid UTF-8.
    • @p start_index is first byte in @text to process.
    • @p length is the number of bytes (not characters) to process after
    • @start_index. This must be >= 0..
    • @p attrs is the set of attributes that apply to @text..
    • @p cached_iter is Cached attribute iterator.
  • itemize_with_base_dir (object context, string base_dir, string text, int start_index, int length, object attrs, object cached_iter)

    Like pango_itemize(), but with an explicitly specified base direction. The base direction is used when computing bidirectional levels. [func@itemize] gets the base direction from the PangoContext (see [method@Pango.Context.set_base_dir]).

    • @p context is a structure holding information that affects the itemization process..
    • @p base_dir is base direction to use for bidirectional processing.
    • @p text is the text to itemize..
    • @p start_index is first byte in @text to process.
    • @p length is the number of bytes (not characters) to process after
    • @start_index. This must be >= 0..
    • @p attrs is the set of attributes that apply to @text..
    • @p cached_iter is Cached attribute iterator.
  • language_from_string (string language)

    Convert a language tag to a PangoLanguage. The language tag must be in a RFC-3066 format. PangoLanguage pointers can be efficiently copied (copy the pointer) and compared with other language tags (compare the pointer.) This function first canonicalizes the string by converting it to lowercase, mapping '_' to '-', and stripping all characters other than letters and '-'. Use [func@Pango.Language.get_default] if you want to get the PangoLanguage for the current locale of the process.

    • @p language is a string representing a language tag.
  • language_get_default ()

    Returns the PangoLanguage for the current locale of the process. On Unix systems, this is the return value is derived from setlocale (LC_CTYPE, NULL), and the user can affect this through the environment variables LC_ALL, LC_CTYPE or LANG (checked in that order). The locale string typically is in the form lang_COUNTRY, where lang is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. For instance, sv_FI for Swedish as written in Finland or pt_BR for Portuguese as written in Brazil. On Windows, the C library does not use any such environment variables, and setting them won't affect the behavior of functions like ctime(). The user sets the locale through the Regional Options in the Control Panel. The C library (in the setlocale() function) does not use country and language codes, but country and language names spelled out in English. However, this function does check the above environment variables, and does return a Unix-style locale string based on either said environment variables or the thread's current locale. Your application should call setlocale(LC_ALL, "") for the user settings to take effect. GTK does this in its initialization functions automatically (by calling gtk_set_locale()). See the setlocale() manpage for more details. Note that the default language can change over the life of an application. Also note that this function will not do the right thing if you use per-thread locales with uselocale(). In that case, you should just call pango_language_from_string() yourself.

  • read_line (stream, str)

    Reads an entire line from a file into a buffer. Lines may be delimited with '\n', '\r', '\n\r', or '\r\n'. The delimiter is not written into the buffer. Text after a '#' character is treated as a comment and skipped. '' can be used to escape a # character. '' proceeding a line delimiter combines adjacent lines. A '' proceeding any other character is ignored and written into the output buffer unmodified.

    • @p stream is a stdio stream.
    • @p str is GString buffer into which to write the result.
  • reorder_items (object items)

    Reorder items from logical order to visual order. The visual order is determined from the associated directional levels of the items. The original list is unmodified. (Please open a bug if you use this function. It is not a particularly convenient interface, and the code is duplicated elsewhere in Pango for that reason.)

    • @p items is a GList of PangoItem in logical order..
  • script_get_sample_language (string script)

    Finds a language tag that is reasonably representative of @script. The language will usually be the most widely spoken or used language written in that script: for instance, the sample language for %PANGO_SCRIPT_CYRILLIC is ru (Russian), the sample language for %PANGO_SCRIPT_ARABIC is ar. For some scripts, no sample language will be returned because there is no language that is sufficiently representative. The best example of this is %PANGO_SCRIPT_HAN, where various different variants of written Chinese, Japanese, and Korean all use significantly different sets of Han characters and forms of shared characters. No sample language can be provided for many historical scripts as well. As of 1.18, this function checks the environment variables PANGO_LANGUAGE and LANGUAGE (checked in that order) first. If one of them is set, it is parsed as a list of language tags separated by colons or other separators. This function will return the first language in the parsed list that Pango believes may use @script for writing. This last predicate is tested using [method@Pango.Language.includes_script]. This can be used to control Pango's font selection for non-primary languages. For example, a PANGO_LANGUAGE enviroment variable set to "en:fa" makes Pango choose fonts suitable for Persian (fa) instead of Arabic (ar) when a segment of Arabic text is found in an otherwise non-Arabic text. The same trick can be used to choose a default language for %PANGO_SCRIPT_HAN when setting context language is not feasible.

    • @p script is a PangoScript.
  • split_file_list (string str)

    Splits a %G_SEARCHPATH_SEPARATOR-separated list of files, stripping white space and substituting ~/ with $HOME/.

    • @p str is a %G_SEARCHPATH_SEPARATOR separated list of filenames.
  • tab_array_from_string (string text)

    Deserializes a PangoTabArray from a string. This is the counterpart to [method@Pango.TabArray.to_string]. See that functions for details about the format.

    • @p text is a string.
  • trim_string (string str)

    Trims leading and trailing whitespace from a string.

    • @p str is a string.
  • units_from_double (double d)

    Converts a floating-point number to Pango units. The conversion is done by multiplying @d by %PANGO_SCALE and rounding the result to nearest integer.

    • @p d is double floating-point value.
  • units_to_double (int i)

    Converts a number in Pango units to floating-point. The conversion is done by dividing @i by %PANGO_SCALE.

    • @p i is value in Pango units.
  • version ()

    Returns the encoded version of Pango available at run-time. This is similar to the macro %PANGO_VERSION except that the macro returns the encoded version available at compile-time. A version number can be encoded into an integer using PANGO_VERSION_ENCODE().

  • version_check (int required_major, int required_minor, int required_micro)

    Checks that the Pango library in use is compatible with the given version. Generally you would pass in the constants %PANGO_VERSION_MAJOR, %PANGO_VERSION_MINOR, %PANGO_VERSION_MICRO as the three arguments to this function; that produces a check that the library in use at run-time is compatible with the version of Pango the application or module was compiled against. Compatibility is defined by two things: first the version of the running library is newer than the version

    • @required_major.required_minor.@required_micro. Second the running library must be binary compatible with the version
    • @required_major.required_minor.@required_micro (same major version.) For compile-time version checking use PANGO_VERSION_CHECK().
    • @p required_major is the required major version.
    • @p required_minor is the required minor version.
    • @p required_micro is the required major version.
  • version_string ()

    Returns the version of Pango available at run-time. This is similar to the macro %PANGO_VERSION_STRING except that the macro returns the version available at compile-time.