Trait pango::prelude::FontExt

source ·
pub trait FontExt: 'static {
    // Required methods
    fn describe(&self) -> FontDescription;
    fn describe_with_absolute_size(&self) -> FontDescription;
    fn coverage(&self, language: &Language) -> Coverage;
    fn face(&self) -> FontFace;
    fn font_map(&self) -> Option<FontMap>;
    fn glyph_extents(&self, glyph: Glyph) -> (Rectangle, Rectangle);
    fn metrics(&self, language: Option<&Language>) -> FontMetrics;
    fn has_char(&self, wc: char) -> bool;
    fn serialize(&self) -> Bytes;
}
Expand description

Trait containing all Font methods.

Implementors

Font

Required Methods§

source

fn describe(&self) -> FontDescription

Returns a description of the font, with font size set in points.

Use describe_with_absolute_size() if you want the font size in device units.

Returns

a newly-allocated FontDescription object.

source

fn describe_with_absolute_size(&self) -> FontDescription

Returns a description of the font, with absolute font size set in device units.

Use describe() if you want the font size in points.

Returns

a newly-allocated FontDescription object.

source

fn coverage(&self, language: &Language) -> Coverage

Computes the coverage map for a given font and language tag.

language

the language tag

Returns

a newly-allocated Coverage object.

source

fn face(&self) -> FontFace

Available on crate feature v1_46 only.

Gets the FontFace to which @self belongs.

Returns

the FontFace

source

fn font_map(&self) -> Option<FontMap>

Gets the font map for which the font was created.

Note that the font maintains a weak reference to the font map, so if all references to font map are dropped, the font map will be finalized even if there are fonts created with the font map that are still alive. In that case this function will return None.

It is the responsibility of the user to ensure that the font map is kept alive. In most uses this is not an issue as a Context holds a reference to the font map.

Returns

the FontMap for the font

source

fn glyph_extents(&self, glyph: Glyph) -> (Rectangle, Rectangle)

Gets the logical and ink extents of a glyph within a font.

The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros PANGO_ASCENT(), PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit.

If @self is None, this function gracefully sets some sane values in the output variables and returns.

glyph

the glyph index

Returns
ink_rect

rectangle used to store the extents of the glyph as drawn

logical_rect

rectangle used to store the logical extents of the glyph

source

fn metrics(&self, language: Option<&Language>) -> FontMetrics

Gets overall metric information for a font.

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.

If @self is None, this function gracefully sets some sane values in the output variables and returns.

language

language tag used to determine which script to get the metrics for, or None to indicate to get the metrics for the entire font.

Returns

a FontMetrics object. The caller must call Pango::FontMetrics::unref() when finished using the object.

source

fn has_char(&self, wc: char) -> bool

Available on crate feature v1_44 only.

Returns whether the font provides a glyph for this character.

wc

a Unicode character

Returns

TRUE if @self can render @wc

source

fn serialize(&self) -> Bytes

Available on crate feature v1_50 only.

Serializes the @self in a way that can be uniquely identified.

There are no guarantees about the format of the output across different versions of Pango.

The intended use of this function is testing, benchmarking and debugging. The format is not meant as a permanent storage format.

To recreate a font from its serialized form, use Font::deserialize().

Returns

a GBytes containing the serialized form of @self

Implementors§

source§

impl<O: IsA<Font>> FontExt for O