|
|
Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
|
Internal helpers for TextEngine layout. Exposed in a header for unit testing. More...
#include <optional>#include <string_view>#include <vector>#include "donner/base/Length.h"#include "donner/base/SmallVector.h"#include "donner/svg/components/text/ComputedTextComponent.h"#include "donner/svg/core/DominantBaseline.h"#include "donner/svg/core/TextAnchor.h"#include "donner/svg/text/TextBackend.h"#include "donner/svg/text/TextLayoutParams.h"#include "donner/svg/text/TextTypes.h"Classes | |
| struct | donner::svg::text_engine_detail::ChunkRange |
| Byte range within a span representing a shaping chunk. More... | |
| struct | donner::svg::text_engine_detail::ByteIndexMappings |
| Index mapping result for a span's text. More... | |
| struct | donner::svg::text_engine_detail::ChunkBoundary |
| Text chunk boundary for per-chunk text-anchor adjustment. More... | |
| struct | donner::svg::text_engine_detail::RunPenExtent |
| Per-run pen start/end position for textLength calculation. 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 | |
| double | donner::svg::text_engine_detail::computeBaselineShift (DominantBaseline baseline, const FontVMetrics &vm, float scale) |
| Compute the baseline-alignment offset for a dominant-baseline / alignment-baseline keyword, in pixels. The offset is added to the baseline Y position, so positive values move glyphs down (+Y in SVG coordinates); e.g. hanging returns +0.8 * ascent. | |
| std::vector< ChunkRange > | donner::svg::text_engine_detail::findChunkRanges (std::string_view spanText, const SmallVector< std::optional< Lengthd >, 1 > &xList, const SmallVector< std::optional< Lengthd >, 1 > &yList) |
| Pre-scan span text to find chunk byte boundaries. A new chunk starts when a non-first codepoint has an absolute x or y position. | |
| ByteIndexMappings | donner::svg::text_engine_detail::buildByteIndexMappings (std::string_view spanText) |
| Build byte→charIdx and byte→rawCpIdx mappings for a span. | |
| void | donner::svg::text_engine_detail::applyTextLength (std::vector< TextRun > &runs, const components::ComputedTextComponent &text, const std::vector< RunPenExtent > &runExtents, const TextLayoutParams ¶ms, bool vertical, double currentPenX, double currentPenY) |
| Apply per-span and global textLength adjustments to positioned runs. | |
| void | donner::svg::text_engine_detail::applyTextAnchor (std::vector< TextRun > &runs, std::vector< ChunkBoundary > &chunkBoundaries, const components::ComputedTextComponent &text, bool vertical) |
| Fix up chunk text-anchors and apply per-chunk text-anchor adjustment. | |
| bool | donner::svg::text_engine_detail::applyInlineSizeWrap (std::vector< TextRun > &runs, const components::ComputedTextComponent &text, const TextLayoutParams ¶ms, double measurePx, double lineHeightPx) |
| Break horizontally-laid-out runs into stacked lines for SVG2 inline-size auto-flow, rewriting glyph positions in place. Called after the flat single-line layout and before text-anchor adjustment; when it wraps it applies text-anchor per line itself. | |
| double | donner::svg::text_engine_detail::computeSpanBaselineShiftPx (const TextBackend &backend, const components::ComputedTextComponent::TextSpan &span, FontHandle spanFont, float spanScale, const TextLayoutParams ¶ms) |
| Compute per-span baseline-shift in pixels, including OS/2 sub/super metrics and ancestor baseline-shift accumulation. | |
Internal helpers for TextEngine layout. Exposed in a header for unit testing.
| bool donner::svg::text_engine_detail::applyInlineSizeWrap | ( | std::vector< TextRun > & | runs, |
| const components::ComputedTextComponent & | text, | ||
| const TextLayoutParams & | params, | ||
| double | measurePx, | ||
| double | lineHeightPx ) |
Break horizontally-laid-out runs into stacked lines for SVG2 inline-size auto-flow, rewriting glyph positions in place. Called after the flat single-line layout and before text-anchor adjustment; when it wraps it applies text-anchor per line itself.
Wrap rules (slice 1, horizontal writing modes only):
measurePx, otherwise it starts a new line. The first word of a line is always placed even when it overflows the measure.params) about the block origin (the first glyph's position) and stacked downward by lineHeightPx.| runs | Runs produced by the flat horizontal layout; glyph positions are rewritten. |
| text | Computed text tree, parallel to runs (span i ↔ run i), used for span text. |
| params | Layout params; textAnchor selects per-line anchoring. |
| measurePx | The inline-size measure in pixels (must be > 0). |
| lineHeightPx | Vertical advance between line baselines in pixels. |
| double donner::svg::text_engine_detail::computeBaselineShift | ( | DominantBaseline | baseline, |
| const FontVMetrics & | vm, | ||
| float | scale ) |
Compute the baseline-alignment offset for a dominant-baseline / alignment-baseline keyword, in pixels. The offset is added to the baseline Y position, so positive values move glyphs down (+Y in SVG coordinates); e.g. hanging returns +0.8 * ascent.
| baseline | Effective baseline keyword for the span. |
| vm | Font vertical metrics in design units (FontVMetrics::xHeight may be 0). |
| scale | Design units → pixels scale (em scale, fontSize / unitsPerEm). |