Skip to content

feat: add Unicode emoji support with font fallback#62

Open
adrienbrault wants to merge 3 commits intomainfrom
claude/add-unicode-emoji-support-Bcj2i
Open

feat: add Unicode emoji support with font fallback#62
adrienbrault wants to merge 3 commits intomainfrom
claude/add-unicode-emoji-support-Bcj2i

Conversation

@adrienbrault
Copy link
Owner

Add comprehensive emoji rendering support using Noto Emoji font
as a fallback when text contains emoji characters.

Changes:

  • Add NotoEmoji-Regular.ttf font (monochrome, ~290KB)
  • Create emoji.py module with detection and segmentation utilities
  • Update renderer.py to automatically detect emoji in text and
    render using appropriate fonts (DejaVuSans for text, Noto Emoji
    for emoji characters)
  • Handle complex emoji: skin tone modifiers, ZWJ sequences, flags
  • Add comprehensive tests for emoji detection and rendering

The implementation:

  • Uses fast path when text has no emoji (no performance impact)
  • Segments mixed text and renders each part with correct font
  • Maintains proper baseline alignment for mixed text/emoji
  • Supports all anchor positions (mm, lt, rb, etc.)

Add comprehensive emoji rendering support using Noto Emoji font
as a fallback when text contains emoji characters.

Changes:
- Add NotoEmoji-Regular.ttf font (monochrome, ~290KB)
- Create emoji.py module with detection and segmentation utilities
- Update renderer.py to automatically detect emoji in text and
  render using appropriate fonts (DejaVuSans for text, Noto Emoji
  for emoji characters)
- Handle complex emoji: skin tone modifiers, ZWJ sequences, flags
- Add comprehensive tests for emoji detection and rendering

The implementation:
- Uses fast path when text has no emoji (no performance impact)
- Segments mixed text and renders each part with correct font
- Maintains proper baseline alignment for mixed text/emoji
- Supports all anchor positions (mm, lt, rb, etc.)
Generate sample images showcasing the new Unicode emoji support:
- 19_emoji_support.png: Grid layout with emoji in widget labels
- 20_emoji_hero.png: Hero layout with emoji text widgets

These demonstrate emoji rendering with font fallback in various
widget contexts (entity labels, text widgets, gauges).
The previous NotoEmoji-Regular.ttf was a corrupted HTML file (GitHub
redirect page), causing emoji to fall back to DejaVuSans which renders
most emoji as empty boxes.

Fixes:
- Replace with valid Noto Emoji variable font from google/fonts repo
- Use font point size directly for emoji sizing instead of measuring
  bbox height of "A" and scaling by 0.9 (which produced ~35% of the
  correct size)
- Match emoji font point size 1:1 with text font for proper visual
  balance in mixed text rendering

Regenerated sample images with corrected emoji rendering.
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.

2 participants