Skip to content

feat: Port text rendering from ttf-parser to skrifa (including fontdb)#1009

Open
oetiker wants to merge 1 commit intolinebender:mainfrom
oetiker:skrifa-minimal
Open

feat: Port text rendering from ttf-parser to skrifa (including fontdb)#1009
oetiker wants to merge 1 commit intolinebender:mainfrom
oetiker:skrifa-minimal

Conversation

@oetiker
Copy link
Copy Markdown
Contributor

@oetiker oetiker commented Jan 13, 2026

Summary

This replaces ttf-parser with skrifa for all font parsing and text rendering.

This is an alternative approach to #922 - see comparison below.

fontdb changes:

  • Vendor fontdb 0.23.0 as a workspace crate
  • Replace ttf-parser with skrifa for font parsing
  • Use skrifa's MetadataProvider for font attributes and metrics

usvg changes:

  • Add skrifa_colr.rs: COLR glyph painting using skrifa's ColorPainter
  • Add skrifa_metrics.rs: Font metrics extraction using skrifa
  • Update flatten.rs: Use skrifa for glyph outlines and bitmap extraction
  • Update layout.rs: Use skrifa for font metrics and harfrust for shaping
  • Replace rustybuzz with harfrust for text shaping
  • Update test reference images for new skrifa-based rendering

Comparison with #922

Aspect This PR #922
Based on main (includes variable fonts #997, Rust 2024) older base
Tests All passing ✅ 23 failing
fontdb Vendored and modified Uses existing fontdb
COLR impl New skrifa_colr.rs using ColorPainter Modified existing colr.rs
Diff size +2530/-375 (larger due to vendored fontdb) +498/-302

Key differences:

  • This PR vendors fontdb to enable the skrifa migration at the font database level
  • This PR is rebased on current main, so it includes variable font support and other recent changes
  • This PR has all tests passing with updated reference images

Test plan

  • All existing tests pass (cargo test --workspace)
  • Reference images updated for skrifa-based rendering

🤖 Generated with Claude Code

@oetiker
Copy link
Copy Markdown
Contributor Author

oetiker commented Jan 13, 2026

Diff images:

tests_text_font-variation-settings_auto-font-stretch-condensed tests_text_font-variation-settings_wght-100 tests_text_font-variation-settings_xtra-extreme tests_text_font-variation-settings_wdth-25 tests_text_font-variation-settings_wght-700 tests_text_text_zalgo tests_text_color-font_colrv0 tests_text_color-font_colrv1 tests_text_font-variation-settings_opsz-144 tests_text_font-variation-settings_explicit-overrides-auto tests_text_font-variation-settings_grad-negative tests_text_font-variation-settings_multiple-axes tests_text_font-variation-settings_auto-font-style-oblique tests_text_font-variation-settings_auto-font-weight-700 tests_text_font-variation-settings_wdth-151 tests_text_font-variation-settings_all-axes-combined tests_text_font-variation-settings_slnt-negative

This replaces ttf-parser with skrifa for all font parsing and text rendering.

fontdb changes:
- Vendor fontdb 0.23.0 as a workspace crate
- Replace ttf-parser with skrifa for font parsing
- Use skrifa's MetadataProvider for font attributes and metrics

usvg changes:
- Add skrifa_colr.rs: COLR glyph painting using skrifa's ColorPainter
- Add skrifa_metrics.rs: Font metrics extraction using skrifa
- Update flatten.rs: Use skrifa for glyph outlines and bitmap extraction
- Update layout.rs: Use skrifa for font metrics and harfrust for shaping
- Replace rustybuzz with harfrust for text shaping
- Update test reference images for new skrifa-based rendering

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@oetiker oetiker changed the title Port text rendering from ttf-parser to skrifa feat: Port text rendering from ttf-parser to skrifa Jan 30, 2026
@oetiker oetiker changed the title feat: Port text rendering from ttf-parser to skrifa feat: Port text rendering from ttf-parser to skrifa (including fontdb) Jan 30, 2026
@oetiker
Copy link
Copy Markdown
Contributor Author

oetiker commented Jan 30, 2026

anything I can do to herd this along ?

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