Documentation menu

Text, Editing, and Fonts

Keep font selection, shaping, layout, editing semantics, and glyph raster resources consistent across process boundaries.

A text view depends on work performed at several layers of the platform. hera-font registers faces, and hera-text uses those faces to shape, measure, and edit content. Kit builds the resulting views and controls into its client tree, after which the server renderer prepares glyph resources and draws the submitted runs.

Font Registration Consistency

A font key connects a client's shaped run with the face used by the server to draw it. That connection is valid only when both processes use the same font bytes, since a glyph ID from another face can identify a different outline. Supply the same HERA_FONT_REGISTRY and assets to participating processes before startup.

The manifest resolves asset paths relative to its own location, so deployment needs to preserve that layout. Keys 0 and 1 remain reserved for the configured default and embedded UI regular face. Additional weighted registrations can refer to a family's regular key, allowing family weight selection to use real registered faces rather than synthetic emboldening.

Text Shaping

Shaping turns the string and typography settings into glyph selection, advances, offsets, direction, and line layout. By the time that content becomes a wire TextRun, it already contains positioned glyph instances. The server uses those positions and font parameters rather than repeating the toolkit's text layout algorithm.

Screen coordinates use right-positive x and down-positive y. Font-space offsets must be converted consistently before encoding glyph placement.

Width-Constrained Measurement

Kit text measurements depend on available width, configured line policy, direction, alignment, and font metrics. Text fields reflow under the actual accepted viewport width and recompute caret and selection geometry together.

Changing a font or wrapping policy can affect both layout size and glyph positions. Caching must include all relevant shaping inputs.

Editing Model

Editing introduces state beyond the displayed string. EditBuffer keeps committed text, logical selection, preedit, formatting, and undo/redo within the shared text input limit. Navigation uses grapheme and shaped caret stops so that logical byte or scalar boundaries are not mistaken for every valid visual caret location.

During composition, committed selection and text remain stable while the display projection substitutes preedit. A text input service is separate from keyboard layout interpretation and server surface focus.

Server Glyph Resources

After a frame passes graph admission, the renderer resolves the glyph resources it needs and uploads atlas content. Any resources referenced by its command buffers must remain alive until completion. If submission fails, preparation and accepted image history must remain consistent so a later retry can still produce the intended text.

See text, text_field, and renderer.

Source Reference

The following files in the Hera checkout define the behavior described on this page.

  • crates/font/src/registry.rs
  • crates/text/src/shaping.rs
  • crates/text/src/editing.rs
  • crates/kit/src/text/cache.rs
  • crates/renderer/src/vulkan/glyph.rs