Skip to content

fix(text): Keep WASM Arabic fallback in its script's font - #25817

Merged
ramezgerges merged 2 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/font-fallback-script-first
Oct 30, 2026
Merged

ramezgerges merged 2 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/font-fallback-script-first

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25816

PR Type:

🐞 Bugfix

What changed? 🚀

On WebAssembly, fallback fonts are Noto families fetched on demand. A codepoint resolved to the first already-loaded family that covers it, so the font a character got depended on what the app had shown before.

1. Letters prefer a script font over a symbol font (9888593d23, FontFallback.CoverageTable.cs)

  • Problem: Noto Sans Math covers the basic Arabic letters as bases for its Arabic math alphabet, without joining forms. Once anything loaded it (e.g. a RichEditBox showing math in "Cambria Math"), every later Arabic letter used it and rendered unjoined.
  • New rule, for letters and marks: symbol families (Noto Sans Math, Noto Sans Symbols, Noto Music) come after script families.
    • An untried script font is fetched rather than settling for a loaded symbol font.
    • The symbol font is still used when every script font fails to load, as the best one available.
  • Symbols and punctuation are unchanged: they keep reusing whatever covering font is loaded, so ∑ stays in a loaded Noto Sans Math rather than fetching Noto Sans CJK, which also covers it.
  • Retry: resolution now retries until a family is found or every candidate has been tried. Previously it gave up after one fetch batch, and the result is cached per codepoint. Each pass records an outcome for at least one untried candidate, so it always ends.

2. Shared characters stay in the run's fallback font (a3395423ba, UnicodeText.cs)

  • Problem: tatweel (U+0640), the Arabic comma and combining marks are covered by several scripts' fonts, and could resolve to another script's loaded font (Adlam, Syriac, NKo...). The font then changed mid-word, which splits the shaping run.
  • Change: a Common or Inherited character now stays in the current fallback font when that font has the glyph. A letter of its own script still gets the fallback for that script.

How it was found: Given_TextBlock.Check_FontFallback_Shaping2 timed out on the WASM WebGPU shard 7 (#25664). Bisecting the shard locally (Chrome + SwiftShader under Xvfb, as on CI) narrowed it to two earlier RichEditBox tests. With them, every Arabic letter resolved to "Noto Sans Math" and rendered 163px wide against 110px in Noto Sans Arabic. It fails the same way on the Skia renderer; the Skia WASM lane is only spared by its sharding. The "render request outstanding with no frame from the host" warnings in that shard were a red herring: the UI is idle once the first frames fail the bitmap comparison.

Tests

  • Given_FontFallbackCoverage (all Skia lanes): drives CoverageTableFontFallbackService with a small table and a fake provider.
    • Math loaded, then alef → Arabic.
    • Arabic fails to load → alef falls back to Math.
    • Math loaded, then ∑ (covered by CJK and Math) → Math, nothing else fetched.
  • Given_TextBlock.When_Other_Fallback_Fonts_Loaded_Then_Arabic_Stays_Joined (WASM): loads Noto Sans Math and Noto Sans Adlam, then renders Arabic with a tatweel. It must be as wide as the same text in Noto Sans Arabic.

Validation

  • Runtime, desktop (Win32): Given_FontFallbackCoverage + Given_FontDetailsCache + Given_TextBlock: 133/133 passed. Without the service change, the first two Given_FontFallbackCoverage cases fail.
  • Runtime, WASM WebGPU (local Chrome + SwiftShader):
    • The new test passes.
    • The minimal repro (the two RichEditBox tests, then Check_FontFallback_Shaping2) passes; it failed every time before.
    • All of shard 7: 881 passed, 0 failed (was 1 failure).
    • Not run on WASM: the new test without the fix.
  • Compile: Uno.UI.Composition.Drawing with analyzers.

PR Checklist ✅

🤖 Generated with Claude Code

ramezgerges and others added 2 commits October 29, 2026 10:45
The browser fallback reused the first already-loaded Noto family that
covers a codepoint. Noto Sans Math covers the basic Arabic letters as
bases for its Arabic math alphabet, with no joining forms, so once any
math was shown, Arabic text took it and rendered unjoined.

For letters and marks, symbol families (Noto Sans Math, Noto Sans
Symbols, Noto Music) now come after script families: an untried script
font is fetched before a loaded symbol font is settled for, and the
symbol font is still used when every script font fails to load.
Symbols and punctuation keep reusing whatever covering font is loaded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Characters several scripts share (tatweel, the Arabic comma, combining
marks) resolved to the first loaded family that covers them, which can
be another script's font. Switching fonts mid-word splits the shaping
run and breaks joining. A Common or Inherited character now stays in
the run's fallback font when that font has the glyph.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 29, 2026
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 242250 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewMode.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • AppWindowPositionAndSize.png-dark
    • AppXamlDefinedResources.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithrightmargin.png
    • AutoBorderStretchwithtopmargin.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • Battery.png-dark
    • Battery.png
    • BezierSegment.png-dark
    • BezierSegment.png
    • BitmapIcon_Monochromatic.png-dark
    • BitmapIcon_Monochromatic.png
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppBarButtonTest.png
    • AppBar_KeyBoard.png
    • ApplicationViewSpanningRectsPage.png
    • AppWindowFeatures.png
    • AppXamlDefinedResources.png
    • Attributed_text_Simple.png
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Landmark.png
    • AutomationProperties_Name.png-dark
    • AutoSuggestBox_Icons.png
    • AutoSuggestBox_Keyboard.png-dark
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png
    • Battery.png-dark
    • Battery.png
    • BezierSegment.png-dark
    • BezierSegment.png

@mergify

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@ramezgerges
ramezgerges merged commit 07fcb0d into unoplatform:master Oct 30, 2026
47 checks passed
@ramezgerges
ramezgerges deleted the dev/rara/font-fallback-script-first branch October 30, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WASM: Arabic fallback text renders unjoined after math is shown

4 participants