Skip to content

Replace ab_glyph with Skrifa + vello_cpu; enable font hinting#7694

Merged
emilk merged 16 commits intoemilk:mainfrom
valadaptive:skrifa
Dec 6, 2025
Merged

Replace ab_glyph with Skrifa + vello_cpu; enable font hinting#7694
emilk merged 16 commits intoemilk:mainfrom
valadaptive:skrifa

Conversation

@valadaptive
Copy link
Copy Markdown
Contributor

  • Closes N/A
  • I have followed the instructions in the PR template

I'll probably come back to this and clean it up a bit. This PR reimplements ab_glyph's functionality on top of Skrifa, a somewhat lower-level font API that's being used in Chrome now.

Skrifa doesn't perform rasterization itself, so I'm using vello_cpu from the Linebender project for rasterization. It's still in its early days, but I believe it's already quite fast. It also supports color and gradient fills, so color emoji support will be easier.

Skrifa also supports font hinting, which should make text look a bit nicer / less blurry.

Here's the current ab_glyph rendering:

image

Here's Skrifa without hinting--it looks almost identical, but there are some subpixel differences, probably due to rasterizer behavior:

image

Here's Skrifa with hinting:

image

Hinting does make the horizontal strokes look a bit bolder, which makes me wonder once again about increasing the font weight from "light" to "regular".

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 10, 2025

Preview available at https://egui-pr-preview.github.io/pr/7694-skrifa
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@emilk
Copy link
Copy Markdown
Owner

emilk commented Nov 14, 2025

I'm very excited for this! The readability improvements of the font hinting is pretty big imho. Also: colored emojis unlocked???

Before we merge I want to make sure we measure what impact this has on the .wasm blob size (./scripts/build_demo_web.sh --release before/after).

@nicoburns
Copy link
Copy Markdown
Contributor

Regarding the quality of the rendering, I have found that adding "font embolden" (aka stem darkening) to the skrifa-based renderers is (subjectively) a big additional improvement, at least on macOS (by tweaking the embolden parameter I can make the rendering very close if not identical to Skia/Chrome).

There's no implementation for vello_cpu yet, but there's a PR for Vello Classic, and in theory a CPU-side implementation ought to be easier.

@drewmiller
Copy link
Copy Markdown

Hey I just wanted to throw a vote behind this. Is there something blocking we at @tritium-legal can help with? Hinting on normal DPI platforms just makes a massive difference.

@emilk
Copy link
Copy Markdown
Owner

emilk commented Dec 6, 2025

wasm size on main: 10,478,576 B
wasm size with skrifa: 11,080,156 B

so +600kB. I think that's well acceptable.

@emilk emilk added feature New feature or request text Problems related to text egui epaint labels Dec 6, 2025
checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc"
dependencies = [
"kurbo",
"kurbo 0.11.1",
Copy link
Copy Markdown
Owner

@emilk emilk Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a shame we get a duplicate kurbo because of resvg, and resvg hasn't had a crate release in over 8 months :/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can fix that. I am working on a round of releases this month.

@emilk emilk self-assigned this Dec 6, 2025
@emilk emilk marked this pull request as ready for review December 6, 2025 11:26
@emilk emilk requested a review from lucasmerlin as a code owner December 6, 2025 11:44
@emilk
Copy link
Copy Markdown
Owner

emilk commented Dec 6, 2025

All snapshots look good

@emilk
Copy link
Copy Markdown
Owner

emilk commented Dec 6, 2025

I encourage everyone to follow this link to experience the improvements: https://rerun-io.github.io/kitdiff/?url=https://github.com/emilk/egui/pull/7694

@emilk emilk merged commit 609dd2d into emilk:main Dec 6, 2025
46 of 47 checks passed
@github-project-automation github-project-automation bot moved this from Next up to Done in egui Dec 6, 2025
emilk pushed a commit that referenced this pull request Dec 7, 2025
- Followup to #7694
- Disables the `traversal` feature of `skrifa` which is not needed
except internally by the fontations project
- Should save a little compile time, and possibly some binary size.

Signed-off-by: Nico Burns <[email protected]>
alltheseas added a commit to alltheseas/egui that referenced this pull request Jan 30, 2026
This adds support for rendering color emoji in egui via a new opt-in
`egui_noto_emoji` crate that bundles Noto Color Emoji sprites.

Key features:
- New `GlyphColoring` enum to distinguish color vs monochrome glyphs
- Color glyphs bypass text tinting and render with original colors
- Minimal API: `Context::register_color_glyph[_arc]` methods
- Atlas persistence: color glyphs survive font atlas rebuilds
- Deferred registration: glyphs registered before fonts init are queued

The implementation addresses feedback from PR emilk#7333 and emilk#7707:
- Fixes tinting problem (color glyphs not affected by text color)
- Handles atlas repopulation when fonts are recreated
- Aligns with skrifa+vello_cpu font backend (PR emilk#7694)
- Minimal API surface as suggested by @lucasmerlin

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
…7694)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes N/A
* [x] I have followed the instructions in the PR template

I'll probably come back to this and clean it up a bit. This PR
reimplements ab_glyph's functionality on top of Skrifa, a somewhat
lower-level font API that's being used in Chrome now.

Skrifa doesn't perform rasterization itself, so I'm using
[vello_cpu](https://github.com/linebender/vello) from the Linebender
project for rasterization. It's still in its early days, but I believe
it's already quite fast. It also supports color and gradient fills, so
color emoji support will be easier.

Skrifa also supports font hinting, which should make text look a bit
nicer / less blurry.

Here's the current ab_glyph rendering:

<img width="1592" height="1068" alt="image"
src="https://github.com/user-attachments/assets/2385b66e-23f8-4c6e-b8c2-ea90e0eea4e4"
/>

Here's Skrifa *without* hinting--it looks almost identical, but there
are some subpixel differences, probably due to rasterizer behavior:

<img width="1592" height="1068" alt="image"
src="https://github.com/user-attachments/assets/a815f3e9-65ac-4940-bc00-571177bef53d"
/>

Here's Skrifa  *with* hinting:

<img width="1592" height="1068" alt="image"
src="https://github.com/user-attachments/assets/d6cc0669-3537-4377-bba9-ed5ef09664db"
/>

Hinting does make the horizontal strokes look a bit bolder, which makes
me wonder once again about increasing the font weight from "light" to
"regular".

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
- Followup to emilk#7694
- Disables the `traversal` feature of `skrifa` which is not needed
except internally by the fontations project
- Should save a little compile time, and possibly some binary size.

Signed-off-by: Nico Burns <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

egui epaint feature New feature or request text Problems related to text

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants