Internal helpers for TextEngine layout. Exposed in a header for unit testing. More...
#include <cstddef>#include <cstdint>#include <optional>#include <span>#include <string_view>#include <utility>#include <vector>#include "donner/base/Length.h"#include "donner/base/MathUtils.h"#include "donner/base/SmallVector.h"#include "donner/base/Transform.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::InlineDisplacement |
| An authored inline displacement consumed by one positioned glyph group. More... | |
| struct | donner::svg::text_engine_detail::RunPenExtent |
| Per-run pen start/end position for textLength calculation. More... | |
| struct | donner::svg::text_engine_detail::TextLengthTraversalStats |
| Optional operation counts for deterministic textLength traversal complexity tests. 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 | |
| template<typename Bitmap> | |
| Transform2d | donner::svg::text_engine_detail::computeLocalFromBitmapGlyph (const TextGlyph &glyph, const Bitmap &bitmap) |
| Map positive-size bitmap texels through their bearing and stretch, then rotate at glyph origin. | |
| 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 typographic character has an absolute x or y position. | |
| ByteIndexMappings | donner::svg::text_engine_detail::buildByteIndexMappings (std::string_view spanText) |
| Build the byte-to-codepoint map; shaping determines group applicability. DOM indexing is separate. | |
| 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, TextLengthTraversalStats *traversalStats=nullptr) |
| 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, const AnchorExclusions &exclusions={}, double firstLineIndent=0.0) |
| Fix up chunk anchors and apply the existing per-line anchor profile. firstLineIndent contributes its signed leading margin only to the first flat chunk. | |
| bool | donner::svg::text_engine_detail::applyInlineSizeWrap (std::vector< TextRun > &runs, const components::ComputedTextComponent &text, const TextLayoutParams ¶ms, double measurePx, double lineHeightPx, const TextBackend *backend=nullptr, std::span< const ChunkBoundary > chunks={}, std::span< const InlineDisplacement > displacements={}, AnchorExclusions *exclusions=nullptr) |
| Apply whitespace-dependent line layout along the inline axis, before text-anchor adjustment. Each line/chunk uses its first addressable character's anchor; lines advance along the block axis. | |
| 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, | ||
| const TextBackend * | backend = nullptr, | ||
| std::span< const ChunkBoundary > | chunks = {}, | ||
| std::span< const InlineDisplacement > | displacements = {}, | ||
| AnchorExclusions * | exclusions = nullptr ) |
Apply whitespace-dependent line layout along the inline axis, before text-anchor adjustment. Each line/chunk uses its first addressable character's anchor; lines advance along the block axis.
Soft wrapping uses spaces and tabs according to each span's white-space policy. Preserved segment breaks force new lines even without inline-size. Overflow-wrap enables bounded emergency typographic-unit breaks; there is no hyphenation or CJK per-character policy. Collapsible trailing spaces are removed; pre-wrap spaces may hang, while break-spaces gives each preserved space a break opportunity. Text-on-path runs are excluded: their controls are shaped as blanks without creating line boxes.
| runs | Runs produced by the single-line layout; glyph positions are rewritten. |
| text | Computed text tree, parallel to runs (span i corresponds to run i). |
| params | Layout params, including writing mode and the first-line start margin. |
| measurePx | The inline-size measure in pixels, or zero to apply only forced breaks/tabs. |
| lineHeightPx | Advance between line baselines along the block axis, in pixels. |
| backend | Font metrics for the minimum tab advance (0.5ch). |
| chunks | Authored text chunk boundaries, retained across line breaks. |
| displacements | Per-group authored inline shifts, applied after CSS line layout. |
| exclusions | Receives source-cluster hanging decisions for final single-line anchoring. |
| 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). |
| Transform2d donner::svg::text_engine_detail::computeLocalFromBitmapGlyph | ( | const TextGlyph & | glyph, |
| const Bitmap & | bitmap ) |
Map positive-size bitmap texels through their bearing and stretch, then rotate at glyph origin.
| glyph | Placed glyph in text-element local coordinates. |
| bitmap | Decoded bitmap or metadata with positive width and height. |