Expand description
use glyph_brush::{ab_glyph::FontArc, BrushAction, BrushError, GlyphBrushBuilder, Section, Text};

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

glyph_brush.queue(Section::default().add_text(Text::new("Hello glyph_brush")));

match glyph_brush.process_queued(
    |rect, tex_data| update_texture(rect, tex_data),
    |vertex_data| into_vertex(vertex_data),
) {
    Ok(BrushAction::Draw(vertices)) => {
        // Draw new vertices.
    Ok(BrushAction::ReDraw) => {
        // Re-draw last frame's vertices unmodified.
    Err(BrushError::TextureTooSmall { suggested }) => {
        // Enlarge texture + glyph_brush texture cache and retry.


Re-exported ab_glyph types.


Macro to delegate builder methods to an inner glyph_brush::GlyphBrushBuilder


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.

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

Data used to generate vertex information for a single glyph

A rectangle, with top-left corner at min, and bottom-right corner at max.

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.


Actions that should be taken after processing queue data

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.


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.

Type Definitions

A “practically collision free” Section hasher

SectionGlyph iterator.