Struct pango::Context[][src]

pub struct Context(_);
Expand description

The Context structure stores global information used to control the itemization process.

Implementations

Creates a new Context initialized to default values.

This function is not particularly useful as it should always be followed by a set_font_map() call, and the function FontMapExt::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 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

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

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

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

Returns

the base direction for the context.

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

Returns

the base gravity for the context.

Retrieve the default font description for the context.

Returns

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

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

Returns

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

Retrieves the gravity for the context. This is similar to base_gravity(), except for when the base gravity is Gravity::Auto for which Gravity::for_matrix() is used to return the gravity from the current context matrix.

Returns

the resolved gravity for the context.

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

Returns

the gravity hint for the context.

Retrieves the global language tag for the context.

Returns

the global language tag.

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

Returns

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

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 FontDescription is interpreted in the same way as by 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.

desc

a FontDescription structure. None means that the font description from the context will be used.

language

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

Returns

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

This is supported on crate feature v1_44 only.

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

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

Returns

The current serial number of self.

List all families for a context.

Returns

families

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

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

desc

a FontDescription describing the font to load

Returns

the newly allocated Font that was loaded, or None if no font matched.

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

desc

a FontDescription describing the fonts to load

language

a Language the fonts will be used for

Returns

the newly allocated Fontset loaded, or None if no font matched.

Sets the base direction for the context.

The base direction is used in applying the Unicode bidirectional algorithm; if the direction is Direction::Ltr or Direction::Rtl, then the value will be used as the paragraph direction in the Unicode bidirectional algorithm. A value of Direction::WeakLtr or Direction::WeakRtl is used only for paragraphs that do not contain any strong characters themselves.

direction

the new base direction

Sets the base gravity for the context.

The base gravity is used in laying vertical text out.

gravity

the new base gravity

Set the default font description for the context

desc

the new pango font description

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

font_map

the FontMap to set.

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 gravity() is set Gravity::East or Gravity::West.

hint

the new gravity hint

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

language

the new language tag.

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

a Matrix, or None to unset any existing matrix. (No matrix set is the same as setting the identity matrix.)

This is supported on crate feature v1_44 only.

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.

round_positions

whether to round glyph positions

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.