|
|
Donner 0.5.0
Embeddable browser-grade SVG2 engine
|
A contiguous slice of text with fully resolved layout attributes. More...
#include "donner/svg/components/text/ComputedTextComponent.h"
Classes | |
| struct | AncestorShift |
| Unresolved baseline-shift values from ancestor tspan elements. Each entry is the ancestor's (baseline-shift keyword, baseline-shift Lengthd, font-size in pixels). Layout engines resolve each entry using font OS/2 metrics for sub/super or toPixels() for explicit lengths, then sum to get the total ancestor shift. More... | |
Public Types | |
| enum class | BaselineShiftKeyword : uint8_t { Length , Sub , Super } |
| Indicates whether baseline-shift was set via the sub or super keywords, which should be resolved from font OS/2 metrics at layout time. | |
Public Member Functions | |
| bool | hasExplicitX () const |
| Returns true if xList[0] has an explicit value. | |
| bool | hasExplicitY () const |
| Returns true if yList[0] has an explicit value. | |
Public Attributes | |
| RcString | text |
| Back‑reference to the original text for this span. | |
| std::size_t | start |
Byte index (inclusive) of the first code unit of the span within text. | |
| std::size_t | end |
Byte index (exclusive) one past the last code unit of the span within text. | |
| entt::entity | sourceEntity = entt::null |
| Back-reference to the source entity (text, tspan, or textPath) that produced this span. Used by the renderer to look up ComputedStyleComponent for per-span properties (fill, opacity, font-weight, clip-path, mask, filter, baseline-shift, etc.). | |
| bool | startsNewChunk = false |
| True when this span starts a new text chunk (has explicit x or y positioning). A new chunk resets the current text position and suppresses cross-span kerning. | |
| bool | hidden = false |
| True when this span's source element has display:none. Hidden spans consume per-character attribute indices (rotate, x, y) but are not rendered and do not advance the pen position. | |
| ResolvedPaintServer | resolvedFill |
| Resolved fill paint for this span (solid color, gradient reference, or none). Populated by RendererDriver from sourceEntity's ComputedStyleComponent. | |
| ResolvedPaintServer | resolvedStroke |
| Resolved stroke paint for this span (solid color, gradient reference, or none). Populated by RendererDriver from sourceEntity's ComputedStyleComponent. | |
| double | fillOpacity = 1.0 |
| CSS fill-opacity value for this span (0.0-1.0). | |
| double | strokeOpacity = 1.0 |
| CSS stroke-opacity value for this span (0.0-1.0). | |
| double | strokeWidth = 0.0 |
| Stroke width in user units for this span. | |
| StrokeLinecap | strokeLinecap = StrokeLinecap::Butt |
| Stroke line cap used for text outlines in this span. | |
| StrokeLinejoin | strokeLinejoin = StrokeLinejoin::Miter |
| Stroke line join used for text outlines in this span. | |
| double | strokeMiterLimit = 4.0 |
| Stroke miter limit used for text outlines in this span. | |
| int | fontWeight = 400 |
| CSS font-weight for this span (100-900, 400=normal, 700=bold). Populated by RendererDriver from sourceEntity. | |
| FontStyle | fontStyle = FontStyle::Normal |
| CSS font-style for this span (normal/italic/oblique). Populated by RendererDriver from sourceEntity. | |
| FontStretch | fontStretch = FontStretch::Normal |
| CSS font-stretch for this span (condensed/normal/expanded). Populated by RendererDriver from sourceEntity. | |
| FontVariant | fontVariant = FontVariant::Normal |
| CSS font-variant for this span (normal/small-caps). Populated by RendererDriver from sourceEntity. | |
| Lengthd | fontSize |
| CSS font-size for this span. When different from the text element's font-size, the layout engine uses this to shape glyphs at the correct size. Populated by RendererDriver from sourceEntity. | |
| Lengthd | baselineShift |
| CSS baseline-shift value for this span. For Length keyword, this is the explicit shift value. For Sub/Super, this is a fallback em-based value; layout engines should prefer font OS/2 metrics when available. | |
| BaselineShiftKeyword | baselineShiftKeyword = BaselineShiftKeyword::Length |
| Whether baseline-shift was sub, super, or an explicit length/percentage. | |
| SmallVector< AncestorShift, 2 > | ancestorBaselineShifts |
| DominantBaseline | alignmentBaseline = DominantBaseline::Auto |
| CSS alignment-baseline value for this span. When not Auto, overrides the dominant-baseline for this specific inline element. Populated by RendererDriver from sourceEntity. | |
| Visibility | visibility = Visibility::Visible |
| CSS visibility value for this span. Hidden/collapsed spans are laid out normally (they still advance the pen position) but their glyphs are not drawn. Populated by RendererDriver from sourceEntity. | |
| double | opacity = 1.0 |
| CSS opacity value for this span (0.0-1.0). Populated by RendererDriver from sourceEntity. | |
| double | letterSpacingPx = 0.0 |
| CSS letter-spacing for this span, resolved to pixels. Populated by RendererDriver. | |
| double | wordSpacingPx = 0.0 |
| CSS word-spacing for this span, resolved to pixels. Populated by RendererDriver. | |
| TextDecoration | textDecoration = TextDecoration::None |
| Per-span text-decoration bitmask, inherited from the declaring ancestor. | |
| ResolvedPaintServer | resolvedDecorationFill |
| Fill paint resolved from the element that declared text-decoration (not this span). Per CSS Text Decoration §3, decoration uses the declaring element's paint. | |
| ResolvedPaintServer | resolvedDecorationStroke |
| Stroke paint from the declaring element (for stroking decoration lines). | |
| double | decorationFillOpacity = 1.0 |
| CSS fill-opacity resolved from the text element that provides decoration paint. | |
| double | decorationStrokeOpacity = 1.0 |
| CSS stroke-opacity resolved from the text element that provides decoration paint. | |
| float | decorationFontSizePx = 0.0f |
| Font size (in pixels) from the declaring element, for computing decoration metrics. | |
| double | decorationStrokeWidth = 0.0 |
| Stroke width from the declaring element, for stroking decoration lines. | |
| int | decorationDeclarationCount = 0 |
| Number of ancestors that explicitly declared a non-none text-decoration for this span. | |
| TextAnchor | textAnchor = TextAnchor::Start |
| Per-span text-anchor value. Used for per-chunk text-anchor adjustment: each text chunk uses the text-anchor of its first rendered character's element. Populated by RendererDriver from sourceEntity's ComputedStyleComponent. | |
| std::optional< Lengthd > | textLength |
| Per-span textLength override from the source element's TextComponent. When set, textLength adjustment is applied to this span's run individually rather than using the global textLength from TextParams. | |
| LengthAdjust | lengthAdjust = LengthAdjust::Default |
| Per-span lengthAdjust from the source element's TextComponent. | |
| SmallVector< std::optional< Lengthd >, 1 > | xList |
Per-character absolute X positions from x attribute lists. Indexed by character (codepoint) index within the span. nullopt means no explicit position — the glyph advances naturally from the previous character. Index 0 holds the span-start position. | |
| SmallVector< std::optional< Lengthd >, 1 > | yList |
Per-character absolute Y positions from y attribute lists. | |
| SmallVector< std::optional< Lengthd >, 1 > | dxList |
Per-character relative X offsets from dx attribute lists. | |
| SmallVector< std::optional< Lengthd >, 1 > | dyList |
Per-character relative Y offsets from dy attribute lists. | |
| SmallVector< double, 1 > | rotateList |
Per-character rotation in degrees from rotate attribute lists. Per SVG spec, the last value repeats for all subsequent characters beyond the list length. | |
| std::optional< Path > | pathSpline |
| If set, glyphs in this span are positioned along this path (for "<textPath>"). | |
| entt::entity | textPathSourceEntity = entt::null |
| The "<textPath>" entity that supplied pathSpline, if any. | |
| double | pathStartOffset = 0.0 |
| Start offset along the path (resolved to pixels). | |
| bool | textPathFailed = false |
| True when a "<textPath>" element's href could not be resolved. Per SVG spec, a textPath with an invalid or missing href does not render. | |
A contiguous slice of text with fully resolved layout attributes.
Offsets start and end refer to UTF-8 byte positions into the parent string stored in text. All coordinate and rotation values are given in the user coordinate system and already include any inherited transformations from ancestor "<text>" elements.
| struct donner::svg::components::ComputedTextComponent::TextSpan::AncestorShift |
Unresolved baseline-shift values from ancestor tspan elements. Each entry is the ancestor's (baseline-shift keyword, baseline-shift Lengthd, font-size in pixels). Layout engines resolve each entry using font OS/2 metrics for sub/super or toPixels() for explicit lengths, then sum to get the total ancestor shift.
| Class Members | ||
|---|---|---|
| double | fontSizePx | |
| BaselineShiftKeyword | keyword | |
| Lengthd | shift | |