feat: add Unicode emoji support with font fallback#62
Open
adrienbrault wants to merge 3 commits intomainfrom
Open
feat: add Unicode emoji support with font fallback#62adrienbrault wants to merge 3 commits intomainfrom
adrienbrault wants to merge 3 commits intomainfrom
Conversation
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.
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.
Add comprehensive emoji rendering support using Noto Emoji font
as a fallback when text contains emoji characters.
Changes:
render using appropriate fonts (DejaVuSans for text, Noto Emoji
for emoji characters)
The implementation: