Repository navigation
Text loose ends: font shorthand, alignment-baseline inherit, text filter regions - #224
Merged
Merged
Conversation
…ter regions, CSS weight matching - Expand the CSS `font` shorthand (style, weight, size, family; omitted parts reset) in style attributes and stylesheets, with system font keywords; it is not a presentation attribute. - Support `alignment-baseline: inherit` (and `dominant-baseline: inherit`). - Measure the text's bounding box for objectBoundingBox filter regions of filtered text and groups containing text, instead of drawing them unfiltered. - Match installed family faces by CSS Fonts 4 weight rules over normal-width faces. - Add text-font-shorthand (matplotlib style) and text-filter samples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
==========================================
- Coverage 95.28% 95.25% -0.04%
==========================================
Files 294 296 +2
Lines 31052 31260 +208
==========================================
+ Hits 29588 29776 +188
- Misses 1464 1484 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The last PR of the text series. Branched from
main(1118887).Changes
fontshorthand. Applies instyle=""and in stylesheets:[style] [variant] [weight] [stretch] size[/line-height] family.normal, as CSS requires.caption,menu…) become 13px sans-serif.svg.fonttype='none'output (style="font: 10px 'DejaVu Sans'").alignment-baseline="inherit"takes the parent's value;dominant-baseline="inherit"is accepted too.<text>has a filter, or a filtered ancestor, the builder stores the text's SVG 2 bounding box (makeTextBounds) on its layer.CommandGenerator.makeBoundsuses it for objectBoundingBox regions and units.@font-facealready was:text-font-shorthand.svg(a matplotlib-style chart) andtext-filter.svg. Both pass against resvg; WebKit matches the shorthand sample.resvg
text/suite (387 files,swiftdraw-diff compare --base main --resvg)No regressions. Now passing:
font/font-shorthandalignment-baseline/inherittext/filter-bboxletter-spacing/filter-bboxThese listed files are unchanged on purpose; each already matches WebKit and CSS, or fails for an out-of-scope reason:
font-size/negative-size: resvg draws nothing. We keep the inherited size, as WebKit does.font-size/named-value-without-a-parent: resvg scales named sizes by 1.2 per step (xx-largeis 27.6px). CSS Fonts 4 and WebKit use 32px, and so do we.font-weight/650: we draw Times-Bold, as WebKit does. resvg draws the regular face of its fallback font.dominant-baseline/hanging: placed right, but the Devanagari fallback font differs.tspan/nested: resvg moves the collapsed space into the bold tspan. We keep it in the first one, as WebKit does.tspan/tspan-bbox-2: only the underline is missing (text-decoration).Checks
swift testpasses../container-run-tests.shpasses, on Swift 6.4 and onSWIFT_VERSION=6.2.swiftdraw-diff compare --base main --resvg Samples.bundle: no regressions. 179 of 181 files are unchanged; the 2 new samples go from SwiftDraw bug to pass.🤖 Generated with Claude Code