Review Request: QTextLine positioning on right-to-left
Casper Boemann
cbr at boemann.dk
Wed Jul 6 17:55:22 BST 2011
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/101867/#review4471
-----------------------------------------------------------
Ship it!
Sounds right, great investigation.
only a single comment
libs/textlayout/KoTextLayoutArea_paint.cpp
<http://git.reviewboard.kde.org/r/101867/#comment3783>
do we need to keep this?
- Casper
On July 6, 2011, 3:04 p.m., Sebastian Sauer wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/101867/
> -----------------------------------------------------------
>
> (Updated July 6, 2011, 3:04 p.m.)
>
>
> Review request for Calligra and Casper Boemann.
>
>
> Summary
> -------
>
> Attached patch fixes QTextLine-positioning on right-to-left.
>
> During layouting it can happen that line.naturalTextWidth() > line.width. This can be reproduced with the small testapp I wrote and uploaded to http://www.2shared.com/file/AwZJc-uG/testapp.html . There just go to e.g. the 3th line, press the PosEnd-Key (to go to the beginning of the line) and add tons of spaces. Spaces seems to be handled different here cause even with left-to-right they never result in a line-break but are always added to the end (or in the case of right-to-left to the beginning) of the line what can the result in line.naturalTextWidth() > line.width. For reference also have a look at Qt's qtextdocumentlayout.cpp:2616 to the "if (QFixed::fromReal(line.naturalTextWidth()) > right-left)" block.
>
> Now on left-to-right the previous solution (aka before the patch) was and still is fine. In that case the produced QTextLine just cuts such additional spaces off on the right side. No visible harm is done. But on right-to-left the problem is that such spaces are added at the beginning of the line and therefore we cut off visible text at the right side.
>
> The patch fixes the right-to-left case by adjusting the line's position according so we make sure that the spaces at the beginning are cut off rather then text at the end. This is very similar to what Qt does with QTextEdit+QTextDocument (see the aboved linked test app).
>
> NOTE:
> An alternate solution would be to just cut off the spaces at the left without changing the line's position but seems that's way more complicated since the spaces added to the beginning somehow are always preserved. Probably cause they are detected as left-to-right rather the right-to-left. To proper handle that we would need to walk backwards once right-to-left text is detected and then change QTextFormat to have the proper layoutDirection.
> Maybe that would be an even better solution? But then we would maybe need to do the same on editing...
>
>
> Diffs
> -----
>
> libs/textlayout/KoTextLayoutArea.cpp 1308574
> libs/textlayout/KoTextLayoutArea_paint.cpp cdb42bf
> libs/textlayout/RunAroundHelper.h e358ff6
> libs/textlayout/RunAroundHelper.cpp 942aaa4
>
> Diff: http://git.reviewboard.kde.org/r/101867/diff
>
>
> Testing
> -------
>
> This solves a problem with an arabic right-to-left document I got. Since that document is confidential I am not allowed to create a BKO bug-report for it :-( But at least the author allowed me to use it to investigate the issue to produce this fix :-)
>
>
> Thanks,
>
> Sebastian
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20110706/19bb4d39/attachment.htm>
More information about the calligra-devel
mailing list