https://bugs.documentfoundation.org/show_bug.cgi?id=153966

Jonathan Clark <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|[email protected] |[email protected]
                   |desktop.org                 |
             Status|NEW                         |ASSIGNED

--- Comment #4 from Jonathan Clark <[email protected]> ---
This bug affects all languages, and can be reproduced in English by
right-aligning a paragraph, typing some text, and then deleting characters from
the beginning (left) of the line.

Technical details:

The root cause for this bug is precision loss while laying out right-aligned
text.

In LibreOffice, all text is internally laid out from left-to-right. This
includes RTL text (which is laid out backwards), and right-aligned text (which
is offset by its width during rendering). Due to this approach, the calculation
for a glyph's position always depends on the positions of the glyphs to its
left.

Unfortunately, floating point math is not perfectly accurate. In order to keep
stationary glyphs from vibrating during editing, their positions must be
calculated in the same manner both before and after an edit. For left-aligned
LTR text, this is the case. However, it is not true for right-aligned RTL text,
where typing always inserts to the left of the characters that should be
stationary.

Example:

Suppose you have some trivial, left-aligned LTR characters with advances A, B,
C. Their laid out X coordinates are

0, A, A+B

Then, you add another character to the end of the line, with advance D. Their X
coordinates are now

0, A, A+B, A+B+C

In both cases, the coordinates for the first three characters are calculated in
the same way. They therefore won't appear to vibrate.

Now, suppose you have right-aligned RTL characters with advances A, B, C. Their
laid out X coordinates are

(C+B)-(A+B+C), (C)-(A+B+C), 0-(A+B+C)

Then, you add another character to the end of the line, with advance D.

(D+C+B)-(A+B+C+D), (D+C)-(A+B+C+D), (D)-(A+B+C+D), (0)-(A+B+C+D)

In the real numbers, we know that the first three characters have the same
coordinate. However, floating point math is not commutative; by adding and then
subtracting D from those first three characters in this manner, an observable
amount of error is introduced.

The fix for this issue is to lay out right-aligned text from right-to-left,
rather than from left-to-right.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to