Editable text
Editable copy, styled spans, line layout and held replacement keys.
A shape can use text as its geometry. The text owns the copy, baseline and paragraph settings. A span marks a range of that copy for a local type style, fill, or property track. The same range stays selected when a word moves to another line.
Content and ownership
textandspanaccept literal Unicode character data and nested spans in document order. Joining the runs inserts no separator. Plain copy needs no wrapper. Empty copy is valid.- Read XML character data after XML line-ending and entity processing. Preserve spaces, tabs, newlines and surrounding whitespace, including whitespace between spans. Comments, an
animatesubtree and a span'sfillsubtree contribute zero characters. Indentation beside those children is copy. Whitespace inside their element-only subtrees is available for formatting. XML character data and normalization - A
textorspanwith no child spans owns a logical string property namedvalue. Its base is the concatenation of its direct character data. An inlineanimate attributeName="value"replaces that string using hold keys. Each key contains literal copy in its XMLvalueattribute. Use
for LF or	for tab there so XML attribute normalization preserves it. Avalueattribute on the text or span itself is invalid. - A
valuetrack on an owner with child spans requires a diagnostic. Put the track on the span containing the copy to replace. This gives each key one string to edit and preserves all neighboring ranges. Track evaluation
Typeface and paragraph
All distances are finite local units before applying the enclosing shape's transform. This profile sets horizontal text on alphabetic baselines.
| Attribute | Owner | Meaning |
|---|---|---|
x, y | text | Horizontal anchor of each line and y coordinate of the first baseline. Each defaults to zero. |
font-family | text, span | Required on text. One nonempty requested family name. A span may override it. |
font-size | text, span | Required on text. Positive em size in local units. A span may override it. |
font-weight | text, span | Integer 1–1000 identifying a face weight. Defaults to 400 on text. A span may override it. |
direction | text | Paragraph base direction, ltr (default) or rtl. Use Unicode bidirectional ordering within the paragraph. |
text-anchor | text | Align each line's shaped advance at x. For start (default), anchor its left edge in LTR and its right edge in RTL. end anchors the opposite edge. middle anchors the midpoint. |
inline-size | text | Positive maximum line advance for soft wrapping. Omission allows each line to take its natural width. An animated width requires a finite authored base. |
line-height | text | Positive distance between consecutive baselines. Defaults to 1.2 times the sampled text element's font size. A taller inline span can extend across that interval. |
For each span, take the nearest specified value of each font field independently. An active track on a span counts as a local value. When a track releases a field with no local base, the sampled enclosing value applies. Family, weight, direction, anchor and copy use hold segments. Coordinates, size, width and baseline distance use ordinary scalar segments. Property types
Resolve the sampled family and weight under the font resolution contract. Preserve the source request through fallback and reflow.
Attachment bounds
Measure the sampled lines using the same advances and line breaks as for painting. The box width is the authored inline-size when present, otherwise the widest line advance. Place a line of that width at x with the resolved direction and text-anchor. The top is the first baseline minus hhea.ascender × font-size / unitsPerEm. The bottom is the last baseline minus the signed hhea.descender × font-size / unitsPerEm. Read both fields from the text element’s resolved primary face. For a variable font, shape advances at the declared instance and use the bound font’s horizontal header fields for these two vertical edges. Span styles can change advances and line count. A blank line still has a baseline. The authored baseline step sets spacing between lines. Glyph ink remains the geometry for a mask or boolean. Attached drawables · OpenType horizontal header
Layout at a sample
- Resolve current copy, font fields and paragraph settings. Keep their source ranges. Treat LF as a hard break. For layout a tab contributes four U+0020 spaces mapped to the original tab.
- Resolve paragraph directionality and script runs. Shape compatible adjacent copy together, even across an authored span boundary. A change of face or size inside one extended grapheme cluster requires a diagnostic at the span. Preserve cluster-to-source associations. Use the same fonts, shaping context and advances for measurement and placement. Unicode bidirectional algorithm · Unicode grapheme boundaries · SVG text layout
- Honor mandatory breaks. With a finite
inline-size, use the default Unicode line break opportunities. Choose the furthest permitted break whose line, shaped for its final boundaries, fits the width. If none fits, place the first unbreakable segment on the line and let it overflow. Do not insert an emergency break or an automatic hyphen. At a soft break discard the advance and ink of the separating trailing U+0020 spaces for measurement and placement. Retain their source ranges. At hard breaks and at end of text preserve authored spaces. Unicode line breaking - Place each line in visual order with its resolved anchor. Baseline number
i, starting at zero, has coordinatey + i × line-height. Empty lines consume one baseline step. Line membership, glyph indices and glyph positions are derived results.
Glyph geometry
Fill each positioned glyph outline according to its font's contour convention, preserving counters such as the hole in O. The text's closed region is the union of those filled regions. Where two glyphs overlap, their shared interior belongs to the union once. Space glyphs with no ink contribute their layout advance and an empty region.
Text can supply this region to a geometry mask or a closed-region boolean operation. Resolve copy, font, layout and the source shape's transform for that request. Skip paint assignment, paint-conflict checks, strokes, the source shape's mask and its opacity. Source markup must still be valid. An alpha or luminance mask consumes the source's rendered appearance, including fill, strokes, its own mask and opacity. Mask evaluation · Boolean operands
The profile paints scalable monochrome glyph outlines using authored paint. When an ink-bearing glyph supplies only a bitmap or color artwork without a usable monochrome outline, diagnose the geometry or appearance request at its source range. Its advance alone cannot establish ink coverage. A centered stroke follows all boundaries of the text region, including counters. Inside or outside alignment requires one simple closed contour. A trim on text requires a diagnostic even when the current glyph happens to have one contour. Stroke alignment · Directed trim contours
Appearance and editing
An optional fill directly under a span supplies the entire paint stack for that range. Nested spans use the nearest enclosing span fill, falling back to the shape fill. Glyphs with no applicable fill receive no fill paint. Apply the shape fill to its assigned glyphs, followed by local fills in preorder of their owning spans. Moving a span's fill declaration past a nested span leaves that order unchanged. Take the union of a stack's assigned glyph coverage before applying it. All stacks use shape-local coordinates and the full text geometry bounds for bounds-relative paint. Draw the shape's strokes after all fills. Paint stacks
A paint boundary supplies no shaping break. When assigning fills, report a shaped cluster that crosses between different fill owners, including between painted and unpainted ranges. For example, a base letter and its combining mark can share one glyph even when the mark alone is in a colored span. A redundant span with the same effective shaping inputs and fill owner preserves the glyphs, their placement and their appearance.
An editor must map a glyph back to all contributing source ranges, through bidi reordering, shaping, reflow and key sampling. Editing base copy patches its character-data range, preserving unrelated escapes, comments and markup. Editing sampled copy supplied by a key patches that key's value. Editing a span fill locates its paint even if another span uses the same color. Reflow never converts the current set of glyphs on a line into an authored selection. Source-preserving editing
A two-beat title
The sample font environment binds PT Serif 400 and 700 to the repository's regular and bold faces. The indentation inside the track formats declarations. The literal prefix contains a space, and the suffix starts with a period. Regular font · Bold font
<scene width="320" height="128" frame-rate="24">
<shape>
<text x="16" y="52" font-family="PT Serif" font-size="32" inline-size="288" line-height="40">Status <span font-weight="700">GO<animate attributeName="value" fill="freeze">
<key frame="0" value="GO" ease="hold"/>
<key frame="24" value="WAIT"/>
</animate><fill><paint><solid color="#FFFF00FF">
<animate attributeName="color" fill="freeze">
<key frame="12" value="#FFFF00FF" ease="hold"/>
<key frame="18" value="#00FFFFFF"/>
</animate>
</solid></paint></fill></span>.</text>
<fill><paint><solid color="#FFFFFFFF"/></paint></fill>
</shape>
</scene>| Sample or edit | Expected result |
|---|---|
| Base or frame 17 | Status GO. appears on the first baseline at y = 52. Only GO is bold and yellow. |
| Frame 18 through frame 23 | GO turns cyan without moving. Its color key belongs to the solid paint. |
| Seek directly to frame 24 | Copy is Status WAIT. and the same span paints WAIT cyan. The period remains in the regular white face and follows the new word's advance. |
Set inline-size="100" and seek to frame 24 | Status occupies the first line and WAIT. the second, with baselines at 52 and 92. The span keeps the same key and paint. |
Change the frame-24 key to GO | Only that attribute value changes. The two other occurrences of GO in the source retain their bytes. |
Nest an unstyled span around GO in the base while retaining the outer string track | The string track now targets an owner with a child span. Diagnose it at the animation. Moving the track into the new leaf restores the original copy behavior. |
| Remove the font environment's weight 700 binding | Apply host weight matching. Preserve the span’s request for 700 when saving. |
A letter as a matte or cutout
Use the same regular PT Serif face for this mask. At y = 45 the letter's left stem covers x = 10 and the counter contains x = 37.
<shape>
<rect width="80" height="90" anchor-u="0" anchor-v="0"/>
<fill><paint><solid color="#FFFFFFFF"/></paint></fill>
<mask type="geometry">
<shape>
<text x="0" y="80" font-family="PT Serif" font-size="100">O</text>
<fill><paint><solid color="#FFFFFF00"/></paint></fill>
</shape>
</mask>
</shape>| Change | Sample at (10, 45) | Sample at (37, 45) |
|---|---|---|
| Use the geometry mask as written | Opaque white | Transparent |
Change only the mask type to alpha | Transparent | Transparent |
On the alpha mask, set the source fill to #FFFFFFFF | Opaque white | Transparent |
Instead subtract the original text source from the rectangle using boolean type="subtraction" and paint the result white | Transparent | Opaque white |
Try the editable word cutout. Change BOOK to INK, or move the operand shape to slide the letters within the card.
Inline graphics, text on a path, vertical writing, font fallback lists, and selectors over generated words, lines, or graphemes remain subjects for further profiles. The author of a fixed two-line title can insert a line feed to preserve that break or mark the words with spans to preserve their styling through a different break. Design studies