Skip to content

Bump blitz to 0.3.0-alpha.4; add DataUrlNetProvider for @font-face; expose StyleThreading#1

Open
HenriqueAnzoategui wants to merge 1 commit into
thomasmost:mainfrom
Kigo-Digital:kigo/blitz-0.3-alpha
Open

Bump blitz to 0.3.0-alpha.4; add DataUrlNetProvider for @font-face; expose StyleThreading#1
HenriqueAnzoategui wants to merge 1 commit into
thomasmost:mainfrom
Kigo-Digital:kigo/blitz-0.3-alpha

Conversation

@HenriqueAnzoategui
Copy link
Copy Markdown

@HenriqueAnzoategui HenriqueAnzoategui commented May 12, 2026

Summary

Three pieces, all needed for hyper-render to work against the current blitz release and to be usable in concurrent embedder contexts (servers rendering documents per request via tokio::task::spawn_blocking, batch pre-renderers, etc.):

  1. Bump blitz-* = "=0.3.0-alpha.4" (was 0.2). Companion bumps: anyrender 0.10, anyrender_vello_cpu 0.12.1, and the PDF-feature deps krilla 0.7, stylo 0.17, parley 0.9. stylo MUST match blitz's pin (links = "servo_style_crate"). MSRV is now Rust 1.92.

    render_to_png and render_to_pdf now take &mut HtmlDocumentblitz_paint::paint_scene requires a mutable document reference as of alpha.4.

  2. DataUrlNetProvider in src/net.rs — an in-process NetProvider resolving data: URIs synchronously. Without it, blitz-dom falls back to DummyNetProvider, which silently drops every embedded asset — that's the historical "system fonts only" / "@font-face not yet supported" limitation. With it, @font-face { src: url(data:font/...) } and inline base64 images load correctly. Non-data: URLs are still ignored; hyper-render does no real network I/O.

  3. New Config.style_threading: StyleThreading field that forwards to DocumentConfig.style_threading (introduced in blitz-dom 0.3.0-alpha.4 via dioxuslabs/blitz#437). Defaults to StyleThreading::Parallel, matching blitz's default — no behavior change for existing callers. Pass StyleThreading::Sequential to disable Stylo's global thread pool and make render safe to invoke from many OS threads concurrently.

    StyleThreading is mirrored as a hyper-render-owned enum (same pattern as ColorScheme) with a From impl for the blitz type, so the public API doesn't leak blitz_dom types.

Changes

  • Cargo.toml — dep version bumps.
  • src/net.rs (new)DataUrlNetProvider.
  • src/config.rsStyleThreading enum + field on Config + builder method.
  • src/lib.rs — wires the net provider and the style-threading field through to DocumentConfig in create_document; flips render_to_png/render_to_pdf to &mut for the new paint_scene signature.
  • src/render/png.rs / pdf.rs&mut HtmlDocument and document.as_mut() for paint_scene.
  • tests/font_face.rs (new) — integration test for @font-face with data: URI.
  • README.md / CLAUDE.md — lift the @font-face not yet supported bullet.
  • CHANGELOG.md0.3.0 entry.

Tests

  • 4 unit tests in src/net.rs for DataUrlNetProvider: base64, percent-encoded, non-data: ignored, binary payload round-trip.
  • tests/font_face.rs: renders HTML with @font-face { src: url(data:font/otf;base64,...) } and asserts a valid PNG comes out.
  • Doctest on the new style_threading builder method.

Verified locally

  • cargo fmt --all --check
  • cargo clippy --no-default-features --features png --all-targets -- -D warnings
  • cargo test --no-default-features --features png ✓ (15 passed)
  • cargo check --no-default-features --features pdf

…ading

Three pieces, all needed for hyper-render to be usable in concurrent
embedder contexts (servers rendering documents per request via
`tokio::task::spawn_blocking`, batch pre-renderers, etc.):

1. Bump `blitz-* = "=0.3.0-alpha.4"` (was `0.2`). Companion bumps:
   `anyrender 0.10`, `anyrender_vello_cpu 0.12.1`, and the PDF-feature
   deps `krilla 0.7`, `stylo 0.17`, `parley 0.9`. `stylo` MUST match
   blitz's pin (links = "servo_style_crate"). MSRV is now 1.92 per the
   new vello stack.

   `render_to_png` and `render_to_pdf` now take `&mut HtmlDocument` —
   `blitz_paint::paint_scene` requires a mutable document reference as
   of alpha.4.

2. New `DataUrlNetProvider` (src/net.rs) — an in-process `NetProvider`
   resolving `data:` URIs synchronously. blitz-dom otherwise falls
   back to `DummyNetProvider`, which silently drops every embedded
   asset — that's the historical "system fonts only" / "@font-face
   not yet supported" limitation. With this provider wired in,
   `@font-face { src: url(data:font/...) }` and inline base64 images
   load correctly. Non-`data:` URLs are still ignored; hyper-render
   does no real network I/O.

3. New `Config.style_threading: StyleThreading` field that forwards
   to `DocumentConfig.style_threading` (introduced in blitz-dom
   0.3.0-alpha.4 via DioxusLabs/blitz#437). Defaults to
   `StyleThreading::Parallel`, matching blitz's default — no behavior
   change for existing callers.

   Pass `StyleThreading::Sequential` when invoking `render` from
   multiple OS threads concurrently. Stylo's `STYLE_THREAD_POOL` is
   process-global; two `Parallel` resolves that share a rayon worker
   can panic on the worker's thread-local sharing cache (`already
   mutably borrowed`). `Sequential` bypasses the global pool at the
   `traverse_dom` call site at the cost of intra-render style
   parallelism (negligible at typical hyper-render document sizes).

   `StyleThreading` is mirrored as a hyper-render-owned enum (same
   pattern as `ColorScheme`) with a `From` impl for the blitz type,
   so the public API doesn't leak `blitz_dom` types.

Tests
-----

- 4 unit tests in `src/net.rs` for `DataUrlNetProvider`: base64,
  percent-encoded, non-`data:` ignored, binary payload round-trip.
- `tests/font_face.rs` (new): renders HTML containing
  `@font-face { src: url(data:font/otf;base64,...) }` and asserts a
  valid PNG comes out.
- Doctest on the new `style_threading` builder method.

Local verification
------------------

- `cargo fmt --all --check`
- `cargo clippy --no-default-features --features png --all-targets -- -D warnings`
- `cargo test --no-default-features --features png` (15 tests pass)
- `cargo check --no-default-features --features pdf`
@HenriqueAnzoategui HenriqueAnzoategui changed the title Enable @font-face by adding DataUrlNetProvider; bump blitz stack Bump blitz to 0.3.0-alpha.4; add DataUrlNetProvider for @font-face; expose StyleThreading May 19, 2026
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.

1 participant