Repository navigation
vello_research: Draw glyphs with mask bitmaps from their outlines - #2122
Merged
waywardmonkeys merged 1 commit intoDec 4, 2026
Merged
waywardmonkeys merged 1 commit into
waywardmonkeys merged 1 commit into
Conversation
waywardmonkeys
force-pushed
the
fix/bitmap-mask-outline-fallback
branch
from
December 1, 2026 15:31
765b71d to
e012619
Compare
Collaborator
Author
|
LLM contributions: Generated by Opus 5.5 |
waywardmonkeys
force-pushed
the
fix/bitmap-mask-outline-fallback
branch
from
December 1, 2026 15:39
e012619 to
722dcef
Compare
waywardmonkeys
marked this pull request as ready for review
December 1, 2026 15:41
LaurenzV
approved these changes
Dec 4, 2026
LaurenzV
reviewed
Dec 4, 2026
LaurenzV
left a comment
Collaborator
There was a problem hiding this comment.
Optionally, I think some of the comments can be dropped.
| let font = skrifa::FontRef::from_index(self.run.font.data.as_ref(), font_index).unwrap(); | ||
| let bitmaps = font.bitmap_strikes(); | ||
| if font.colr().is_ok() && font.cpal().is_ok() || !bitmaps.is_empty() { | ||
| // `EBDT` strikes only hold masks, which are drawn from the outlines. |
Collaborator
There was a problem hiding this comment.
Do we need this comment here if we already mention it further below?
Comment on lines
+271
to
+273
| /// The font's glyphs have outlines, and also monochrome bitmaps in an `EBDT` strike, as Calibri's | ||
| /// do. The glyphs should be drawn from their outlines (blocky letters in the brush's color), not | ||
| /// from the bitmaps (solid boxes) or not at all. |
Collaborator
There was a problem hiding this comment.
Up to you, but it seems to me like the link to the issue should be enough.
A font with any bitmap strike took the color glyph path, where each glyph with a bitmap at any size was drawn from it. Fonts such as Calibri and Cambria have glyf outlines plus monochrome EBDT strikes, meant only for a few exact sizes. Their rows are byte-aligned, which the mask code didn't support, so those glyphs were dropped and most text vanished (linebender#2019). The mask code was also wrong for the bit-aligned masks it did accept: it didn't scale 1, 2 and 4 bpp values up to a full alpha, read the pixels in each byte in reverse, and filled with white instead of the brush. So a 1 bpp glyph drew a box at alpha 1/255. As glifo does, grayscale and monochrome masks are now never drawn; those glyphs are drawn from their outlines. Fonts whose only strikes are EBDT go straight to the outline path. Color bitmaps (PNG and BGRA, from CBDT and sbix) are drawn as before. The test font is generated by assets/ebdt/generate.py.
waywardmonkeys
force-pushed
the
fix/bitmap-mask-outline-fallback
branch
from
December 4, 2026 16:44
006d920 to
916fffc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2019.
Fonts such as Calibri and Cambria have
glyfoutlines plus monochromeEBDTstrikes, which are meant only for a few exact sizes. Any font with a bitmap strike took the color glyph path, and each glyph with a bitmap was drawn from it at any size. Calibri's bitmaps have byte-aligned rows, which the mask code skipped, so those glyphs were dropped and most text vanished.This takes glifo's approach: grayscale and monochrome masks are never drawn, and those glyphs are drawn from their outlines. Fonts whose only strikes are
EBDT(which can only hold masks) go straight to the outline path. Color bitmaps (PNG and BGRA, fromCBDTandsbix) are drawn as before.The mask code is removed rather than kept for fonts without outlines, because it was wrong for the masks it did accept: it didn't scale 1, 2 and 4 bpp values up to a full alpha, read the pixels in each byte in reverse, and filled with white instead of the brush. With the new test font, the bit-aligned glyph drew as a box at alpha 1/255. Only 8 bpp masks in fonts without outlines drew roughly right (in white); those glyphs are now not drawn, as in glifo.
The test font,
assets/ebdt/ebdt.ttf, is generated byassets/ebdt/generate.py(as for the sbix fonts). Its glyphs have outlines plus a solid-box bitmap:Awith byte-aligned rows as in Calibri,Bwith bit-aligned rows. Without the fix, the snapshot shows noAand a nearly invisible box forB. I also checked the snapshot with theEBDTshortcut disabled, so the per-glyph check is exercised too.