Skip to content

LibGfx+LibWeb: Use per-code-point font fallback for SVG text - #11228

Open
sideshowbarker wants to merge 2 commits into
LadybirdBrowser:masterfrom
sideshowbarker:svg-text-font-fallback
Open

LibGfx+LibWeb: Use per-code-point font fallback for SVG text#11228
sideshowbarker wants to merge 2 commits into
LadybirdBrowser:masterfrom
sideshowbarker:svg-text-font-fallback

Conversation

@sideshowbarker

@sideshowbarker sideshowbarker commented Aug 20, 2026

Copy link
Copy Markdown
Member

Problem: Characters a generic font doesn’t cover drew as missing-glyph boxes inside SVG text; e.g. U+1D11E with font-family:serif — while the same character renders correctly in ordinary HTML text, and naming a font that does cover it renders it correctly inside SVG as well.

Cause: The SVG text path builder resolved one font for a whole run with first_available_font() — the first font in the list that covers the space character — and then handed the entire string to Skia to map through that font alone. So any code point outside it became glyph 0.

Fix: Shape each run with Gfx::shape_text() against the box’s full font list — the same way HTML text and canvas text already did. Fixes #11031.

Note

This PR branch contains two commits: The first commit has the change described above, while the second commit is entirely just deletions of the Path::text() and place_text_along() code — which no longer has any callers, after the change to using Gfx::shape_text() against the box’s full font list.

So, it might be easier to first review the first commit in isolation, and then review the deletions.

Problem: Characters a generic font doesn’t cover drew as missing-glyph
boxes inside SVG text; e.g. U+1D11E with font-family:serif — while the
same character renders correctly in ordinary HTML text, and naming a
font that does cover it renders it correctly inside SVG as well.

Cause: The SVG text path builder resolved one font for a whole run with
first_available_font() — the first font in the list that covers the
space character — and then handed the entire string to Skia to map
through that font alone. So any code point outside it became glyph 0.

Fix: Shape each run with Gfx::shape_text() against the box’s full font
list — the same way HTML text and canvas text already did.

Fixes LadybirdBrowser#11031
After SVG text path-building was reworked to build from shaped glyph
runs, Path::text() and place_text_along() no longer have any callers.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d5342da-d5db-4ff0-a8dc-70c9727aa3ee

📥 Commits

Reviewing files that changed from the base of the PR and between b4368ba and 2067bf1.

⛔ Files ignored due to path filters (3)
  • Tests/LibWeb/Screenshot/expected/svg-gradient-paint-transformation.png is excluded by !**/*.png
  • Tests/LibWeb/Screenshot/expected/svg-text-effects.png is excluded by !**/*.png
  • Tests/LibWeb/Screenshot/expected/svg-textPath.png is excluded by !**/*.png
📒 Files selected for processing (11)
  • Libraries/LibGfx/Path.h
  • Libraries/LibGfx/PathSkia.cpp
  • Libraries/LibGfx/PathSkia.h
  • Libraries/LibWeb/Layout/LayoutRustBridge.cpp
  • Tests/LibWeb/Layout/expected/css-namespace-tag-name-selector.txt
  • Tests/LibWeb/Layout/expected/svg-text-dominant-baseline.txt
  • Tests/LibWeb/Layout/expected/svg-text-with-percentage-values.txt
  • Tests/LibWeb/Layout/expected/svg-text-with-viewbox.txt
  • Tests/LibWeb/Layout/expected/svg/svg-text-positioning.txt
  • Tests/LibWeb/Ref/expected/svg-text-font-fallback-ref.html
  • Tests/LibWeb/Ref/input/svg-text-font-fallback.html

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

LibGfx replaces UTF-8 and UTF-16 text placement APIs with glyph-run placement APIs. The Skia backend transforms glyph outlines along paths using glyph positions, widths, and path tangents. SVG layout now shapes text with the complete font list for fallback support, uses glyph runs for measurement and rendering, and places them along paths. Layout expectations and SVG font-fallback tests were updated.

Sequence Diagram(s)

sequenceDiagram
  participant SVGLayout
  participant GfxShapeText
  participant PathSkia
  SVGLayout->>GfxShapeText: Shape text with the font list
  GfxShapeText-->>SVGLayout: Return glyph runs
  SVGLayout->>PathSkia: Place glyph runs along the path
  PathSkia-->>SVGLayout: Return transformed glyph outlines
Loading

Possibly related PRs

Suggested reviewers: awesomekling, kalenikaliaksandr

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes use the full font list for SVG glyph shaping and add fallback coverage, satisfying issue #11031.
Out of Scope Changes check ✅ Passed The API removals, layout updates, and test expectation changes directly support the SVG font fallback fix.
Description check ✅ Passed The description directly explains the SVG font-fallback issue, the glyph-run shaping fix, and the removal of unused path APIs.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

SVG <text> does not use fallback fonts for missing glyphs

1 participant