Donner 0.5.0
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::TextEngine Class Reference

Shared SVG text engine. More...

#include "donner/svg/text/TextEngine.h"

Public Member Functions

 TextEngine (FontManager &fontManager, Registry &registry)
 TextEngine (FontManager &fontManager, Registry &registry, std::unique_ptr< TextBackend > backend)
 Test-only constructor that injects a custom TextBackend.
 TextEngine (const TextEngine &)=delete
TextEngine & operator= (const TextEngine &)=delete
void addFontFace (const css::FontFace &face)
void addFontFaces (std::span< const css::FontFace > faces)
void prepareForElement (EntityHandle handle, ParseWarningSink &warningSink)
 Prepare text dependencies for the text root containing handle.
std::vector< TextRunlayout (const components::ComputedTextComponent &text, const TextLayoutParams &params)
 Lay out all spans, returning positioned glyph runs.
FontVMetrics fontVMetrics (FontHandle font) const
float scaleForPixelHeight (FontHandle font, float pixelHeight) const
float scaleForEmToPixels (FontHandle font, float pixelHeight) const
std::optional< UnderlineMetricsunderlineMetrics (FontHandle font) const
std::optional< UnderlineMetricsstrikeoutMetrics (FontHandle font) const
std::optional< SubSuperMetricssubSuperMetrics (FontHandle font) const
Path glyphOutline (FontHandle font, int glyphIndex, float scale) const
bool isBitmapOnly (FontHandle font) const
std::optional< TextBackend::BitmapGlyphbitmapGlyph (FontHandle font, int glyphIndex, float scale) const
std::optional< double > measureChUnitInEm (std::span< const RcString > fontFamilies)
 Measure the ch unit in ems for the given font-family cascade.
void resolvePerSpanLayoutStyles (EntityHandle textRootHandle, components::ComputedTextComponent &text) const
 Resolve per-span layout-affecting style state on a computed text tree.
const components::ComputedTextGeometryComponentensureComputedTextGeometryComponent (EntityHandle handle) const
 Ensure cached text geometry exists for the text root containing handle.
std::vector< PathcomputedGlyphPaths (EntityHandle handle) const
 Return glyph outlines for the text subtree rooted at handle.
Box2d computedInkBounds (EntityHandle handle) const
 Return the ink bounds for the text subtree rooted at handle.
Box2d computedObjectBoundingBox (EntityHandle handle) const
 Return the object bounding box for the text subtree rooted at handle.
long getNumberOfChars (EntityHandle handle) const
 Return the number of addressable characters for the text subtree rooted at handle.
double getComputedTextLength (EntityHandle handle) const
 Return the computed text length for the text subtree rooted at handle.
double getSubStringLength (EntityHandle handle, std::size_t charnum, std::size_t nchars) const
 Return the substring length for the text subtree rooted at handle.
Vector2d getStartPositionOfChar (EntityHandle handle, std::size_t charnum) const
 Return the start position of a character for the text subtree rooted at handle.
Vector2d getEndPositionOfChar (EntityHandle handle, std::size_t charnum) const
 Return the end position of a character for the text subtree rooted at handle.
Box2d getExtentOfChar (EntityHandle handle, std::size_t charnum) const
 Return the extent of a character for the text subtree rooted at handle.
double getRotationOfChar (EntityHandle handle, std::size_t charnum) const
 Return the rotation of a character for the text subtree rooted at handle.
long getCharNumAtPosition (EntityHandle handle, const Vector2d &point) const
 Return the character index at the given point for the text subtree rooted at handle.

Detailed Description

Shared SVG text engine.

Owns the selected text backend and provides layout plus font-related operations while hiding backend selection from callers.

Usage:

Registry registry;
auto& fontManager = registry.ctx().emplace<FontManager>(registry);
auto& engine = registry.ctx().emplace<TextEngine>(fontManager, registry);
std::vector<TextRun> runs = engine.layout(text, params);
Manages font loading, caching, and lookup for text rendering.
Definition FontManager.h:68
entt::basic_registry< Entity, std::allocator< Entity > > Registry
Registry type for the SVG ECS, which is the entry point for storing all data.
Definition EcsRegistry.h:46

The documentation for this class was generated from the following files:
  • donner/svg/text/TextEngine.h
  • donner/svg/text/TextEngine.cc