Expand description
§text-typeset
Turns rich text documents into GPU-ready glyph quads.
Typesetting crate for the text-document ecosystem. Takes a rich text
document model (styled paragraphs, tables, lists, frames) and produces
positioned glyph quads, decoration rectangles, and a glyph atlas texture
that any GPU framework can render in a few draw calls.
text-document (model) --> text-typeset (shaping + layout) --> framework adapter (rendering)§Quick start
use text_typeset::Typesetter;
let mut ts = Typesetter::new();
let font = ts.register_font(include_bytes!("../test-fonts/NotoSans-Variable.ttf"));
ts.set_default_font(font, 16.0);
ts.set_viewport(800.0, 600.0);
// With text-document (default feature):
let doc = text_document::TextDocument::new();
doc.set_plain_text("Hello, world!").unwrap();
ts.layout_full(&doc.snapshot_flow());
let frame = ts.render();
// frame.glyphs -> glyph quads (textured rects from atlas)
// frame.atlas_pixels -> RGBA texture to upload
// frame.decorations -> cursor, selection, underlines, borders§Features
text-document(default) : enablesbridgemodule andTypesetter::layout_fullfor direct integration with text-document’sFlowSnapshot.
Modules§
- atlas
- bridge
- Bridge between text-document snapshot types and text-typeset layout params.
- font
- layout
- shaping
Structs§
- Block
Visual Info - Visual position and size of a laid-out block.
- Cursor
Display - Cursor display state for rendering.
- Decoration
Rect - A colored rectangle for decorations (underlines, selections, borders, etc.).
- Font
Face Id - Opaque handle to a registered font face.
- Glyph
Quad - A positioned glyph to draw as a textured quad from the atlas.
- HitTest
Result - Result of
crate::Typesetter::hit_test- maps a screen-space point to a document position. - Image
Quad - An inline image placeholder.
- Render
Frame - Everything needed to draw one frame.
- Typesetter
- The main entry point for text typesetting.
Enums§
- Content
Width Mode - How the content (layout) width is determined.
- Decoration
Kind - The type of a
DecorationRect. - HitRegion
- What region of the layout a hit test landed in.