10
66
Fork
You've already forked fcft
13

Support COLRv1 fonts #118

Open
twilligon wants to merge 2 commits from twilligon/fcft:colrv1 into master
pull from: twilligon/fcft:colrv1
merge into: dnkl:master
dnkl:master
dnkl:colrv1
dnkl:releases/3.3
dnkl:rasterize-utf8
dnkl:spacing
dnkl:releases/3.2
dnkl:releases/3.1
dnkl:releases/3.0
dnkl:releases/2.5
dnkl:releases/2.4
dnkl:releases/2.3
dnkl:releases/2.2
dnkl:releases/2.1
dnkl:releases/2.0
dnkl:releases/1.0
First-time contributor
Copy link

Fixes #114. COLRv1 color glyphs are now rendered instead of rejected. As laid out in the issue and the upstream WIP colrv1 branch, FreeType parses the paint graph, and the paint operations are implemented with pixman (look ma, no harfbuzz!).

Full disclosure up front, most of this is LLM-written. I've read all the code and don't see anything too out there (it's mostly a canvas model like Skia or HarfBuzz, mapping FreeType stuff to pixman ops, mundane to the point of tedium), but I am very willing to refactor things (e.g. if you think the colrv1 stuff should move to a separate file like the OT-SVG renderer shim).

Compositing uses color_glyphs.format, blending in gamma space when color_glyphs.srgb_decode=false and linear light when color_glyphs.srgb_decode=true (read: honoring foot's gamma-correct-blending). All COLRv1 paint formats are handled: solid, linear/radial/sweep gradients across extend modes, colr-layers, glyph, colr-glyph, translate/transform/scale/rotate/skew, composite, and clip boxes. All but sweep/rotate/skew and colr-glyph are exercised by the COLRv1 version of Noto Color Emoji, and validated both visually and by diffing rendered glyphs against a bitmap version of Noto Color Emoji. Clankers love their tests, though, so nevertheless all these formats have also been tested through "a tiny, self-contained COLRv1 test font (test-fonts/, generated by gen-colr-test-font.py)", an approach insane enough that I have not included it in this PR (I can of course add it if you want). IME, the real test is printing some emoji in foot.

The one quirk I'm aware of is our (pixman's) gradient stops are interpolated straight where the CPAL spec wants premultiplied. These only differ when a gradient stop changes color and alpha together. I did at one point implement this more exact gradient rendering, in a hacky way, and could not notice a visual difference in any emoji in any font I tested. So it seems there are very few such gradients, and when they exist, they are between near-identical colors. Given this I don't think the pedantry is worth giving up pixman's gradient rendering and rolling our own, but that is theoretically something one could do.

Fixes #114. COLRv1 color glyphs are now rendered instead of rejected. As laid out in the issue and the upstream WIP colrv1 branch, FreeType parses the paint graph, and the paint operations are implemented with pixman (look ma, no harfbuzz!). **Full disclosure up front, most of this is LLM-written.** I've read all the code and don't see anything too out there (it's mostly a canvas model like Skia or HarfBuzz, mapping FreeType stuff to pixman ops, mundane to the point of tedium), but I am very willing to refactor things (e.g. if you think the colrv1 stuff should move to a separate file like the OT-SVG renderer shim). Compositing uses color_glyphs.format, blending in gamma space when color_glyphs.srgb_decode=false and linear light when color_glyphs.srgb_decode=true (read: honoring foot's gamma-correct-blending). All COLRv1 paint formats are handled: solid, linear/radial/sweep gradients across extend modes, colr-layers, glyph, colr-glyph, translate/transform/scale/rotate/skew, composite, and clip boxes. All but sweep/rotate/skew and colr-glyph are exercised by the COLRv1 version of Noto Color Emoji, and validated both visually and by diffing rendered glyphs against a bitmap version of Noto Color Emoji. Clankers love their tests, though, so nevertheless all these formats have *also* been tested through ["a tiny, self-contained COLRv1 test font (`test-fonts/`, generated by `gen-colr-test-font.py`)"](https://codeberg.org/twilligon/fcft/commit/f8cd18af232bb85e55d763e27ac320f06586b20d), an approach insane enough that I have not included it in this PR (I can of course add it if you want). IME, the real test is printing some emoji in foot. The one quirk I'm aware of is our (pixman's) gradient stops are interpolated straight where the CPAL spec wants premultiplied. These only differ when a gradient stop changes color and alpha together. I did at one point implement this more exact gradient rendering, in a hacky way, and could not notice a visual difference in any emoji in any font I tested. So it seems there are very few such gradients, and when they exist, they are between near-identical colors. Given this I don't think the pedantry is worth giving up pixman's gradient rendering and rolling our own, but that is theoretically something one could do.
This reverts commit e600f6bb87.
fcft: render COLRv1 color glyphs with pixman
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pull_request_metadata/woodpecker Pipeline is pending approval
c11bb5a1cb
Co-authored-by: Daniel Eklöf <daniel@ekloef.se>
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pull_request_metadata/woodpecker Pipeline is pending approval
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u colrv1:twilligon-colrv1
git switch twilligon-colrv1

Merge

Merge the changes and update on Forgejo.
git switch master
git merge --no-ff twilligon-colrv1
git switch twilligon-colrv1
git rebase master
git switch master
git merge --ff-only twilligon-colrv1
git switch twilligon-colrv1
git rebase master
git switch master
git merge --no-ff twilligon-colrv1
git switch master
git merge --squash twilligon-colrv1
git switch master
git merge --ff-only twilligon-colrv1
git switch master
git merge twilligon-colrv1
git push origin master
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/fcft!118
Reference in a new issue
dnkl/fcft
No description provided.
Delete branch "twilligon/fcft:colrv1"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?