pub trait FontMapExt: IsA<FontMap> + 'static {
// Provided methods
fn changed(&self) { ... }
fn create_context(&self) -> Context { ... }
fn family(&self, name: &str) -> FontFamily { ... }
fn serial(&self) -> u32 { ... }
fn list_families(&self) -> Vec<FontFamily> { ... }
fn load_font(
&self,
context: &Context,
desc: &FontDescription,
) -> Option<Font> { ... }
fn load_fontset(
&self,
context: &Context,
desc: &FontDescription,
language: &Language,
) -> Option<Fontset> { ... }
fn reload_font(
&self,
font: &impl IsA<Font>,
scale: f64,
context: Option<&Context>,
variations: Option<&str>,
) -> Font { ... }
}
Provided Methods§
Sourcefn changed(&self)
fn changed(&self)
Forces a change in the context, which will cause any Context
using this fontmap to change.
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.
Sourcefn create_context(&self) -> Context
fn create_context(&self) -> Context
Creates a Context
connected to @self.
This is equivalent to Context::new()
followed by
Context::set_font_map()
.
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().
Sourcefn family(&self, name: &str) -> FontFamily
Available on crate feature v1_46
only.
fn family(&self, name: &str) -> FontFamily
v1_46
only.Sourcefn serial(&self) -> u32
fn serial(&self) -> u32
Returns the current serial number of @self.
The serial number is initialized to an small number larger than zero when a new fontmap is created and is increased whenever the fontmap is changed. It may wrap, but will never have the value 0. Since it can wrap, never compare it with “less than”, always use “not equals”.
The fontmap can only be changed using backend-specific API, like changing fontmap resolution.
This can be used to automatically detect changes to a FontMap
,
like in Context
.
§Returns
The current serial number of @self.
Sourcefn list_families(&self) -> Vec<FontFamily>
fn list_families(&self) -> Vec<FontFamily>
List all families for a fontmap.
Note that the returned families are not in any particular order.
FontMap
also implemented the [gio::ListModel
][crate::gio::ListModel] interface
for enumerating families.
§Returns
§families
location to
store a pointer to an array of FontFamily
*.
This array should be freed with g_free().
Sourcefn load_fontset(
&self,
context: &Context,
desc: &FontDescription,
language: &Language,
) -> Option<Fontset>
fn load_fontset( &self, context: &Context, desc: &FontDescription, language: &Language, ) -> Option<Fontset>
Load a set of fonts in the fontmap that can be used to render a font matching @desc.
§context
the Context
the font will be used with
§desc
a FontDescription
describing the font to load
§language
a Language
the fonts will be used for
§Returns
the newly allocated
Fontset
loaded, or None
if no font matched.
Sourcefn reload_font(
&self,
font: &impl IsA<Font>,
scale: f64,
context: Option<&Context>,
variations: Option<&str>,
) -> Font
Available on crate feature v1_52
only.
fn reload_font( &self, font: &impl IsA<Font>, scale: f64, context: Option<&Context>, variations: Option<&str>, ) -> Font
v1_52
only.Returns a new font that is like @font, except that its size is multiplied by @scale, its backend-dependent configuration (e.g. cairo font options) is replaced by the one in @context, and its variations are replaced by @variations.
§font
a font in @self
§scale
the scale factor to apply
§context
a Context
§variations
font variations to use
§Returns
the modified font
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.