Crate gfx_glyph

source ·
Expand description

Fast GPU cached text rendering using gfx-rs & ab_glyph.

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

use gfx_glyph::{ab_glyph::FontArc, GlyphBrushBuilder, Section, Text};

let dejavu = FontArc::try_from_slice(include_bytes!("../../fonts/DejaVuSans.ttf"))?;
let mut glyph_brush = GlyphBrushBuilder::using_font(dejavu).build(gfx_factory.clone());

let section = Section::default().add_text(Text::new("Hello gfx_glyph"));

glyph_brush.queue(section);
glyph_brush.queue(some_other_section);

glyph_brush.use_queue().draw(&mut gfx_encoder, &gfx_color)?;

Modules

Re-exported ab_glyph types.

Structs

Short-lived builder for drawing glyphs, constructed from GlyphBrush::use_queue.
Default extra field type. Non-layout data for vertex generation.
Id for a font.
Object allowing glyph drawing, containing cache state. Manages glyph positioning cacheing, glyph draw caching & efficient GPU texture cache updating and re-sizing on demand.
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.
A positioned glyph with info relating to the SectionText from which it was derived.
Text to layout together using a font & scale.
SectionText + extra.

Enums

Built-in linebreaking logic.
Describes horizontal alignment preference for positioning & bounds.
Built-in GlyphPositioner implementations.
Indicator that a character is a line break, soft or hard. Includes the offset (byte-index) position.
Describes vertical alignment preference for positioning & bounds. Currently a placeholder for future functionality.

Traits

Common glyph layout logic.
Logic to calculate glyph positioning using Font, SectionGeometry and SectionText.
Producer of a LineBreak iterator. Used to allow to the Layout to be line break aware in a generic way.

Functions

Returns the default 4 dimensional matrix orthographic projection used for drawing.

Type Definitions

SectionGlyph iterator.