Skip to content

graphics/fonts: add Hebrew (RTL) text rendering support#941

Merged
gmarull merged 2 commits intocoredevices:mainfrom
alonmln:hebrew
Mar 11, 2026
Merged

graphics/fonts: add Hebrew (RTL) text rendering support#941
gmarull merged 2 commits intocoredevices:mainfrom
alonmln:hebrew

Conversation

@alonmln
Copy link
Copy Markdown
Contributor

@alonmln alonmln commented Mar 8, 2026

Summary

Adds Hebrew text rendering support. Hebrew notifications and UI text render right-to-left with correct glyph shapes on all Pebble targets.

BiDi renderer fix (text_layout.c, rtl_support.c): The segment-based BiDi path in walk_line() iterates UTF-8 bytes directly, bypassing char_iter. It was not filtering out invisible codepoints (ZWJ U+200D, variation selector U+FE0F, skin tone modifiers, control characters) that char_iter silently drops. These caused wildcard glyph rendering and corrupted line layout. A new prv_codepoint_is_invisible() helper is applied at all three scan sites in the BiDi path. MAX_RTL_CODEPOINTS is also raised from 16 to 32 for longer word forms.

Hebrew font glyphs (resources/): 34 Hebrew codepoints (U+05D0–U+05F4, punctuation, shekel sign U+20AA) from the Alef typeface by HaGilda & Mushon Zer-Aviv (© 2012, SIL Open Font License 1.1) are merged into all 11 base Gothic PBF sizes across both normal/ and common/ resource directories. The generator script and source TTFs are included for reproducibility.

Testing

Verified on QEMU (snowy_bb2) by injecting Hebrew phone notifications. Title and body render right-aligned and right-to-left. Mixed Hebrew/Latin text and Hebrew text containing emoji render without wildcard glyphs.

Copy link
Copy Markdown
Member

@jplexer jplexer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with adding the hebrew glyphs to the default font: they should be externally packed as a language pack

@alonmln
Copy link
Copy Markdown
Contributor Author

alonmln commented Mar 9, 2026

@jplexer Thanks for the quick response!

I totally agree with the direction, but I want to flag a use case that I think is important to get right: Hebrew speakers very commonly keep their device UI in English while still communicating in Hebrew. If we go the language pack route, Hebrew notifications would only render correctly for users who have he_IL set as their active UI language — which is probably a small minority of the target audience.

Do you have a suggestion for how to handle that? I've been thinking about a lightweight "supplement" font mechanism that sits below the language pack in the lookup chain and activates automatically for scripts like Hebrew, without requiring any UI language change. Happy to explore other directions too if you have something in mind.

@jplexer
Copy link
Copy Markdown
Member

jplexer commented Mar 9, 2026

There are language packs that are English + extra characters! They just wouldn't have anything translated (i.e. I am using a english + japanese language pack since I listen to quite a bit of music that is japanese)

@ericmigi
Copy link
Copy Markdown
Collaborator

Yes, please create a pblpack and we would be happy to add it to the list of Language Packs in the mobile app!

alonmln added 2 commits March 11, 2026 10:55
Raise MAX_RTL_CODEPOINTS from 16 to 32 in rtl_support.c to handle
longer Hebrew strings.

Overhaul text_layout.c to support correct right-to-left rendering:
- Add prv_codepoint_is_invisible() helper to skip ZWJ, variation
  selectors, skin-tone modifiers, and control characters.
- Filter invisible codepoints in prv_utf8_starts_with_rtl() and in
  BiDi segment collection so they never reach render_glyph().
- Implement a three-pass BiDi renderer: collect segments, reverse RTL
  runs, then render in visual order.
- Auto right-align lines whose dominant direction is RTL in
  prv_line_justify().

Signed-off-by: Alon Malin <alonmln@gmail.com>
Add a complete he_IL language pack using the Heebo font family
(SIL OFL 1.1). The pack covers GOTHIC_14 through GOTHIC_28 in both
regular and bold weights; Bitham, Roboto, and Droid Serif entries are
empty stubs as in all other language packs.

hebrew_codepoints.json contains the 34 Hebrew codepoints needed for
notifications: the 22 base letters (U+05D0-U+05EA), maqaf, sof passuk,
geresh, gershayim, various niqqud, and the shekel sign.

Signed-off-by: Alon Malin <alonmln@gmail.com>
@alonmln
Copy link
Copy Markdown
Contributor Author

alonmln commented Mar 11, 2026

Done! I've reworked the implementation based on the feedback.

The Hebrew glyphs are now delivered as a he_IL language pack (no changes to the base Gothic PBFs). The pack uses the Heebo typeface (SIL OFL 1.1) and covers GOTHIC_14 through GOTHIC_28 in regular and bold — the sizes used by phone notifications. Non-Gothic extended fonts are empty stubs, matching the pattern of other language packs.

Following @jplexer suggestion, the pack is English-UI-compatible: it provides font resources only (no string translations), so a user can install it while keeping their watch language set to English and still get correct Hebrew glyph rendering for notifications.

The BiDi/RTL rendering changes from the previous push are unchanged.
@ericmigi anything needed from me in the PR to create the pblpack?

@gmarull gmarull merged commit f8f5ac0 into coredevices:main Mar 11, 2026
42 checks passed
@alonmln alonmln deleted the hebrew branch March 11, 2026 20:19
@ericmigi
Copy link
Copy Markdown
Collaborator

@alonmln could you follow the template here and do a PR for the hebrew pblpack to the mobile app? Thanks! coredevices/mobileapp#121

@alonmln
Copy link
Copy Markdown
Contributor Author

alonmln commented Mar 12, 2026

Hi @ericmigi, thanks for the pointer!
I have the he_IL.pbl built and ready. Before I open the PR, where should I host the .pbl file?
Should I upload it to binaries.rebble.io/lp/ (and if so, how do I get access?), or is a raw GitHub URL acceptable like in #121?

@ericmigi
Copy link
Copy Markdown
Collaborator

raw github should be fine

@alonmln
Copy link
Copy Markdown
Contributor Author

alonmln commented Mar 13, 2026

@ericmigi awesome
Created PR - coredevices/mobileapp#134

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.

4 participants