Skip to content

Land textLength and baselines (#221, #222) on main - #223

Merged
swhitty merged 3 commits into
mainfrom
claude/text-length
Nov 17, 2026
Merged

swhitty merged 3 commits into
mainfrom
claude/text-length

Conversation

@swhitty

@swhitty swhitty commented Nov 17, 2026

Copy link
Copy Markdown
Owner

#221 (textLength/lengthAdjust) and #222 (baselines and baseline-shift) were stacked on #220. They merged into their base branches rather than into main:

So main has only #220. claude/text-length (5c50f02) contains both: 7633c35 (#221) and a5364d5 (#222), with #222's merge commit on top. This PR brings them onto main unchanged; the commits are the ones already reviewed in #221 and #222.

🤖 Generated with Claude Code

swhitty and others added 3 commits November 17, 2026 23:21
textLength and lengthAdjust are parsed on <text> and <tspan>; a negative
or invalid length (inherit) is ignored. Each element's characters are
fitted innermost first, as plain Swift over the shaped advances:
lengthAdjust="spacing" spreads the difference over the space between
them, and "spacingAndGlyphs" scales their advances, the space between
them and their glyphs. The text after a fitted tspan moves on, by the
gap after its last character too, as resvg does. An element whose
characters a descendant already fitted, or that starts a new chunk
within itself, keeps its natural length.

Scaled glyphs are a GlyphRun with scaleX, stretched about each glyph's
origin when its outlines are drawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dominant-baseline (inherited) and alignment-baseline (not inherited,
overriding it for its own element) take every common value: auto,
alphabetic, middle, central, hanging, mathematical, ideographic,
text-before-edge and text-after-edge, with the CSS Inline 3 and SVG 1.1
aliases (text-top, text-bottom, before-edge, after-edge, baseline,
use-script; no-change and reset-size keep the parent's). Each comes from
the font's ascent, descent and x-height in makeYOffset, as resvg derives
them. The sign of hanging, which lifted the text instead of hanging it,
is fixed.

baseline-shift applies to tspans: sub and super from the font's OS/2
script offsets, lengths, and percentages of the font-size they are
declared at. Shifts of nested tspans add up; baseline adds nothing,
and inherit takes the parent's value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@swhitty
swhitty merged commit 1118887 into main Nov 17, 2026
18 checks passed
@swhitty
swhitty deleted the claude/text-length branch November 17, 2026 19:56
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.25073% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.30%. Comparing base (e6a7f10) to head (5c50f02).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...raw/Sources/LayerTree/LayerTree.Builder.Text.swift 98.43% 2 Missing ⚠️
...aw/Tests/LayerTree/LayerTree.TextLengthTests.swift 97.50% 2 Missing ⚠️
SwiftDraw/Sources/LayerTree/LayerTree.Layer.swift 0.00% 1 Missing ⚠️
...tDraw/Sources/Renderer/Renderer.CoreGraphics.swift 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #223      +/-   ##
==========================================
+ Coverage   95.24%   95.30%   +0.06%     
==========================================
  Files         292      294       +2     
  Lines       30825    31129     +304     
==========================================
+ Hits        29360    29669     +309     
+ Misses       1465     1460       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant