applib: treat Arabic diacritics as transparent for cursive joining#1622
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0af93eac3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (size_t j = i + 1; j < num_codepoints; j++) { | ||
| if (!prv_codepoint_is_transparent(codepoints[j])) { | ||
| next_cp = codepoints[j]; | ||
| next_idx = j; |
There was a problem hiding this comment.
Keep layout shaping transparent-aware too
When Arabic text contains harakat, this change makes the render path shape through skipped marks, but the layout paths still measure with immediate neighbors via arabic_shape_pair() (for example src/fw/applib/graphics/text_layout.c:280, :609, and :749). A vocalized Lam-Alef such as Lam + shadda + Alef is now rendered as the ligature while layout measures the unligated letters/isolated forms, so wrapping and truncation can reserve the wrong width or break text differently from what is drawn. The transparent-neighbor logic needs to be shared with those measurement callers as well.
Useful? React with 👍 / 👎.
Arabic combining marks (harakat) sit on a base letter and must not break the cursive connection between the letters around them. Both the shaping (render) path and the layout measurement paths used each codepoint's immediate neighbours as joining context, so a mark between two letters shaped them as if disconnected: a shadda before a Lam-Alef left the ligature isolated instead of joined, and a fatha between Lam and Alef stopped them ligating at all. Vocalized words fragmented, and measured width disagreed with what was drawn (wrong wrap/truncation). Add arabic_is_transparent() and skip transparent marks (U+0610-061A, U+064B-065F, U+0670, U+06D6-06ED) when choosing the previous/next letter -- in arabic_shape_text() and in the three text_layout measurement sites (word width, RTL segment fit, line/truncation). Marks keep their own width; an Alef consumed into a Lam-Alef across a mark is skipped once. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Khalid Nuaim <i@kalua.im>
0af93ea to
32e82e0
Compare
|
Which Arabic language pack are you using? We're looking to include one in the language drop-down |
@ericmigi I'm using Vazirmatn (ar_SA-vazirmatn.pbl.zip) Not my favorite, but in my opinion the best of what worked on Pebble so far — I'll keep looking for others. @AhmedTheGeek also added ar_SA from Noto in #1333 (pack here) — so Noto or Vazirmatn both work. |
|
Which one do you think we should include as the default in the languages drop-down? We'll defer to the experts here 😀 |
|
@ericmigi I’d say Vazirmatn (ar_SA-vazirmatn.pbl.zip) for now. I’m still on the hunt for the perfect Arabic font that works with Pebble and will update you once I find it 😄 |
|
I agree with @kaluaim I tried the Vazirmatn version it looks way better than Noto. |
|
cool! can you do a PR to github.com/coredevices/mobileapp to include that file in the list of language packs please? |
|
we don't bake language packs into the OS |
Single ar_SA entry pointing at a Vazirmatn-based .pbl hosted as a GitHub release asset, with hardware: null so it applies to all supported platforms (same shape as the he_IL entry). Vazirmatn was chosen as the default Arabic font in the coredevices/PebbleOS#1622 discussion. Tested on a Core Time 2. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@ericmigi Done! → coredevices/mobileapp#280 |
Single ar_SA entry pointing at a Vazirmatn-based .pbl hosted as a GitHub release asset, with hardware: null so it applies to all supported platforms (same shape as the he_IL entry). Vazirmatn was chosen as the default Arabic font in the coredevices/PebbleOS#1622 discussion. Tested on a Core Time 2. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Single ar_SA entry pointing at a Vazirmatn-based .pbl hosted as a GitHub release asset, with hardware: null so it applies to all supported platforms (same shape as the he_IL entry). Vazirmatn was chosen as the default Arabic font in the coredevices/PebbleOS#1622 discussion. Tested on a Core Time 2. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
What
Arabic combining marks (harakat — fatha, damma, kasra, shadda, sukun…) sit on a base letter and must not break the cursive connection between the letters around them.
arabic_shape_textused each codepoint's immediate neighbours as the joining context, so a mark between two letters shaped them as if disconnected — e.g. a shadda before a Lam-Alef left the ligature isolated instead of joined. Vocalized words fragmented.Skip transparent marks (U+0610–061A, U+064B–065F, U+0670, U+06D6–06ED) when choosing the previous/next letter for shaping, and carry any mark consumed inside a Lam-Alef pair through to the output.
Before / after
Notification
ثَلَاثَة بِلَا مُلَاحَظَات(fatha / kasra / damma). Before: words fragment where the marks break the joins; after: they connect.Test
diacritic_transparent_join: a shadda between Meem and Lam-Alef keeps the Meem medial and the ligature final (U+FEFC), not isolated (U+FEFB)../pbl testpasses.