Crate gfx_glyph [−] [src]
Fast GPU cached text rendering using gfx-rs & rusttype.
Makes use of three kinds of caching to optimise frame performance.
- Caching of glyph positioning output to avoid repeated cost of identical text rendering on sequential frames.
- Caches draw calculations to avoid repeated cost of identical text rendering on sequential frames.
- Uses rusttype's built-in GPU cache logic to maintain a GPU texture of rendered glyphs.
Example
extern crate gfx_glyph; use gfx_glyph::{Section, Layout, GlyphBrushBuilder}; let arial = include_bytes!("examples/Arial Unicode.ttf"); let mut glyph_brush = GlyphBrushBuilder::using_font(arial) .build(gfx_factory.clone()); let section = Section { text: "Hello gfx_glyph", ..Section::default() }; glyph_brush.queue(section, &Layout::default()); glyph_brush.queue(some_other_section, &Layout::default()); glyph_brush.draw_queued(&mut gfx_encoder, &gfx_target).unwrap();
Structs
GlyphBrush |
Object allowing glyph drawing, containing cache state. Manages glyph positioning cacheing, glyph draw caching & efficient GPU texture cache updating and re-sizing on demand. |
GlyphBrushBuilder |
Builder for a |
GlyphInfo |
A specialised view on a |
OwnedSection |
A section with owned text. See |
Section |
An object that, along with the |
StaticSection |
A section with a static str reference, equalent to Section<'static>
but may avoid edge case compile issues. See |
Enums
GlyphGroup |
Built-in |
HorizontalAlign |
Describes horizontal alignment preference for positioning & bounds. |
Layout |
Built-in |
LayoutLeftover |
Container for glyphs leftover/unable to fit in a layout and/or within render bounds |
Traits
GlyphGrouper |
Logic to link glyphs/characters together as a group for the purposes of wrapping. |
GlyphPositioner |
Logic to calculate glyph positioning based on |
Type Definitions
Font |
Aliased type to allow lib usage without declaring underlying rusttype lib |
Glyph |
Aliased type to allow lib usage without declaring underlying rusttype lib |
Point |
Aliased type to allow lib usage without declaring underlying rusttype lib |
PositionedGlyph |
Aliased type to allow lib usage without declaring underlying rusttype lib |
Rect |
Aliased type to allow lib usage without declaring underlying rusttype lib |
Scale |
Aliased type to allow lib usage without declaring underlying rusttype lib |
ScaledGlyph |
Aliased type to allow lib usage without declaring underlying rusttype lib |