Review Request: QTextLine positioning on right-to-left

Sebastian Sauer mail at dipe.org
Wed Jul 6 15:54:01 BST 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/101867/
-----------------------------------------------------------

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).


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/830b7234/attachment.htm>


More information about the calligra-devel mailing list