Skip to content

applib: treat Arabic diacritics as transparent for cursive joining#1622

Merged
gmarull merged 1 commit into
coredevices:mainfrom
kaluaim:arabic-nsm-transparency
Jun 29, 2026
Merged

applib: treat Arabic diacritics as transparent for cursive joining#1622
gmarull merged 1 commit into
coredevices:mainfrom
kaluaim:arabic-nsm-transparency

Conversation

@kaluaim

@kaluaim kaluaim commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

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_text used 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.

cmp_nsm

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 test passes.

@kaluaim
kaluaim requested review from gmarull and jplexer as code owners June 28, 2026 12:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +352 to +355
for (size_t j = i + 1; j < num_codepoints; j++) {
if (!prv_codepoint_is_transparent(codepoints[j])) {
next_cp = codepoints[j];
next_idx = j;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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>
@kaluaim
kaluaim force-pushed the arabic-nsm-transparency branch from 0af93ea to 32e82e0 Compare June 28, 2026 13:26
@ericmigi

Copy link
Copy Markdown
Collaborator

Which Arabic language pack are you using? We're looking to include one in the language drop-down

@kaluaim

kaluaim commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

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.

@gmarull
gmarull merged commit c8b69dc into coredevices:main Jun 29, 2026
42 checks passed
@ericmigi

Copy link
Copy Markdown
Collaborator

Which one do you think we should include as the default in the languages drop-down? We'll defer to the experts here 😀

@kaluaim

kaluaim commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@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 😄

@AhmedTheGeek

Copy link
Copy Markdown
Contributor

I agree with @kaluaim I tried the Vazirmatn version it looks way better than Noto.

@ericmigi

ericmigi commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

cool! can you do a PR to github.com/coredevices/mobileapp to include that file in the list of language packs please?

@ericmigi

ericmigi commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

we don't bake language packs into the OS

kaluaim added a commit to kaluaim/mobileapp that referenced this pull request Jul 3, 2026
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>
@kaluaim

kaluaim commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@ericmigi Done! → coredevices/mobileapp#280

kaluaim added a commit to kaluaim/mobileapp that referenced this pull request Jul 19, 2026
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>
sjp4 pushed a commit to coredevices/mobileapp that referenced this pull request Jul 20, 2026
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>
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