Donner SVG 0.8.0-pre
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::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

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, std::span< const components::ComputedTextComponent::TextSpan > spans, const Box2d &viewBox, const FontMetrics &fontMetrics, float fontSizePx)
 Compute the text element's bounding box for objectBoundingBox paint.

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::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.