I am using QTextEdit to display Arabic text, but there are tiny gaps between the letters when I justify the text.
Here's an example of how it looks:
And I highlighted the gaps in here:
I tried changing:
Fonts.
Font weight.
Font size.
line wrap mode.
Font letter spacing (this one closed the gaps a little when i gave it a negative value, but it's not the solution).
Font word spacing.
Enabling/disabling kerning
But same problem.


The problem is caused by applying justification on Arabic letters that's meant for Latin ones.
Arabic letters cannot have spaces between them, unlike Latin letters, and since justifying text in a
QTextEditseems to mess with letter spacing, it cannot be applied to Arabic text, because it simply makes it look ugly and unpleasant to read because of the in between letters gaps.One solution that seems to work partially, is to use the stretch metric of the used font. In my case, a value of
50made the gaps almost completely disappear, but it's too tight.You can also combine it with a custom letter and word spacing, it depends on your situation and how it affects your text.
You can take a look at the result, the difference is quite noticeable.
Before:
After:
Note: