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.
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.
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.
pub fn metrics(
&self,
desc: Option<&FontDescription>,
language: Option<&Language>
) -> Option<FontMetrics>
pub fn metrics(
&self,
desc: Option<&FontDescription>,
language: Option<&Language>
) -> Option<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 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.
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.
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
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.
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
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
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for Context
impl UnwindSafe for Context
Blanket Implementations
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 true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
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.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,