If you have ever tried to render fully-voweled Arabic text in Flutter — especially with per-character color styling for tajweed — you have almost certainly hit a wall. Letters look wrong. Diacritics overlap. Tasydid and fathah collide into a mess instead of stacking cleanly.
We ran into this while building a Quran application that required tajweed coloring: highlighting individual segments of each verse in different colors based on their recitation rule. What seemed like a simple styling task turned into a weeks-long debugging journey through Flutter internals, browser rendering pipelines, and native Android text engines.
This article documents the full journey — what we tried, why each approach failed, and the solution that finally worked.
What Is Tajweed Coloring and Why Is It Hard?
Tajweed coloring means assigning different colors to specific character ranges within an Arabic verse. For example, a nasal sound (ghunnah) might be colored green, while a prolonged vowel (madd) is colored blue.
This requires two things to work at the same time:
- Correct Arabic shaping — ligatures, contextual letter forms, and diacritic stacking must all render accurately.
- Per-segment coloring — specific character ranges must be colored independently.
These two requirements are fundamentally at odds with how most text rendering systems work.
Why Flutter's RichText Fails for Complex Arabic Text
Flutter's standard approach to colored text is RichText with multiple TextSpan children, each with a different color. This works perfectly for Latin text. For complex Arabic, it breaks.
The Root Cause: Text Run Splitting
Flutter's text layout engine — sitting between the widget layer and the underlying HarfBuzz shaping engine — splits the text string into separate runs at every TextSpan boundary before shaping begins.
HarfBuzz needs the full string as context to correctly: