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: &[u8] = 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
AnyCharLineBreaker |
|
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 |
StandardLineBreaker |
|
StaticSection |
A section with a static str reference, equalent to Section<'static>
but may avoid edge case compile issues. See |
Enums
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 |
LineBreak |
Indicator that a character is a line break, soft or hard. Includes the offset position. |
Traits
GlyphPositioner |
Logic to calculate glyph positioning based on |
LineBreaker |
Producer of a |
Functions
font |
Returns a Font from font bytes info or an error reason. |
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 |
HMetrics |
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 |
SharedBytes |
Aliased type to allow lib usage without declaring underlying rusttype lib |
VMetrics |
Aliased type to allow lib usage without declaring underlying rusttype lib |