Class: Pango::Context

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#base_dirPango::Direction

Retrieves the base direction for the context. See pango_context_set_base_dir().

Returns:

#base_dir=(direction) ⇒ nil

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.

Parameters:

Returns:

  • (nil)

#base_gravityPango::Gravity

Retrieves the base gravity for the context. See pango_context_set_base_gravity().

Returns:

#base_gravity=(gravity) ⇒ nil

Sets the base gravity for the context.

The base gravity is used in laying vertical text out.

Parameters:

Returns:

  • (nil)

#changednil

Forces a change in the context, which will cause any Pango::Layout 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.

Returns:

  • (nil)

#font_descriptionPango::FontDescription

Retrieve the default font description for the context.

Returns:

  • (Pango::FontDescription)

    a pointer to the context’s default font description. This value must not be modified or freed.

#font_description=(desc) ⇒ nil

Set the default font description for the context

Parameters:

  • desc (Pango::FontDescription)

    the new pango font description

Returns:

  • (nil)

#font_mapPango::FontMap

Gets the Pango::FontMap used to look up fonts for this context.

Returns:

  • (Pango::FontMap)

    the font map for the Pango::Context. This value is owned by Pango and should not be unreferenced.

#font_map=(font_map) ⇒ nil

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 Pango::Context obtained via one of the recommended methods should already have a suitable font map.

Parameters:

Returns:

  • (nil)

#get_metrics(desc, language) ⇒ Pango::FontMetrics

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 Pango::FontDescription is interpreted in the same way as by pango_itemize(), and the family name may be a comma separated list of figures. 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.

Parameters:

  • desc (Pango::FontDescription)

    a Pango::FontDescription structure. nil means that the font description from the context will be used.

  • language (Pango::Language)

    language tag used to determine which script to get the metrics for. nil means that the language tag from the context will be used. If no language tag is set on the context, metrics for the default language (as determined by pango_language_get_default()) will be returned.

Returns:

  • (Pango::FontMetrics)

    a Pango::FontMetrics object. The caller must call pango_font_metrics_unref() when finished using the object.

#gravityPango::Gravity

Retrieves the gravity for the context. This is similar to pango_context_get_base_gravity(), except for when the base gravity is %PANGO_GRAVITY_AUTO for which pango_gravity_get_for_matrix() is used to return the gravity from the current context matrix.

Returns:

#gravity_hintPango::GravityHint

Retrieves the gravity hint for the context. See pango_context_set_gravity_hint() for details.

Returns:

#gravity_hint=(hint) ⇒ nil

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 pango_context_get_gravity() is set %PANGO_GRAVITY_EAST or %PANGO_GRAVITY_WEST.

Parameters:

Returns:

  • (nil)

#languagePango::Language

Retrieves the global language tag for the context.

Returns:

  • (Pango::Language)

    the global language tag.

#language=(language) ⇒ nil

Sets the global language tag for the context. The default language for the locale of the running process can be found using pango_language_get_default().

Parameters:

  • language (Pango::Language)

    the new language tag.

Returns:

  • (nil)

#list_families(families, n_families) ⇒ nil

List all families for a context.

Parameters:

  • families (Array<Pango::FontFamily>)

    location to store a pointer to an array of Pango::FontFamily *. This array should be freed with g_free().

  • n_families (Integer)

    location to store the number of elements in descs

Returns:

  • (nil)

#load_font(desc) ⇒ Pango::Font

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

Parameters:

  • desc (Pango::FontDescription)

    a Pango::FontDescription describing the font to load

Returns:

  • (Pango::Font)

    the newly allocated Pango::Font that was loaded, or nil if no font matched.

#load_fontset(desc, language) ⇒ Pango::Fontset

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

Parameters:

  • desc (Pango::FontDescription)

    a Pango::FontDescription describing the fonts to load

  • language (Pango::Language)

    a Pango::Language the fonts will be used for

Returns:

  • (Pango::Fontset)

    the newly allocated Pango::Fontset loaded, or nil if no font matched.

#matrixPango::Matrix

Gets the transformation matrix that will be applied when rendering with this context. See pango_context_set_matrix().

Returns:

  • (Pango::Matrix)

    the matrix, or nil if no matrix has been set (which is the same as the identity matrix). The returned matrix is owned by Pango and must not be modified or freed.

#matrix=(matrix) ⇒ nil

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. matrix. (No matrix set is the same as setting the identity matrix.)

Parameters:

  • matrix (Pango::Matrix)

    a Pango::Matrix, or nil to unset any existing

Returns:

  • (nil)

#newPango::Context

Creates a new Pango::Context initialized to default values.

This function is not particularly useful as it should always be followed by a pango_context_set_font_map() call, and the function pango_font_map_create_context() does these two steps together and hence users are recommended to use that.

If you are using Pango as part of a higher-level system, that system may have it’s own way of create a Pango::Context. For instance, the GTK+ toolkit has, among others, gdk_pango_context_get_for_screen(), and gtk_widget_get_pango_context(). Use those instead.

Returns:

  • (Pango::Context)

    the newly allocated Pango::Context, which should be freed with g_object_unref().

#round_glyph_positionsTrueClass

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

Returns:

  • (TrueClass)

#round_glyph_positions=(round_positions) ⇒ nil

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.

Parameters:

  • round_positions (TrueClass)

    whether to round glyph positions

Returns:

  • (nil)

#serialInteger

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 Pango::FontMap 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 Pango::Context, and is only useful when implementing objects that need update when their Pango::Context changes, like #PangoLayout.

Returns:

  • (Integer)

    The current serial number of context.