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... | |
| struct | BidiEmbedding |
| An element whose unicode-bidi places bidi controls around its content. 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 | ownsFill () const |
| True when this span's own fill decides how its glyphs are filled, rather than the text element's fill. | |
| std::span< const double > | strokeDashLengths () const |
| The span's stroke dash lengths in user units; empty for a solid stroke. The view borrows the dash list this span holds, so it is valid only while this span, or another span sharing the same list, keeps it. | |
| std::span< const RcString > | fontFamilyList () const |
| The span's font-family list; empty until resolved. The view borrows the list this span holds, so it is valid only while this span, or another span sharing the list, keeps it. | |
| void | setFontFamilies (SmallVector< RcString, 1 > families) |
Sets the span's font-family list to its own copy of families. | |
| 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.). | |
| entt::entity | effectOwner = entt::null |
| The text content element whose rendering instance paints this span, or entt::null when the text root's own instance paints it. Set when an ancestor-or-self span declares clip-path, mask, or filter and therefore renders in its own layer. | |
| 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. | |
| bool | hasComputedPaint = false |
| True when resolvedFill and resolvedStroke hold the span's computed paint, so a fill of none means the span is not filled. A span whose paint was not resolved from a computed style is filled with the text element's fill. | |
| std::optional< std::uint64_t > | fillPatternSlot |
| The span pattern slot whose tile this span's own fill paints with, when its fill references a pattern other than the text element's own (see SpanPatternPaint). Set by RendererDriver; unset when the span paints the text element's pattern, or none. | |
| std::optional< std::uint64_t > | strokePatternSlot |
| 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. | |
| std::shared_ptr< const std::vector< double > > | strokeDashArray |
| Stroke dash lengths in user units for this span (stroke-dasharray), shared by every span styled by the same element so a text of many chunks holds one copy; null for a solid stroke. | |
| double | strokeDashOffset = 0.0 |
| Stroke dash offset in user units for this span (stroke-dashoffset). | |
| 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. | |
| FontSynthesisSmallCaps | fontSynthesisSmallCaps = FontSynthesisSmallCaps::Auto |
| Resolved policy for synthesizing small caps when the drawing face lacks them. | |
| std::array< uint32_t, 3 > | openTypeLanguageTags {} |
| Preferred OpenType language systems resolved from the inherited XML language. | |
| std::optional< FontKerning > | fontKerning |
| Resolved kerning policy; absent values use the text root layout parameters. | |
| std::optional< std::optional< double > > | fontSizeAdjust |
| Resolved size adjustment; an absent outer value uses root parameters, while an empty inner value explicitly disables adjustment (font-size-adjust: none). | |
| 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. | |
| bool | hasResolvedFontSize = false |
| True when computed style supplied fontSize, including an explicit zero. Unresolved programmatic spans keep their root-size fallback when fontSize has the default zero value. | |
| std::shared_ptr< const SmallVector< RcString, 1 > > | fontFamilies |
| CSS font-family list for this span, shared by every span styled by the same element, so a text of many spans holds one copy; null until resolved. | |
| 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 |
| Ordered stack of baseline shifts contributed by ancestor text spans. | |
| DominantBaseline | alignmentBaseline = DominantBaseline::Auto |
| Effective baseline alignment for this span: the CSS alignment-baseline value when not Auto, otherwise the span's resolved (inherited) dominant-baseline. Auto means the alphabetic baseline (no shift). Populated by RendererDriver from sourceEntity. | |
| TextOrientation | textOrientation = TextOrientation::Mixed |
| Computed glyph orientation for vertical text. | |
| 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 |
| Product of the CSS opacity of every text content element from sourceEntity up to, but excluding, the element whose rendering instance paints this span - the text root, or effectOwner when set. That element applies its own opacity through its isolated layer, so counting it here would apply it twice. Populated by RendererDriver. | |
| 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. | |
| PaintOrder | paintOrder |
| CSS paint-order for this span. Controls whether fill or stroke is painted first (markers do not apply to text). Populated by RendererDriver from sourceEntity. | |
| std::shared_ptr< const TextDecorationData > | decorations |
| All originating decoration declarations affecting this span, outermost first. | |
| 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. | |
| bool | rightToLeftInline = false |
| Whether this span's inline progression runs right to left: direction: rtl on a horizontal line that is not on a path. Its chunks anchor from their right edge, and the current text position after them is their left edge. | |
| SmallVector< BidiEmbedding, 1 > | bidiEmbeddings |
| Elements between the text root and this span, the span's own element included, whose unicode-bidi is not normal, outermost first. The text root's own value applies to its whole paragraph instead. | |
| WhiteSpace | whiteSpace = WhiteSpace::Normal |
| Whitespace policy resolved when source text is normalized. | |
| bool | preservesSpaces = false |
| Whether normalization preserved space characters, including legacy xml:space. | |
| TextTransform | textTransform = TextTransform::None |
| Presentation-only transformation resolved from this span's computed style. | |
| std::optional< WhiteSpace > | boundaryWhiteSpace |
| Common ancestor's whitespace policy at the boundary with the next nonempty span. | |
| 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). | |
| TextPathMethod | textPathMethod = TextPathMethod::Align |
| How glyphs are placed along pathSpline. | |
| 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. | |
| FontSynthesisStyle | fontSynthesisStyle = FontSynthesisStyle::Auto |
| Resolved permission to synthesize an oblique face for this span. | |
| OverflowWrap | overflowWrap = OverflowWrap::Normal |
| Emergency breaking policy from this span's computed style. | |
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 | |
| struct donner::svg::components::ComputedTextComponent::TextSpan::BidiEmbedding |
An element whose unicode-bidi places bidi controls around its content.
| Class Members | ||
|---|---|---|
| entity | element = entt::null | Element enclosing the span. |
| bool | rightToLeft = false | Whether its direction is rtl. |
| UnicodeBidi | unicodeBidi = UnicodeBidi::Normal | The element's unicode-bidi. |
| std::optional<std::uint64_t> donner::svg::components::ComputedTextComponent::TextSpan::strokePatternSlot |