DioxusLabs / DioxusLabs/blitz

SVG text renders blank wherever system fonts are unavailable (e.g. WASM); DocumentConfig.font_ctx does not reach it

Open
#897 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.1k
Forks
203
Avg merge
8h 58m
Merged PRs (30d)
112

Description

# SVG text renders blank wherever system fonts are unavailable (e.g. WASM); `DocumentConfig.font_ctx` does not reach it

## Summary

`

HTML text — uses DocumentConfig.font_ctx


```

Same binary, two targets, 420x130:

| target | HTML text | SVG text | ink pixels |
| --- | --- | --- | --- |
| host (`aarch64-apple-darwin`) | renders | renders | 5183 |
| `wasm32-wasip1` under wasmtime | renders | **blank** | 1881 |

Isolating just the SVG: native 2117 ink px, wasm **0**.

## Why it also shows up in WPT

Running the WPT runner on both targets and diffing the reports per test
(24,581 tests, 110,757 subtests) gives **zero subtest-level differences** and 17
test-level ones. All 17 are SVG-text tests, and all go native-`FAIL` →
wasm-`PASS` — the wasm side renders no text, which happens to match the
reference. So the failure is currently masked as a pass.

Examples: `css/css-pseudo/svg-text-selection-002.html`,
`css/css-masking/clip-path-svg-content/clip-path-text-001.svg`,
`css/css-text-decor/text-shadow/svg-stroke.html`.

## Suggested fix

Let callers supply the SVG font database — e.g. a `DocumentConfig.svg_font_db`,
or derive it from the faces already registered in `font_ctx` so a single
`build_single_font_ctx` call covers both paths. The latter seems closer to what
users expect, given that helper's stated purpose.

I have this working locally and can open a PR. The shape I tested:
`FONT_DB` becomes a system-font fallback behind an optional supplied database,
plus a public `register_svg_fonts(&[&[u8]])` which also sets the generic
families so `font-family: sans-serif` resolves. One call site changes.

Verified on `wasm32-wasip1`: SVG ink pixels go 0 -> matching the native render
on the repro above. Happy to reshape it if you'd rather thread the faces through
`DocumentConfig` instead.

Contributor guide

Open the contributing guide

Research direction

Start in blitz-dom/src/util.rs and trace how the private FONT_DB is used for SVG text, then compare it with DocumentConfig.font_ctx and build_single_font_ctx. Check HOWTO_WASM.md and the WPT examples named in the issue. Done means bundled fonts render SVG text on wasm32-wasip1, including generic families, without regressing native rendering.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
computer-graphics, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.