Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
PlacedTextGeometry.h File Reference

Shared, backend-agnostic text geometry for RendererInterface::drawText. More...

Include dependency graph for PlacedTextGeometry.h:

Classes

struct  donner::svg::PreparedTextDraw
 Immutable layout slice and full-element bounds prepared once for a text effect owner. More...
struct  donner::svg::TextDrawGeometry
 Mutable per-call run copy after effect ownership and visibility filtering. More...
struct  donner::svg::GlyphOutlineAndPlacement
 A glyph's outline split into the part that depends only on the glyph and the part that depends only on where the glyph sits in the run. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
namespace  donner::svg
 Donner SVG library, which can load, manipulate and render SVG files.

Functions

TextLayoutParams donner::svg::ToTextLayoutParams (const TextParams &params)
 Convert renderer-facing text parameters to the shared layout engine's input.
TextDrawGeometry donner::svg::PrepareTextDrawGeometry (Registry &registry, const components::ComputedTextComponent &text, const TextParams &params, TextEngine &textEngine)
 Resolve one backend draw from a shared element preparation or the direct-caller fallback.
Path donner::svg::TransformPath (const Path &path, const Transform2d &transform)
 Apply an affine transform to every point of a path.
Transform2d donner::svg::GlyphPlacementTransform (const TextGlyph &glyph)
 The affine that places a glyph's unplaced outline at its baseline position in the text element's local space.
GlyphOutlineAndPlacement donner::svg::UnplacedGlyphOutline (const TextEngine &textEngine, FontHandle font, const TextGlyph &glyph, float scale)
 Build a glyph's unplaced outline and its placement transform.
Path donner::svg::PlacedGlyphOutline (const TextEngine &textEngine, FontHandle font, const TextGlyph &glyph, float scale)
 Build the placed outline for a single glyph in document space.
Box2d donner::svg::ComputeTextBounds (const TextEngine &textEngine, const std::vector< TextRun > &runs)
 Compute the text element's bounding box for objectBoundingBox paint.
void donner::svg::ClearUnpaintedSpanGlyphs (const components::ComputedTextComponent &text, entt::entity spanEffectOwner, std::vector< TextRun > &runs)
 Drop the glyphs of runs this draw is not responsible for painting.

Detailed Description

Shared, backend-agnostic text geometry for RendererInterface::drawText.

RendererTinySkia::drawText and RendererGeode::drawText historically each re-derived per-glyph placement (outline โ†’ stretch โ†’ translate โ†’ rotate), which let the two copies drift. This header is the shared placement layer both backends consume so the geometry is computed once. It encodes tiny-skia's behavior verbatim (tiny-skia is the parity reference); geode converges to it.

Pure geometry only: inputs/outputs are donner::Path / Transform2d / TextEngine - no backend paint types. No allocation beyond what Path itself does; no exceptions.


Class Documentation

◆ donner::svg::PreparedTextDraw

struct donner::svg::PreparedTextDraw

Immutable layout slice and full-element bounds prepared once for a text effect owner.

Class Members
Box2d elementBounds
vector< TextRun > runs

◆ donner::svg::TextDrawGeometry

struct donner::svg::TextDrawGeometry

Mutable per-call run copy after effect ownership and visibility filtering.

Class Members
Box2d elementBounds
vector< TextRun > runs

◆ donner::svg::GlyphOutlineAndPlacement

struct donner::svg::GlyphOutlineAndPlacement

A glyph's outline split into the part that depends only on the glyph and the part that depends only on where the glyph sits in the run.

The two compose back into the placed outline: TransformPath(outline, glyphFromLocal) maps to the same place PlacedGlyphOutline does. It is not the same arithmetic - that one composes the placement into a single affine - so the two agree as mappings, not bit for bit, whenever a rotation is present.

Splitting them lets a renderer key a cache on glyph identity (font, glyph index, effective scale, stretch, rotation) and reuse one outline for every occurrence, carrying the per-occurrence placement as a transform instead of re-deriving and re-transforming the outline for each one.

Class Members
Transform2d glyphFromLocal Pure translation placing outline at its baseline position in the text element's local space.
Path outline Raw glyph outline at the glyph's effective scale, with the lengthAdjust stretch and the per-glyph rotation already baked in. Empty for .notdef and for glyphs with no vector outline.