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(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

AnyCharLineBreaker

LineBreaker that soft breaks on any character, and hard breaks similarly to StandardLineBreaker.

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 GlyphBrush.

GlyphInfo

A specialised view on a Section for the purposes of calculating glyph positions. Used by a GlyphPositioner.

Section

An object that, along with the GlyphPositioner, contains all the info to render a section of text.

StandardLineBreaker

LineBreaker that follows Unicode Standard Annex #14. That effectively means it wraps words in a way that should work for most cases.

Enums

HorizontalAlign

Describes horizontal alignment preference for positioning & bounds.

Layout

Built-in GlyphPositioner implementations.

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 Font and GlyphInfo

LineBreaker

Producer of a LineBreak iterator. Used to allow to the Layout to be line break aware in a generic way.

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

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