1.1 <PangoContext>

Class: <PangoContext>

It derives from <GObject>.

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 font-map:create-context.

Procedures

Method: context:changed self
Method: changed self

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.

self

Passed: a <PangoContext>.

a <PangoContext>

Method: context:get-base-dir self ⇒ %return
Method: get-base-dir self ⇒ %return

Retrieves the base direction for the context.

See context:set-base-dir.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoDirection>.

the base direction for the context.

Method: context:get-base-gravity self ⇒ %return
Method: get-base-gravity self ⇒ %return

Retrieves the base gravity for the context.

See context:set-base-gravity.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoGravity>.

the base gravity for the context.

Method: context:get-font-description self ⇒ %return
Method: get-font-description self ⇒ %return

Retrieve the default font description for the context.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoFontDescription>, or #f.

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

Method: context:get-font-map self ⇒ %return
Method: get-font-map self ⇒ %return

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

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoFontMap>, or #f.

the font map for the. <PangoContext> This value is owned by Pango and should not be unreferenced.

Method: context:get-gravity self ⇒ %return
Method: get-gravity self ⇒ %return

Retrieves the gravity for the context.

This is similar to context:get-base-gravity, except for when the base gravity is auto for which gravity:get-for-matrix is used to return the gravity from the current context matrix.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoGravity>.

the resolved gravity for the context.

Method: context:get-gravity-hint self ⇒ %return
Method: get-gravity-hint self ⇒ %return

Retrieves the gravity hint for the context.

See context:set-gravity-hint for details.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoGravityHint>.

the gravity hint for the context.

Method: context:get-language self ⇒ %return
Method: get-language self ⇒ %return

Retrieves the global language tag for the context.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoLanguage>.

the global language tag.

Method: context:get-matrix self ⇒ %return
Method: get-matrix self ⇒ %return

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

See context:set-matrix.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a <PangoMatrix>, or #f.

the matrix, or #f 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.

Method: context:get-metrics self [desc] [language] ⇒ %return
Method: get-metrics self [desc] [language] ⇒ %return

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 itemize, 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.

self

Passed: a <PangoContext>.

a <PangoContext>

desc

Passed, or left out: a <PangoFontDescription>, or #f.

a <PangoFontDescription> structure. #f means that the font description from the context will be used.

language

Passed, or left out: a <PangoLanguage>, or #f.

language tag used to determine which script to get the metrics for. #f 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 language:get-default will be returned.

%return

Returned: a <PangoFontMetrics>.

a <PangoFontMetrics> object. The caller must call font-metrics:unref when finished using the object.

Method: context:get-round-glyph-positions? self ⇒ %return
Method: get-round-glyph-positions? self ⇒ %return

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

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: a boolean.

Method: context:get-serial self ⇒ %return
Method: get-serial self ⇒ %return

Returns the current serial number of self.

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>.

self

Passed: a <PangoContext>.

a <PangoContext>

%return

Returned: an unsigned 32-bit integer.

The current serial number of self.

Method: context:list-families self ⇒ families
Method: list-families self ⇒ families

List all families for a context.

self

Passed: a <PangoContext>.

a <PangoContext>

families

Returned: a vector, each a <PangoFontFamily>.

location to store a pointer to an array of <PangoFontFamily>. This array should be freed with byte-array:free.

n-families

Not returned: it is the length of families.

location to store the number of elements in descs

Method: context:load-font self desc ⇒ %return
Method: load-font self desc ⇒ %return

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

self

Passed: a <PangoContext>.

a <PangoContext>

desc

Passed: a <PangoFontDescription>.

a <PangoFontDescription> describing the font to load

%return

Returned: a <PangoFont>, or #f.

the newly allocated <PangoFont> that was loaded, or #f if no font matched.

Method: context:load-fontset self desc language ⇒ %return
Method: load-fontset self desc language ⇒ %return

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

self

Passed: a <PangoContext>.

a <PangoContext>

desc

Passed: a <PangoFontDescription>.

a <PangoFontDescription> describing the fonts to load

language

Passed: a <PangoLanguage>.

a <PangoLanguage> the fonts will be used for

%return

Returned: a <PangoFontset>, or #f.

the newly allocated <PangoFontset> loaded, or #f if no font matched.

Procedure: context:new ⇒ %return

Creates a new <PangoContext> initialized to default values.

This function is not particularly useful as it should always be followed by a context:set-font-map call, and the function 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 <PangoContext>. For instance, the GTK toolkit has, among others, widget:get-pango-context. Use those instead.

%return

Returned: a <PangoContext>.

the newly allocated <PangoContext>, which should be freed with object:unref.

Method: context:set-base-dir self direction
Method: set-base-dir self direction

Sets the base direction for the context.

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

self

Passed: a <PangoContext>.

a <PangoContext>

direction

Passed: a <PangoDirection>, or one of its symbols.

the new base direction

Method: context:set-base-gravity self gravity
Method: set-base-gravity self gravity

Sets the base gravity for the context.

The base gravity is used in laying vertical text out.

self

Passed: a <PangoContext>.

a <PangoContext>

gravity

Passed: a <PangoGravity>, or one of its symbols.

the new base gravity

Method: context:set-font-description self [desc]
Method: set-font-description self [desc]

Set the default font description for the context

self

Passed: a <PangoContext>.

a <PangoContext>

desc

Passed, or left out: a <PangoFontDescription>, or #f.

the new pango font description

Method: context:set-font-map self [font-map]
Method: set-font-map self [font-map]

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.

self

Passed: a <PangoContext>.

a <PangoContext>

font-map

Passed, or left out: a <PangoFontMap>, or #f.

the <PangoFontMap> to set.

Method: context:set-gravity-hint self hint
Method: set-gravity-hint self hint

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 context:get-gravity is set to east or west.

self

Passed: a <PangoContext>.

a <PangoContext>

hint

Passed: a <PangoGravityHint>, or one of its symbols.

the new gravity hint

Method: context:set-language self [language]
Method: set-language self [language]

Sets the global language tag for the context.

The default language for the locale of the running process can be found using language:get-default.

self

Passed: a <PangoContext>.

a <PangoContext>

language

Passed, or left out: a <PangoLanguage>, or #f.

the new language tag.

Method: context:set-matrix self [matrix]
Method: set-matrix self [matrix]

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.

self

Passed: a <PangoContext>.

a <PangoContext>

matrix

Passed, or left out: a <PangoMatrix>, or #f.

a <PangoMatrix>, or #f to unset any existing matrix. (No matrix set is the same as setting the identity matrix.)

Method: context:set-round-glyph-positions self round-positions
Method: set-round-glyph-positions self round-positions

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.

self

Passed: a <PangoContext>.

a <PangoContext>

round-positions

Passed: a boolean.

whether to round glyph positions