Skip to content

Add color emoji rendering for TTF fonts#582

Open
mariusandra wants to merge 1 commit into
treeform:masterfrom
mariusandra:emojis
Open

Add color emoji rendering for TTF fonts#582
mariusandra wants to merge 1 commit into
treeform:masterfrom
mariusandra:emojis

Conversation

@mariusandra

Copy link
Copy Markdown

I wanted to see how complicated it would be to get TTF emojis rendering with Pixie.

And when I say "I", I mean Claude Fable.

image

Turns out it was just $27 of tokens (part of my subscription, so nothing really).

This PS seems to works and looks all right to me... and I wouldn't mind it merged... however considering how little the effort I put into it I won't be sad/surprised to see it closed.

Happy to do more human effort if it helps get this merged.

Support all three OpenType color emoji formats:
- COLR/CPAL layered vector glyphs (Twemoji, OpenMoji, Segoe UI Emoji)
- CBDT/CBLC embedded PNG bitmaps (Noto Color Emoji)
- sbix embedded PNG bitmaps (Apple Color Emoji)

fillText draws color glyphs automatically, including through typeface
fallbacks. Bitmap strikes are selected by font size and decoded PNGs are
cached on the Typeface. New Typeface.hasColorGlyph proc.

Also:
- Bitmap-only fonts (no glyf/CFF, like Noto Color Emoji) now load.
- Platform 0 (Unicode) cmap subtables are now parsed; Apple Color Emoji
  has no Windows cmap at all.
- typeset skips zero-width format runes (ZWJ, variation selectors) so
  emoji sequences degrade into their individual emoji instead of tofu.
- strokeText skips color glyphs instead of crashing on outline-less fonts.

Tests use three tiny generated fonts (one per format, see
generate_emoji_fonts.py) plus an 11 KB subset of the real Twemoji
Mozilla COLRv0 font. Verified against full Apple Color Emoji,
Noto Color Emoji and Twemoji Mozilla.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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