[][src]Trait glyph_brush::GlyphCruncher

pub trait GlyphCruncher<'font> {
    fn pixel_bounds_custom_layout<'a, S, L>(
        &mut self,
        section: S,
        custom_layout: &L
    ) -> Option<Rect<i32>>
    where
        L: GlyphPositioner + Hash,
        S: Into<Cow<'a, VariedSection<'a>>>
;
fn glyphs_custom_layout<'a, 'b, S, L>(
        &'b mut self,
        section: S,
        custom_layout: &L
    ) -> PositionedGlyphIter<'b, 'font>
    where
        L: GlyphPositioner + Hash,
        S: Into<Cow<'a, VariedSection<'a>>>
;
fn fonts(&self) -> &[Font<'font>]; fn pixel_bounds<'a, S>(&mut self, section: S) -> Option<Rect<i32>>
    where
        S: Into<Cow<'a, VariedSection<'a>>>
, { ... }
fn glyphs<'a, 'b, S>(
        &'b mut self,
        section: S
    ) -> PositionedGlyphIter<'b, 'font>
    where
        S: Into<Cow<'a, VariedSection<'a>>>
, { ... }
fn glyph_bounds_custom_layout<'a, S, L>(
        &mut self,
        section: S,
        custom_layout: &L
    ) -> Option<Rect<f32>>
    where
        L: GlyphPositioner + Hash,
        S: Into<Cow<'a, VariedSection<'a>>>
, { ... }
fn glyph_bounds<'a, S>(&mut self, section: S) -> Option<Rect<f32>>
    where
        S: Into<Cow<'a, VariedSection<'a>>>
, { ... } }

Common glyph layout logic.

Example

use glyph_brush::GlyphCruncher;

let default_font = glyph_brush.fonts()[0];

Required methods

fn pixel_bounds_custom_layout<'a, S, L>(
    &mut self,
    section: S,
    custom_layout: &L
) -> Option<Rect<i32>> where
    L: GlyphPositioner + Hash,
    S: Into<Cow<'a, VariedSection<'a>>>, 

Returns the pixel bounding box for the input section using a custom layout. The box is a conservative whole number pixel rectangle that can contain the section.

If the section is empty or would result in no drawn glyphs will return None.

glyphs_custom_layout should be preferred if the bounds are to be used to inform further layout logic.

Benefits from caching, see caching behaviour.

fn glyphs_custom_layout<'a, 'b, S, L>(
    &'b mut self,
    section: S,
    custom_layout: &L
) -> PositionedGlyphIter<'b, 'font> where
    L: GlyphPositioner + Hash,
    S: Into<Cow<'a, VariedSection<'a>>>, 

Returns an iterator over the PositionedGlyphs of the given section with a custom layout.

Generally only drawable glyphs will be returned as invisible glyphs, like spaces, are discarded during layout.

Benefits from caching, see caching behaviour.

Important traits for &'_ mut [u8]
fn fonts(&self) -> &[Font<'font>]

Returns the available fonts.

The FontId corresponds to the index of the font data.

Loading content...

Provided methods

fn pixel_bounds<'a, S>(&mut self, section: S) -> Option<Rect<i32>> where
    S: Into<Cow<'a, VariedSection<'a>>>, 

Returns the pixel bounding box for the input section. The box is a conservative whole number pixel rectangle that can contain the section.

If the section is empty or would result in no drawn glyphs will return None.

glyph_bounds should be preferred if the bounds are to be used to inform further layout logic.

Benefits from caching, see caching behaviour.

fn glyphs<'a, 'b, S>(&'b mut self, section: S) -> PositionedGlyphIter<'b, 'font> where
    S: Into<Cow<'a, VariedSection<'a>>>, 

Returns an iterator over the PositionedGlyphs of the given section.

Generally only drawable glyphs will be returned as invisible glyphs, like spaces, are discarded during layout.

Benefits from caching, see caching behaviour.

fn glyph_bounds_custom_layout<'a, S, L>(
    &mut self,
    section: S,
    custom_layout: &L
) -> Option<Rect<f32>> where
    L: GlyphPositioner + Hash,
    S: Into<Cow<'a, VariedSection<'a>>>, 

Returns a bounding box for the section glyphs calculated using each glyph's vertical & horizontal metrics.

If the section is empty or would result in no drawn glyphs will return None.

Invisible glyphs, like spaces, are discarded during layout so trailing ones will not affect the bounds.

The bounds will always lay within the specified layout bounds, ie that returned by the layout's bounds_rect function.

Benefits from caching, see caching behaviour.

fn glyph_bounds<'a, S>(&mut self, section: S) -> Option<Rect<f32>> where
    S: Into<Cow<'a, VariedSection<'a>>>, 

Returns a bounding box for the section glyphs calculated using each glyph's vertical & horizontal metrics.

If the section is empty or would result in no drawn glyphs will return None.

Invisible glyphs, like spaces, are discarded during layout so trailing ones will not affect the bounds.

The bounds will always lay within the specified layout bounds, ie that returned by the layout's bounds_rect function.

Benefits from caching, see caching behaviour.

Loading content...

Implementors

impl<'font, '_, H: BuildHasher> GlyphCruncher<'font> for GlyphCalculatorGuard<'_, 'font, H>[src]

impl<'font, V, H> GlyphCruncher<'font> for GlyphBrush<'font, V, H> where
    V: Clone + 'static,
    H: BuildHasher
[src]

Loading content...