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.
- GPU cache logic to dynamically maintain a GPU texture of rendered glyphs.
Example
extern crate gfx_glyph; use gfx_glyph::{Section, GlyphBrushBuilder}; let arial: &[u8] = include_bytes!("../examples/Arial Unicode.ttf"); let mut glyph_brush = GlyphBrushBuilder::using_font_bytes(arial) .build(gfx_factory.clone()); let section = Section { text: "Hello gfx_glyph", ..Section::default() }; glyph_brush.queue(section); glyph_brush.queue(some_other_section); glyph_brush.draw_queued(&mut gfx_encoder, &gfx_color, &gfx_depth).unwrap();
Structs
FontId |
Id for a font, the default |
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 |
GlyphedSectionText | |
Section |
An object that contains all the info to render a section of text. |
SectionGlyphInfo | |
SectionText | |
VariedSection |
An object that contains all the info to render a varied section of text. That is one including many parts with differing fonts/scales/colors bowing to a single layout. |
Enums
BuiltInLineBreaker | |
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. |
VerticalAlign |
Describes vertical alignment preference for positioning & bounds. Currently a placeholder for future functionality. |
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 |
GlyphId |
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 |
PositionedGlyphIter |
An iterator over |
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 |