Skip to content

Improve SVG text layout and enable Chrome-backed baselines#484

Merged
wieslawsoltes merged 7 commits intomasterfrom
codex/svg-text-support
Apr 10, 2026
Merged

Improve SVG text layout and enable Chrome-backed baselines#484
wieslawsoltes merged 7 commits intomasterfrom
codex/svg-text-support

Conversation

@wieslawsoltes
Copy link
Copy Markdown
Owner

PR Summary: SVG text support and Chrome-backed text baselines

Branch

  • codex/svg-text-support

Commit stack

  1. d3cdffa6d Improve SVG text layout and font fallback
  2. e38af65ba Add text rendering regression coverage
  3. c85f91df3 Enable W3C text fixtures with Chrome baselines
  4. b58feb0b9 Enable resvg text fixtures with Chrome baselines

High-level summary

This branch focuses on text rendering parity, especially fonts, fallback, bidi, whitespace handling, tspan, tref, textPath, textLength, rotation, and Chrome-backed text test coverage.

The implementation keeps Chrome as the source of truth for newly enabled W3C and resvg text rows. Where browser/runtime behavior is still not implemented, rows stay skipped with explicit reasons instead of being forced through with fake baselines.

What changed

1. Core text layout and font handling

  • Reworked SvgSceneTextCompiler to support substantially more browser-like text layout behavior across:
    • mixed-direction and bidi text runs
    • inherited and per-glyph rotate handling
    • whitespace preservation and trimming boundaries
    • tspan and tref sequencing
    • textPath placement and handoff behavior
    • textLength / lengthAdjust handling in more cases
    • spacing-sensitive layout branching
  • Improved SVG font fallback selection so an SVG font that only exposes missing-glyph does not suppress usable platform/system fallback.
  • Added/expanded shaping and loader support in the Skia model and asset loader to keep glyph fallback and script shaping aligned with the renderer changes.
  • Added compatibility loader support under Svg.Custom for text-related compatibility cases needed by the new coverage.
  • Extended settings/API support for text-reference rendering options and related cloning/configuration paths.

Primary files:

  • src/Svg.SceneGraph/SvgSceneTextCompiler.cs
  • src/Svg.SceneGraph/SvgFontTextRenderer.cs
  • src/Svg.Skia/SkiaModel.TextShaping.cs
  • src/Svg.Skia/SkiaSvgAssetLoader.cs
  • src/Svg.Model/ISvgAssetLoader.cs
  • src/Svg.Model/Services/PaintingService.cs
  • src/Svg.Custom/Compatibility/SvgDocumentCompatibilityLoader.cs

2. Regression coverage

  • Added targeted retained-scene regressions for:
    • SVG font fallback vs missing-glyph
    • nested tspan rotation alignment
    • inter-tspan space preservation
    • textPath arc and percentage offset behavior
    • text-reference enable/disable behavior
  • Expanded settings tests for new text-reference configuration behavior.

Primary files:

  • tests/Svg.Skia.UnitTests/SvgRetainedSceneGraphTests.cs
  • tests/Svg.Skia.UnitTests/Issue405Tests.cs
  • tests/Svg.Skia.UnitTests/SKSvgSettingsTests.cs

3. W3C text coverage

  • Enabled a large set of previously skipped W3C text rows.
  • Added Chrome override captures under tests/Svg.Skia.UnitTests/ChromeReference/W3C/.
  • Kept unsupported browser-only rows skipped with explicit reasons.
  • Updated thresholds only where the render is semantically aligned with Chrome and the remaining error is raster-level.

Examples of enabled/validated areas:

  • text alignment
  • bidi and multilingual intro rows
  • fonts and fallback rows
  • text decoration
  • text path
  • text content / whitespace rows
  • tref and tspan

Primary files:

  • tests/Svg.Skia.UnitTests/W3CTestSuiteTests.cs
  • tests/Svg.Skia.UnitTests/ChromeReference/W3C/*

4. resvg text coverage

  • Enabled many previously skipped resvg text rows.
  • Added Chrome-backed resvg baselines under tests/Svg.Skia.UnitTests/ChromeReference/resvg/.
  • Added scripts/capture_resvg_chrome_overrides.mjs for repeatable Chrome capture of resvg text fixtures.
  • Added plan/skipped-tests-implementation-roadmap.md documenting the remaining skipped buckets and the implementation order for deeper work that is still open.

Examples of enabled/validated areas:

  • letter-spacing
  • word-spacing
  • text-decoration
  • textLength
  • text
  • textPath
  • tref
  • tspan

Primary files:

  • tests/Svg.Skia.UnitTests/resvgTests.cs
  • tests/Svg.Skia.UnitTests/ChromeReference/resvg/*
  • scripts/capture_resvg_chrome_overrides.mjs
  • plan/skipped-tests-implementation-roadmap.md

Validation run

Executed successfully:

  • dotnet format Svg.Skia.slnx --no-restore
  • dotnet build Svg.Skia.slnx -c Release --no-restore
  • dotnet test Svg.Skia.slnx -c Release --no-restore

Selected results from the full test pass:

  • Svg.Skia.UnitTests: Passed 1537, Skipped 616, Total 2153
  • ShimSkiaSharp.UnitTests: Passed 128
  • Svg.Model.UnitTests: Passed 64
  • Svg.Editor.Svg.UnitTests: Passed 4
  • Svg.Editor.Skia.UnitTests: Passed 10
  • Svg.Controls.Skia.Uno.UnitTests: Passed 17
  • Svg.Controls.Skia.Avalonia.UnitTests: Passed 21
  • Svg.Controls.Avalonia.UnitTests: Passed 10
  • Svg.Editor.Skia.Avalonia.UnitTests: Passed 18

Known warnings / non-blocking notes

  • The solution build still emits pre-existing warnings, including:
    • NU1903 for samples/UnoTestApp on Tmds.DBus.Protocol
    • existing nullable warnings in text and editor code
    • generated obsolete-API warnings from source-generated sample outputs
  • externals/SVG was already dirty before this work and was intentionally left untouched.

Remaining intentionally skipped areas

The biggest remaining skipped buckets are documented in plan/skipped-tests-implementation-roadmap.md. The main unresolved categories are:

  • browser-runtime-dependent W3C rows that require DOM, script, event, or interaction behavior
  • advanced text/layout areas still needing deeper engine work in some resvg buckets
  • unsupported filter/image/runtime features outside the text tranche

Review guidance

Suggested review order:

  1. Core renderer and shaping changes in SvgSceneTextCompiler, SvgFontTextRenderer, and Skia loader/shaping code
  2. Regression tests in SvgRetainedSceneGraphTests, Issue405Tests, and SKSvgSettingsTests
  3. W3C test manifest updates plus W3C Chrome baselines
  4. resvg test manifest updates, Chrome resvg baselines, and the capture script / roadmap

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b58feb0b9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Svg.Custom/Compatibility/SvgDocumentCompatibilityLoader.cs
Comment thread src/Svg.SceneGraph/SvgSceneTextCompiler.cs
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89af0a7cff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Svg.Model/Services/PaintingService.cs
Comment thread src/Svg.Model/Services/PaintingService.cs
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a12fbe6c6a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Svg.SceneGraph/SvgSceneTextCompiler.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant