Struct rusttype::Font [] [src]

pub struct Font<'a> { /* fields omitted */ }

A single font. This may or may not own the font data.

Methods

impl<'a> Font<'a>
[src]

[src]

The "vertical metrics" for this font at a given scale. These metrics are shared by all of the glyphs in the font. See VMetrics for more detail.

[src]

Get the unscaled VMetrics for this font, shared by all glyphs. See VMetrics for more detail.

[src]

Returns the units per EM square of this font

[src]

The number of glyphs present in this font. Glyph identifiers for this font will always be in the range 0..self.glyph_count()

[src]

Returns the corresponding glyph for a Unicode code point or a glyph id for this font. If id corresponds to a glyph identifier, the identifier must be valid (smaller than self.glyph_count()), otherwise None is returned.

Note that code points without corresponding glyphs in this font map to the "undef" glyph, glyph 0.

[src]

A convenience function.

Returns an iterator that produces the glyphs corresponding to the code points or glyph ids produced by the given iterator itr.

This is equivalent in behaviour to itr.map(|c| font.glyph(c).unwrap()).

[src]

A convenience function for laying out glyphs for a string horizontally. It does not take control characters like line breaks into account, as treatment of these is likely to depend on the application.

Note that this function does not perform Unicode normalisation. Composite characters (such as ö constructed from two code points, ¨ and o), will not be normalised to single code points. So if a font does not contain a glyph for each separate code point, but does contain one for the normalised single code point (which is common), the desired glyph will not be produced, despite being present in the font. Deal with this by performing Unicode normalisation on the input string before passing it to layout. The crate unicode-normalization is perfect for this purpose.

Calling this function is equivalent to a longer sequence of operations involving glyphs_for, e.g.

font.layout("Hello World!", scale, start)

produces an iterator with behaviour equivalent to the following:

font.glyphs_for("Hello World!".chars())
    .scan((None, 0.0), |&mut (mut last, mut x), g| {
        let g = g.scaled(scale);
        let w = g.h_metrics().advance_width
            + last.map(|last| font.pair_kerning(scale, last, g.id())).unwrap_or(0.0);
        let next = g.positioned(start + vector(x, 0.0));
        last = Some(next.id());
        x += w;
        Some(next)
    })

[src]

Returns additional kerning to apply as well as that given by HMetrics for a particular pair of glyphs.

Trait Implementations

impl<'a> Clone for Font<'a>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more