Donner 0.5.0
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
TextEngineHelpers.h File Reference

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"
Include dependency graph for TextEngineHelpers.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 baseline shift for a given DominantBaseline/AlignmentBaseline value. Returns a Y offset in pixels (positive = shift up toward ascender).
std::vector< ChunkRangedonner::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 &params, 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.
double donner::svg::text_engine_detail::computeSpanBaselineShiftPx (const TextBackend &backend, const components::ComputedTextComponent::TextSpan &span, FontHandle spanFont, float spanScale, const TextLayoutParams &params)
 Compute per-span baseline-shift in pixels, including OS/2 sub/super metrics and ancestor baseline-shift accumulation.

Detailed Description

Internal helpers for TextEngine layout. Exposed in a header for unit testing.