pango::prelude

Trait FontMapExt

Source
pub trait FontMapExt:
    IsA<FontMap>
    + Sealed
    + 'static {
    // Provided methods
    fn add_font_file(&self, filename: impl AsRef<Path>) -> Result<(), Error> { ... }
    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 { ... }
}
Expand description

Trait containing all FontMap methods.

§Implementors

FontMap

Provided Methods§

Source

fn add_font_file(&self, filename: impl AsRef<Path>) -> Result<(), Error>

Available on crate feature v1_56 only.

Loads a font file with one or more fonts into the FontMap.

The added fonts will take precedence over preexisting fonts with the same name.

§filename

Path to the font file

§Returns

True if the font file is successfully loaded into the fontmap, false if an error occurred.

Source

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.

Source

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

Source

fn family(&self, name: &str) -> FontFamily

Available on crate feature v1_46 only.

Gets a font family by name.

§name

a family name

§Returns

the FontFamily

Source

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.

Source

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

Source

fn load_font(&self, context: &Context, desc: &FontDescription) -> Option<Font>

Load the font in the fontmap that is the closest match for @desc.

§context

the Context the font will be used with

§desc

a FontDescription describing the font to load

§Returns

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

Source

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.

Source

fn reload_font( &self, font: &impl IsA<Font>, scale: f64, context: Option<&Context>, variations: Option<&str>, ) -> Font

Available on crate feature 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.

Implementors§