#[repr(transparent)]
pub struct Context { /* private fields */ }
Expand description

A Context stores global information used to control the itemization process.

The information stored by Context includes the fontmap used to look up fonts, and default values such as the default language, default gravity, or default font.

To obtain a Context, use FontMapExt::create_context().

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

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::FontMetrics::unref() when finished using the object.

Available 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 to 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.)

Available 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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

Returns the type of the object.

Returns the ObjectClass of the object. Read more

Returns the class of the object.

Returns the class of the object in the given type T. Read more

Returns the interface T of the object. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_properties but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::set_properties_from_value but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::property but fails instead of panicking.

Gets the property property_name of the object and cast it to the type V. Read more

Similar to Self::property_value but fails instead of panicking.

Gets the property property_name of the object. Read more

Check if the object has a property property_name of the given type_. Read more

Get the type of the property property_name of this object. Read more

Get the ParamSpec of the property property_name of this object.

Return all ParamSpec of the properties of this object.

Freeze all property notifications until the return guard object is dropped. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Block a given signal handler. Read more

Unblock a given signal handler.

Stop emission of the currently emitted signal.

Stop emission of the currently emitted signal by the (possibly detailed) signal name.

Similar to Self::connect but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_local but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_local_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_unsafe but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_unsafe_id but fails instead of panicking.

Similar to Self::connect_closure but fails instead of panicking.

Connect a closure to the signal signal_name on this object. Read more

Similar to Self::connect_closure_id but fails instead of panicking.

Connect a closure to the signal signal_id on this object. Read more

Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more

Connect to the signal signal_id on this object. Read more

Similar to Self::emit but fails instead of panicking.

Emit signal by signal id. Read more

Similar to Self::emit_with_values but fails instead of panicking.

Same as Self::emit but takes Value for the arguments.

Similar to Self::emit_by_name but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_values but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_details but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_by_name_with_details_and_values but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_with_details but fails instead of panicking.

Emit signal by signal id with details. Read more

Similar to Self::emit_with_details_and_values but fails instead of panicking.

Emit signal by signal id with details. Read more

Disconnect a previously connected signal handler.

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Notify that the given property has changed its value. Read more

Notify that the given property has changed its value. Read more

Downgrade this object to a weak reference.

Add a callback to be notified when the Object is disposed.

Add a callback to be notified when the Object is disposed. Read more

Bind property source_property on this object to the target_property on the target object. Read more

Returns the strong reference count of this object.

Ensures that the type has been registered with the type system.

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)

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

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.