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")));
glyph_brush.queue(some_other_section);
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.
}
}
Modules§
Macros§
- delegate_
glyph_ brush_ builder_ fns - Macro to delegate builder methods to an inner
glyph_brush::GlyphBrushBuilder
Structs§
- Extra
- Default
extra
field type. Non-layout data for vertex generation. - FontId
- Id for a font.
- Glyph
Brush - Object allowing glyph drawing, containing cache state. Manages glyph positioning caching, glyph draw caching & efficient GPU texture cache updating.
- Glyph
Brush Builder - Builder for a
GlyphBrush
. - Glyph
Calculator - Cut down version of a
GlyphBrush
that can calculate pixel bounds, but is unable to actually render anything. - Glyph
Calculator Builder - Builder for a
GlyphCalculator
. - Glyph
Calculator Guard GlyphCalculator
scoped cache lock.- Glyph
Vertex - Data used to generate vertex information for a single glyph
- Owned
Section - Owned
Text - Rectangle
- A rectangle, with top-left corner at min, and bottom-right corner at max.
Both field are in
[offset from left, offset from top]
format. - Section
- 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.
- Section
Builder Section
builder.- Section
Geometry - Section
Glyph - A positioned glyph with info relating to the
SectionText
(or glyph_brushSection::text
) from which it was derived. - Section
Text - Text to layout together using a font & scale.
- Text
SectionText
+ extra.
Enums§
- Brush
Action - Actions that should be taken after processing queue data
- Brush
Error - Built
InLine Breaker - Built-in linebreaking logic.
- Glyph
Change - Horizontal
Align - Describes horizontal alignment preference for positioning & bounds.
- Layout
- Built-in
GlyphPositioner
implementations. - Line
Break - Indicator that a character is a line break, soft or hard. Includes the offset (byte-index) position.
- Vertical
Align - Describes vertical alignment preference for positioning & bounds. Currently a placeholder for future functionality.
Traits§
- Glyph
Cruncher - Common glyph layout logic.
- Glyph
Positioner - Logic to calculate glyph positioning using
Font
,SectionGeometry
andSectionText
. - Line
Breaker - Producer of a
LineBreak
iterator. Used to allow to theLayout
to be line break aware in a generic way. - ToSection
Text
Type Aliases§
- Color
- Default
Section Hasher - A “practically collision free”
Section
hasher - Section
Glyph Iter SectionGlyph
iterator.