Jean-Marc Lasgouttes schreef op 8-5-2014 19:18:
Le 08/05/14 19:14, Kornel Benko a écrit :
Assume that I want to draw "abcde" and "bcd" is selected. Then I will
draw the string twice:
Or three times?
a
bcd
e
That is what I want to avoid. In Arabic, for example, 'a' will may a
different shape depending on whether it is at the end of a word or
followed by a 'b'.
But the real solution would be to get rid of the Color_selectiontext
thing. Is there somebody who really thinks that we need to handle this
'reverse video' selection?
I'm not sure that is the real solution. The user can always color part
of the string, or have emphasized parts or whatever.
I think the real solution then would be to use glyphs.
The function QTextLayout::glyphRuns can convert a String into glyphs
(the glyphs represent the actual characters that you see on screen, so
all arabic characters have been translated into their correct form).
Then you can draw a subset of the glyphs with QPainter::drawGlyphRun
with the correct color etc.
Vincent