Skip to main content

Crate text_typeset

Crate text_typeset 

Source
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

Modules§

atlas
bridge
Bridge between text-document snapshot types and text-typeset layout params.
font
layout
shaping

Structs§

BlockVisualInfo
Visual position and size of a laid-out block.
CursorDisplay
Cursor display state for rendering.
DecorationRect
A colored rectangle for decorations (underlines, selections, borders, etc.).
FontFaceId
Opaque handle to a registered font face.
GlyphQuad
A positioned glyph to draw as a textured quad from the atlas.
HitTestResult
Result of crate::Typesetter::hit_test - maps a screen-space point to a document position.
ImageQuad
An inline image placeholder.
RenderFrame
Everything needed to draw one frame.
Typesetter
The main entry point for text typesetting.

Enums§

ContentWidthMode
How the content (layout) width is determined.
DecorationKind
The type of a DecorationRect.
HitRegion
What region of the layout a hit test landed in.