Struct gfx_glyph::GlyphCalculator [] [src]

pub struct GlyphCalculator<'font> { /* fields omitted */ }

Cut down version of a GlyphBrush that can calculate pixel bounds, but is unable to actually render anything.

Build using a GlyphCalculatorBuilder.

Example

extern crate gfx_glyph;
use gfx_glyph::{GlyphCruncher, GlyphCalculatorBuilder, Section};

let dejavu: &[u8] = include_bytes!("../examples/DejaVuSans.ttf");
let glyphs = GlyphCalculatorBuilder::using_font_bytes(dejavu).build();

let section = Section {
    text: "Hello gfx_glyph",
    ..Section::default()
};

// create the scope, equivalent to a lock on the cache when
// dropped will clean unused cached calculations like a draw call
let mut scope = glyphs.cache_scope();

let bounds = scope.pixel_bounds(section);

Caching behaviour

Calls to GlyphCalculatorGuard::pixel_bounds, GlyphCalculatorGuard::glyphs calculate the positioned glyphs for a section. This is cached so future calls to any of the methods for the same section are much cheaper.

Unlike a GlyphBrush there is no concept of actually drawing the section to imply a section is no longer used. Instead a GlyphCalculatorGuard is created, that provides the calculation functionality. Dropping indicates the 'cache frame' is over, similar to when a GlyphBrush is draws. Any cached sections from previous 'frames' are invalidated.

Methods

impl<'font> GlyphCalculator<'font>
[src]

[src]

Trait Implementations

impl<'font> Debug for GlyphCalculator<'font>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'font> Send for GlyphCalculator<'font>

impl<'font> Sync for GlyphCalculator<'font>