[−][src]Struct glyph_brush::GlyphCalculator
Cut down version of a GlyphBrush
that can calculate pixel bounds,
but is unable to actually render anything.
Build using a GlyphCalculatorBuilder
.
Example
use glyph_brush::{GlyphCalculatorBuilder, GlyphCruncher, Section}; let dejavu: &[u8] = include_bytes!("../../fonts/DejaVuSans.ttf"); let glyphs = GlyphCalculatorBuilder::using_font_bytes(dejavu).build(); let section = Section { text: "Hello glyph_brush", ..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 when a section is used / 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
draws. Section calculations are cached for the next
'cache frame', if not used then they will be dropped.
Methods
impl<'font, H: BuildHasher + Clone> GlyphCalculator<'font, H>
[src][−]
pub fn cache_scope<'a>(&'a self) -> GlyphCalculatorGuard<'a, 'font, H>
[src]
pub fn fonts(&self) -> &[Font]
[src][−]
Returns the available fonts.
The FontId
corresponds to the index of the font data.
Trait Implementations
impl<'_, H> Debug for GlyphCalculator<'_, H>
[src][+]
Auto Trait Implementations
impl<'font, H> Unpin for GlyphCalculator<'font, H> where
H: Unpin,
H: Unpin,
impl<'font, H> Sync for GlyphCalculator<'font, H> where
H: Sync,
H: Sync,
impl<'font, H> Send for GlyphCalculator<'font, H> where
H: Send,
H: Send,
impl<'font, H> UnwindSafe for GlyphCalculator<'font, H> where
H: UnwindSafe,
H: UnwindSafe,
impl<'font, H> RefUnwindSafe for GlyphCalculator<'font, H> where
H: RefUnwindSafe,
H: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src][+]
V: MultiLane<T>,