Commit Graph

16 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
7734270163 Speed-up drawing when text is not justified.
Do not cut strings at separators in RowPainter when text is not
justified. This speeds-up painting by reducing the number of strings
to draw.

Do also a modest cleanup of paintChar (remove dubious optimization).
2014-07-08 21:24:01 +02:00
Jean-Marc Lasgouttes
3013ce3716 Implement a better solution for painting of RTL text
Instead of relying on character range (Hebrew or Arabic) or character
direction, use RLO unicode character (Right-to-Left override) to force
painting in the direction indicated by the current font. This should
be as close as we can to the old LyX behavior (and requires less
code).

If this code works as intended, it will be possible to remove a lot of
code from Encodings.cpp.
2014-07-08 21:24:00 +02:00
Jean-Marc Lasgouttes
ea1a5cb80e Draw right-to-left text string-wise using Qt
We rely on Qt built-in unicode support for handling Arabic and Hebrew
compose characters. This allows to avoid to use our homegrown
machinery.

This  should provide a nice speedup at a low cost and
will eventually allow us to get rid of:
 * most of our Arabic/Hebrew machinery in Encodings.cpp,
 * Paragraph::transformChar,
 * and probably more.
2014-07-08 21:24:00 +02:00
Jean-Marc Lasgouttes
b8170e0e01 Fix various selection-related problems
All these problems are related to what happens at the extreme points of rows

 * since VIRTUAL elements have a width but no contents, they have to
   be treated specially at some places. It would have been better to
   avoid testing for them explicitly, but I did not find a way.

 * Improve and cleanup the code in breakRow and fix in passing a crash
   when clicking on the right of an incomplete MARGIN_MANUAL
   paragraph.

 * improve the computation of row width in TextMetrics::computeRowMetrics.

 * handle properly the case where a position if not found on the row
   in both cursorX and getPosNearX (actually, this happens when
   selecting).

 * Some code cleanup and comments.
2014-07-08 21:23:59 +02:00
Jean-Marc Lasgouttes
1a4b3201e7 Update README and do a small code cleanup 2014-07-08 21:23:58 +02:00
Jean-Marc Lasgouttes
f686375eec Change getColumnNearX to getPosNearX
The semantics was bad: the old implementation would return pos - row.pos(), and then all user of the function had to re-add row.pos().
2014-07-08 21:10:47 +02:00
Jean-Marc Lasgouttes
8649ac7fe6 Some fixes related to RTL text
* fix handling of boundary situations in Row::Elements::x2pos;

 * fix handling of boundary situations in TextMetrics::getColumnNearX;

 * make sure to always use Font::isVisibleRightToLeft instead of Font::isRightToLeft;

 * Improve debug messages.
2014-06-25 17:55:30 +02:00
Jean-Marc Lasgouttes
059de2d04c Fix getColumnNearX for nested insets
The horizontal position of the inset was not taken in account.
The rounding is not always the same as with the old code, but this
is not really important.

Additional changes:

 * improve debug output of rows

 * remove Bidi& argument of the RowPainter constructor, since it is always
   an empty Bifi that is passed. This means that the Bidi class is not
   used at all any more in TextMetrics.cpp. The only remaining user is
   RowPainter.
2014-06-25 17:55:30 +02:00
Jean-Marc Lasgouttes
6258cebb77 Fix line breaking algorithm
Break words longer than the screen width. The code is more complicated
than I would like, but I have no better idea right now.

Implement properly the notion of a row broken by a display inset. This is useful in different places.

Also fix a bug with last line of a paragraph spotted by Kornel.
2014-06-25 17:55:30 +02:00
Jean-Marc Lasgouttes
ff608f46fd Handle boundary in getColumnNearX (and more)
Use proper font everywhere for end-of-par marker

Fix getColumnNearX for RTL text and for centered/right-justified paragraphs.

Let computeRowMetrics update the row width.
2014-06-25 17:55:30 +02:00
Jean-Marc Lasgouttes
f215bb3b92 Re-implement getColumNearX using row elements
The code is now so much shorter that it is scary... Expect that
further changes will be necessary

Cursor boundary is not handled yet.
2014-06-25 17:55:30 +02:00
Jean-Marc Lasgouttes
35d47698c6 Convert cursorX() and computeRowMetrics() to the new scheme
* convert cursorX to new scheme; old computation is still there for the sake of comparison.

* use Row to compute separator width in computeRowMetrics; again, the old code is retained for now.

* Get rid of rowWidth()
2014-06-25 17:54:27 +02:00
Jean-Marc Lasgouttes
b2eba66083 Implement proper handling of RtL in Rows
Now the row elements are sorted according to RtL/LtR.

Some additional cleanup.
2014-06-25 17:54:26 +02:00
Jean-Marc Lasgouttes
452fb60359 Store in the Row object the list of elements it contains
* Row now contains a vector of Elements
* replace Row::dump by a proper << operator
* the width is updated as elements are added
* breakRow is reimplmented to use this infrastructure
2014-06-25 17:54:26 +02:00
Jean-Marc Lasgouttes
8539f756ed Implement real string width computation
Important features:
* widths are cached in a map
* old behavior is still used when lyxrc.force_paint_single_char is true.
2014-06-25 17:54:15 +02:00
Jean-Marc Lasgouttes
b044696d59 Add a readme file describing the state of the branch 2014-06-25 17:53:35 +02:00