Trait pango::prelude::FontMapExt

source ·
pub trait FontMapExt: 'static {
    // Required methods
    fn changed(&self);
    fn create_context(&self) -> Option<Context>;
    fn family(&self, name: &str) -> Option<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>;
}
Expand description

Trait containing all FontMap methods.

Implementors

FontMap

Required Methods§

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

Implementors§