Skip to content

Add skrifa + vello_cpu font rendering backend#91

Open
torokati44 wants to merge 4 commits intoPolyMeilex:masterfrom
torokati44:skrifa
Open

Add skrifa + vello_cpu font rendering backend#91
torokati44 wants to merge 4 commits intoPolyMeilex:masterfrom
torokati44:skrifa

Conversation

@torokati44
Copy link
Copy Markdown

Implements #90.

Add a skrifa feature flag as an alternative font rendering backend using skrifa for font parsing/metrics/outlines and vello_cpu for rasterization.

Priority order when multiple features are enabled:
crossfont > skrifa > ab_glyph > dumb (no text)

Usage: --features skrifa


If you'd like, I can drop the commit that adds the unit tests - they seem a bit superfluous. And then the other three commits could even be squashed into one.
The dependency versions were chosen to match the ones in egui just before their updating to wgpu 29: https://github.com/emilk/egui/blob/b077cf910297884a4f1b431e8da99806ae925168/Cargo.toml#L128-L140
This is somewhat in self-interest, because of ruffle-rs/ruffle#23274.


I don't know your (or this project's) stance on AI in general, but full disclaimer: This whole thing was generated by an LLM-powered coding agent. I have read through all of it with my own human eyes though, and nothing stood out as particularly problematic. It's also similar in size as the other two backends, and what it does is fairly straightforward.
Also I have tested it manually, and it does indeed appear to work just fine.

torokati44 added 4 commits May 8, 2026 10:51
Add a `skrifa` feature flag as an alternative font rendering backend
using skrifa for font parsing/metrics/outlines and vello_cpu for
rasterization.

Priority order when multiple features are enabled:
  crossfont > skrifa > ab_glyph > dumb (no text)

Usage: --features skrifa
Test the rendering pipeline using the bundled Cantarell font:
- renders_non_empty_pixmap: verifies output has non-zero dimensions
- renders_pixels_with_coverage: confirms glyphs produce visible pixels
- empty_title_returns_none: no pixmap for empty string
- update_scale_changes_size: scaling produces wider output
- update_color_rerenders: color change produces different pixels
- parse_bundled_font_succeeds: Cantarell parses with valid metrics

Run with: cargo test --no-default-features --features skrifa
Use HintingInstance with default options (Engine::AutoFallback,
SmoothMode::Normal) to apply hinting when drawing glyph outlines.
Falls back gracefully to unhinted rendering if the font doesn't
support it.
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