graphics/fonts: add Hebrew (RTL) text rendering support#941
graphics/fonts: add Hebrew (RTL) text rendering support#941gmarull merged 2 commits intocoredevices:mainfrom
Conversation
jplexer
left a comment
There was a problem hiding this comment.
I don't agree with adding the hebrew glyphs to the default font: they should be externally packed as a language pack
|
@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. |
|
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) |
|
Yes, please create a pblpack and we would be happy to add it to the list of Language Packs in the mobile app! |
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>
|
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. |
|
@alonmln could you follow the template here and do a PR for the hebrew pblpack to the mobile app? Thanks! coredevices/mobileapp#121 |
|
raw github should be fine |
|
@ericmigi awesome |
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 inwalk_line()iterates UTF-8 bytes directly, bypassingchar_iter. It was not filtering out invisible codepoints (ZWJ U+200D, variation selector U+FE0F, skin tone modifiers, control characters) thatchar_itersilently drops. These caused wildcard glyph rendering and corrupted line layout. A newprv_codepoint_is_invisible()helper is applied at all three scan sites in the BiDi path.MAX_RTL_CODEPOINTSis 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 bothnormal/andcommon/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.