Per-context font store, HarfBuzz shaper, FreeType glyph atlas, and layout engine.
More...
|
|
| TextEngine (const TextEngine &)=delete |
|
TextEngine & | operator= (const TextEngine &)=delete |
|
| TextEngine (TextEngine &&) noexcept |
|
TextEngine & | operator= (TextEngine &&) noexcept |
|
FontHandle | loadFont (std::string_view name, std::string_view path) |
| | Load a TTF/OTF font file from disk under logical name.
|
|
FontHandle | loadFontFromMemory (std::string_view name, const void *data, size_t size) |
| | Load a TTF/OTF font from an in-memory buffer under logical name (copies bytes).
|
|
void | unloadFont (std::string_view name) |
| | Unload a font by logical name and invalidate layout caches.
|
|
FontHandle | getFont (std::string_view name) const |
| | Look up a loaded font by logical name; returns {0} if not found.
|
|
FontHandle | resolveFont (const FontStack &stack, FontHandle fallback={}) const |
| | Resolve the first loaded font matching stack; falls back to the default font if set.
|
|
void | setDefaultFont (FontHandle h) |
| | Set the fallback font used when a node specifies no font or an unknown font name.
|
|
FontHandle | defaultFont () const |
| | Return the current default font handle ({0} if none).
|
|
FontMetrics | fontMetrics (FontHandle font, float fontSize) const |
| | Query scaled vertical metrics for font at logical fontSize.
|
|
void | setDpiScale (float scale) |
| | Update the active logical-to-physical DPI scale used when rasterizing glyphs.
|
|
float | dpiScale () const |
|
void | setTargetDpiScale (float scale) |
|
void | setFallbackCharWidth (float width) |
| | Set the fixed character advance used when no TTF/OTF font is loaded (headless fallback).
|
|
float | fallbackCharWidth () const |
|
void | setLayoutCacheCapacity (size_t maxEntries) |
| | Configure the maximum number of entries kept in the layout LRU cache.
|
|
void | clearAtlas (IRenderer &renderer) |
| | Destroy all GPU atlas pages on renderer and clear the glyph cache.
|
|
void | clearLayoutCache () |
| | Clear the cached TextLayout entries without touching GPU atlas textures.
|
|
TextAtlasStats | stats () const |
| | Return current atlas and layout-cache diagnostics.
|
|
void | setSyntheticDrawCallback (SyntheticDrawCallback cb) |
|
TextLayout | layout (std::string_view text, const TextMeasureSpec &spec, const TextLayoutOptions &options={}) const |
| | Shape and lay out text according to spec and options (uncached).
|
|
std::shared_ptr< const TextLayout > | layoutCached (std::string_view text, const TextMeasureSpec &spec, const TextLayoutOptions &options={}) |
| | Cached variant of layout() backed by the per-engine LRU cache.
|
|
Vec2 | measureText (std::string_view text, const TextMeasureSpec &spec) const |
| | Measure a single line (no wrapping, splits on \n) and return its {width, height}.
|
| void | draw (IRenderer &renderer, const TextLayout &layout, Rect bounds, Color color, const TextMeasureSpec &spec, Align align=Align::Start, std::string_view fallbackText={}, const Rect *cullRect=nullptr) |
| | Rasterize any missing glyphs into the atlas and emit batched drawGeometry calls.
|
|
|
static TextDirection | detectDirection (std::string_view text) |
| | Detect the strong base direction of text via UAX #9 (RTL or LTR).
|
| static size_t | hitTestLine (std::string_view fullText, const TextLine &line, float localX, bool clampSoftBreak=false) |
| | Map a line-local X coordinate to the closest UTF-8 cluster byte offset.
|
|
static size_t | hitTestPoint (std::string_view fullText, const TextLayout &layout, Vec2 localPos, Align textAlign=Align::Start, float boxWidth=0.0f, bool clampSoftBreak=true) |
| | Map a layout-local (x, y) point to the closest UTF-8 cluster byte offset.
|
|
static size_t | lineIndexForByte (const TextLayout &layout, size_t byteIndex) |
| | Return the line index containing byteIndex.
|
|
static float | caretXOnLine (const TextLine &line, size_t byteIndex) |
| | Return the line-local X coordinate of byteIndex on line.
|
|
static Rect | caretRect (const TextLayout &layout, size_t byteIndex, float caretWidth=2.0f, Align textAlign=Align::Start, float boxWidth=0.0f) |
| | Compute the caret rectangle in layout-local coordinates.
|
|
static std::vector< Rect > | selectionRects (const TextLayout &layout, size_t selStart, size_t selEnd, Align textAlign=Align::Start, float boxWidth=0.0f) |
| | Compute selection highlight rectangles in layout-local coordinates for [selStart, selEnd).
|
Per-context font store, HarfBuzz shaper, FreeType glyph atlas, and layout engine.