Repository navigation
renderText: fallback fonts and color emoji (COLR v0, CBDT) - #75
Merged
Merged
Conversation
- renderText takes a font or an array of fonts by priority: every character comes from the first font that has a glyph for it, the first font sets the line height. Kerning applies within a font, whole pixel placement follows each glyph's own font's hinting. - src/render/color.ts parses COLR version 0 layers with the first CPAL palette, and CBDT/CBLC bitmaps (index formats 1-5, image formats 17-19) from the strike closest to the size. Fonts with only bitmaps load. - Color glyphs render into a premultiplied RGBA layer over the text: layers through the rasterizer, PNGs decoded and resampled. The text color's alpha applies to them, layers in the text color take its color; outlines go around them too. - Default ignorable code points (joiners, variation selectors, tags) take no room, as HarfBuzz hides them. - Tests with subsets of Noto Color Emoji (OFL) and Twemoji Mozilla (CC-BY 4.0), license notices in tests/fonts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
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.
Image.renderTextnow takes several fonts by priority and draws color glyphs, so emoji fonts can sit next to a text font:This is the first of three steps. Emoji sequences (skin tones, flags, families, keycaps) need GSUB ligatures, which come next. COLR v1 comes after that.
Fallback fonts
Color glyphs (
src/render/color.ts)render()is now async, because PNG decoding is.Invisible characters
Default ignorable code points take no room, even when a font has glyphs for them. This covers ZWJ, the variation selectors FE0E/FE0F and tag characters. HarfBuzz hides them the same way. Twemoji, for example, has wide empty glyphs for ZWJ and FE0F, which left gaps.
Tests
tests/fonts, with license notices.emoji-cbdt.pngandemoji-colr.png.🤖 Generated with Claude Code
https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ