font stringclasses 3
values | case stringclasses 5
values | text stringclasses 5
values | path stringclasses 4
values | iou_vs_reference float64 0.07 1 | verdict stringclasses 3
values | missing_glyphs listlengths 0 8 | glyphs_ok bool 2
classes |
|---|---|---|---|---|---|---|---|
SFArabic | greeting | مرحبا بكم | raqm_plain | 1 | identical | [] | true |
SFArabic | greeting | مرحبا بكم | raqm_reshaped | 0.223 | broken | [] | true |
SFArabic | greeting | مرحبا بكم | basic_plain | 0.181 | broken | [] | true |
SFArabic | greeting | مرحبا بكم | basic_reshaped | 0.847 | recognisable | [] | true |
SFArabic | sentence | التزامنا بالنزاهة | raqm_plain | 1 | identical | [] | true |
SFArabic | sentence | التزامنا بالنزاهة | raqm_reshaped | 0.199 | broken | [] | true |
SFArabic | sentence | التزامنا بالنزاهة | basic_plain | 0.11 | broken | [] | true |
SFArabic | sentence | التزامنا بالنزاهة | basic_reshaped | 0.814 | recognisable | [] | true |
SFArabic | with_digits | في عام 2026 | raqm_plain | 1 | identical | [
"2",
"0",
"6"
] | false |
SFArabic | with_digits | في عام 2026 | raqm_reshaped | 0.27 | broken | [
"2",
"0",
"6"
] | false |
SFArabic | with_digits | في عام 2026 | basic_plain | 0.234 | broken | [
"2",
"0",
"6"
] | false |
SFArabic | with_digits | في عام 2026 | basic_reshaped | 0.839 | recognisable | [
"2",
"0",
"6"
] | false |
SFArabic | mixed_latin | شركة Pixelogik للإنتاج | raqm_plain | 1 | identical | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
SFArabic | mixed_latin | شركة Pixelogik للإنتاج | raqm_reshaped | 0.677 | recognisable | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
SFArabic | mixed_latin | شركة Pixelogik للإنتاج | basic_plain | 0.559 | broken | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
SFArabic | mixed_latin | شركة Pixelogik للإنتاج | basic_reshaped | 0.853 | recognisable | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
SFArabic | diacritics | مَرْحَبًا بِكُمْ | raqm_plain | 1 | identical | [] | true |
SFArabic | diacritics | مَرْحَبًا بِكُمْ | raqm_reshaped | 0.167 | broken | [] | true |
SFArabic | diacritics | مَرْحَبًا بِكُمْ | basic_plain | 0.172 | broken | [] | true |
SFArabic | diacritics | مَرْحَبًا بِكُمْ | basic_reshaped | 0.345 | broken | [] | true |
GeezaPro | greeting | مرحبا بكم | raqm_plain | 1 | identical | [] | true |
GeezaPro | greeting | مرحبا بكم | raqm_reshaped | 0.252 | broken | [] | true |
GeezaPro | greeting | مرحبا بكم | basic_plain | 0.166 | broken | [] | true |
GeezaPro | greeting | مرحبا بكم | basic_reshaped | 0.763 | recognisable | [] | true |
GeezaPro | sentence | التزامنا بالنزاهة | raqm_plain | 1 | identical | [] | true |
GeezaPro | sentence | التزامنا بالنزاهة | raqm_reshaped | 0.186 | broken | [] | true |
GeezaPro | sentence | التزامنا بالنزاهة | basic_plain | 0.097 | broken | [] | true |
GeezaPro | sentence | التزامنا بالنزاهة | basic_reshaped | 0.665 | recognisable | [] | true |
GeezaPro | with_digits | في عام 2026 | raqm_plain | 1 | identical | [
"2",
"0",
"6"
] | false |
GeezaPro | with_digits | في عام 2026 | raqm_reshaped | 0.102 | broken | [
"2",
"0",
"6"
] | false |
GeezaPro | with_digits | في عام 2026 | basic_plain | 0.087 | broken | [
"2",
"0",
"6"
] | false |
GeezaPro | with_digits | في عام 2026 | basic_reshaped | 0.638 | recognisable | [
"2",
"0",
"6"
] | false |
GeezaPro | mixed_latin | شركة Pixelogik للإنتاج | raqm_plain | 1 | identical | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
GeezaPro | mixed_latin | شركة Pixelogik للإنتاج | raqm_reshaped | 0.27 | broken | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
GeezaPro | mixed_latin | شركة Pixelogik للإنتاج | basic_plain | 0.195 | broken | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
GeezaPro | mixed_latin | شركة Pixelogik للإنتاج | basic_reshaped | 0.4 | broken | [
"P",
"i",
"x",
"e",
"l",
"o",
"g",
"k"
] | false |
GeezaPro | diacritics | مَرْحَبًا بِكُمْ | raqm_plain | 1 | identical | [] | true |
GeezaPro | diacritics | مَرْحَبًا بِكُمْ | raqm_reshaped | 0.099 | broken | [] | true |
GeezaPro | diacritics | مَرْحَبًا بِكُمْ | basic_plain | 0.072 | broken | [] | true |
GeezaPro | diacritics | مَرْحَبًا بِكُمْ | basic_reshaped | 0.138 | broken | [] | true |
IBMPlexSansArabic | greeting | مرحبا بكم | raqm_plain | 1 | identical | [] | true |
IBMPlexSansArabic | greeting | مرحبا بكم | raqm_reshaped | 0.167 | broken | [] | true |
IBMPlexSansArabic | greeting | مرحبا بكم | basic_plain | 0.191 | broken | [] | true |
IBMPlexSansArabic | greeting | مرحبا بكم | basic_reshaped | 0.847 | recognisable | [] | true |
IBMPlexSansArabic | sentence | التزامنا بالنزاهة | raqm_plain | 1 | identical | [] | true |
IBMPlexSansArabic | sentence | التزامنا بالنزاهة | raqm_reshaped | 0.148 | broken | [] | true |
IBMPlexSansArabic | sentence | التزامنا بالنزاهة | basic_plain | 0.117 | broken | [] | true |
IBMPlexSansArabic | sentence | التزامنا بالنزاهة | basic_reshaped | 0.678 | recognisable | [] | true |
IBMPlexSansArabic | with_digits | في عام 2026 | raqm_plain | 1 | identical | [] | true |
IBMPlexSansArabic | with_digits | في عام 2026 | raqm_reshaped | 0.129 | broken | [] | true |
IBMPlexSansArabic | with_digits | في عام 2026 | basic_plain | 0.142 | broken | [] | true |
IBMPlexSansArabic | with_digits | في عام 2026 | basic_reshaped | 0.203 | broken | [] | true |
IBMPlexSansArabic | mixed_latin | شركة Pixelogik للإنتاج | raqm_plain | 1 | identical | [] | true |
IBMPlexSansArabic | mixed_latin | شركة Pixelogik للإنتاج | raqm_reshaped | 0.149 | broken | [] | true |
IBMPlexSansArabic | mixed_latin | شركة Pixelogik للإنتاج | basic_plain | 0.142 | broken | [] | true |
IBMPlexSansArabic | mixed_latin | شركة Pixelogik للإنتاج | basic_reshaped | 0.311 | broken | [] | true |
IBMPlexSansArabic | diacritics | مَرْحَبًا بِكُمْ | raqm_plain | 1 | identical | [] | true |
IBMPlexSansArabic | diacritics | مَرْحَبًا بِكُمْ | raqm_reshaped | 0.151 | broken | [] | true |
IBMPlexSansArabic | diacritics | مَرْحَبًا بِكُمْ | basic_plain | 0.151 | broken | [] | true |
IBMPlexSansArabic | diacritics | مَرْحَبًا بِكُمْ | basic_reshaped | 0.403 | broken | [] | true |
ArShape — when does the standard Arabic rendering recipe break Arabic?
Author: Syamjith NK Write-up: The Arabic fix everyone recommends is now the thing breaking your Arabic Companion dataset: ArNum-TTS — the same failure mode in speech.
The finding
arabic_reshaper + python-bidi before drawing is the standard advice for rendering
Arabic in Python. On any renderer that already performs complex-text layout it
corrupts the output, because the shaping and the bidi reorder both happen twice.
The word is "welcome":
| rendered as | |
|---|---|
| correct (no preprocessing) | مرحبا بكم |
| after reshaper + bidi | مكب ابحرم |
Each string sits alone in its own table cell, because putting them either side of an arrow on one line lets the bidi algorithm reorder them - which, on a page about Arabic being silently reordered, is exactly the wrong mistake to make.
Whether your renderer already does this work is a runtime property, not a version number. Since Pillow 8.2.0 the wheels bundle libraqm, but libraqm links FriBiDi at runtime - so the same wheel is Raqm-enabled on one machine and not on another. Check the environment that actually renders:
import PIL.features
PIL.features.check("raqm") # True -> do NOT reshape, it is already shaping
# False -> you must reshape
The recipe was correct when it was written; text stacks caught up and the advice did not.
Correction, 2026-08-21. An earlier version of this card said "Pillow 12 links Raqm/HarfBuzz, so it already does this work." That tied the behaviour to a Pillow version, which is wrong: it is a property of the environment, not of the release. The same correction was filed upstream at python-arabic-reshaper#102.
Measured
3 Arabic fonts × 5 strings × 4 rendering paths, scored on shape similarity against a verified-correct reference:
| rendering path | identical | recognisable | broken |
|---|---|---|---|
| modern engine, text as-is | 15 | 0 | 0 |
| modern engine + reshaper + bidi | 0 | 1 | 14 |
| no shaping engine, text as-is | 0 | 0 | 15 |
| no shaping engine + reshaper + bidi | 0 | 9 | 6 |
The last row is the useful nuance: on a renderer without shaping the recipe is a partial rescue. Plain Arabic recovers, but digits, embedded Latin and diacritics still fail — positioning combining marks and resolving bidirectional runs needs real shaping regardless of what you pre-process.
Font coverage trap
Checked against the font cmap tables, not by eye: SF Arabic and Geeza Pro contain
no Latin letters or digits at all. في عام 2026 renders the year as .notdef boxes
while looking entirely correct to anyone not reading the number. IBM Plex Sans Arabic
has full coverage.
The practical version
- Check whether your renderer does complex-text layout — in Pillow,
PIL.features.check("raqm"). - If it does: pass Arabic through untouched. Do not reshape.
- If it does not: reshape, and test digits, Latin and diacritics separately, because those will still be wrong.
- Check the font actually contains every character you are about to draw.
Honesty about method
Two errors, both caught only by looking at the output rather than the score, and both recorded because they are instructive:
- The premise was backwards. I was confident reshaping was required, so I made it the reference the others were scored against — which meant the correct renderings scored worst.
- The metric compared position as well as shape, so a visually identical render scored zero because two layout engines place glyphs a few pixels apart. Fixed by normalising to the ink bounding box, then reporting three bands instead of pass/fail — which is what exposed the partial-rescue result above.
A benchmark inherits the assumptions of whoever wrote it. The only reliable way to find them is to look at the output.
Reproduce
python render_bench.py
Renders every combination to out/ and writes results.jsonl. Images are not shipped
— they regenerate in seconds and the fonts are system fonts.
The glyphs_ok column, and the trap it exposes
verdict is scored on shape similarity (IoU) against a reference render. That measures whether
the Arabic letterforms are correct. It does not measure whether every character in the string
was drawn at all.
Four rows score verdict = identical at IoU 1.000 while rendering 2026 and Pixelogik as
.notdef boxes, because SF Arabic and Geeza Pro contain no Latin glyphs or digits. The Arabic is
perfect; the rest of the string is missing.
glyphs_ok (added 21 August 2026) makes that queryable instead of leaving it in prose:
import json
rows = [json.loads(l) for l in open("results.jsonl")]
[r for r in rows if r["verdict"] == "identical" and not r["glyphs_ok"]]
# 4 rows: SFArabic/GeezaPro x with_digits/mixed_latin, raqm_plain
The published 15/15 figure is unchanged and still correct — it is a statement about shaping,
which is what this benchmark measures. glyphs_ok is a second, independent axis: font coverage.
Anyone filtering on verdict alone should filter on both.
Does Arabic Survive the Pipeline?
This is one of three reproducible benchmarks, one per stage of a real production pipeline. Each measures an Arabic failure that looks correct to anyone who does not read Arabic — which is exactly why it ships.
- ArNum-TTS — do numbers survive speech synthesis?
- ArShape — does the standard reshaping recipe survive rendering? ← you are here
- ArPDF — does Arabic survive a PDF round trip?
All three are CC BY 4.0 and ship the scorer, the raw per-item results, and an explicit statement
of what the measurement does not establish. Code is MIT (see LICENSE).
Citation
@misc{syamjithnk_arshape_2026,
author = {Syamjith NK},
title = {ArShape: Arabic shaping across text rendering paths},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/datasets/syamjithnk/arshape}},
note = {Data CC BY 4.0; code MIT}
}
- Downloads last month
- 53