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::{GlyphBrushBuilder, Section}; let dejavu: &[u8] = include_bytes!("../examples/DejaVuSans.ttf"); let mut glyph_brush = GlyphBrushBuilder::using_font_bytes(dejavu).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)?;
Structs
Font |
A single font. This may or may not own the font data. |
FontId |
Id for a font, the default |
Glyph |
A single glyph of a font. this may either be a thin wrapper referring to the font and the glyph id, or it may be a standalone glyph that owns the data needed by it. |
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 |
GlyphCalculator |
Cut down version of a |
GlyphCalculatorBuilder |
Builder for a |
GlyphCalculatorGuard |
|
GlyphId |
Represents a glyph identifier for a particular font. This identifier will not necessarily correspond to the correct glyph in a font other than the one that it was obtained from. |
HMetrics |
The "horizontal metrics" of a glyph. This is useful for calculating the horizontal offset of a glyph from the previous one in a string when laying a string out horizontally. |
OwnedSectionText | |
OwnedVariedSection | |
Point |
A point in 2-dimensional space, with each dimension of type |
PositionedGlyph |
A glyph augmented with positioning and scaling information. You can query such a glyph for information that depends on the scale and position of the glyph. |
Rect |
A rectangle, with top-left corner at |
Scale |
Defines the size of a rendered face of a font, in pixels, horizontally and
vertically. A vertical scale of |
ScaledGlyph |
A glyph augmented with scaling information. You can query such a glyph for information that depends on the scale of the glyph. |
Section |
An object that contains all the info to render a section of text. |
SectionText | |
VMetrics |
The "vertical metrics" of a font at a particular scale. This is useful for calculating the amount of vertical space to give a line of text, and for computing the vertical offset between successive lines. |
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 |
LineBreak |
Indicator that a character is a line break, soft or hard. Includes the offset (byte-index) position. |
SharedBytes |
|
VerticalAlign |
Describes vertical alignment preference for positioning & bounds. Currently a placeholder for future functionality. |
Traits
GlyphCruncher |
Common glyph layout logic. |
GlyphPositioner |
Logic to calculate glyph positioning based on |
LineBreaker |
Producer of a |
Type Definitions
FontMap | |
PositionedGlyphIter |
|