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 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).unwrap();

Structs

FontId

Id for a font, the default FontId(0) will always be present in a GlyphBrush

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.

GlyphCalculator

Cut down version of a GlyphBrush that can calculate pixel bounds, but is unable to actually render anything.

GlyphCalculatorBuilder

Builder for a GlyphCalculator.

GlyphCalculatorGuard

GlyphCalculator scoped cache lock.

GlyphInfo

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

GlyphedSectionText
OwnedSectionText
OwnedVariedSection
RemainingNormCharIndices

char_indices style iterator for skipped normalized chars

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

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 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 [
Deprecated
]

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 PositionedGlyphs from the GlyphBrush

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