The old implementation of Row::Element::pos2x and x2pos did not work
correctly with Arabic text, because characters can have shapes that
depend on context.
This new implementation leverages QTextLayout in a simplified way,
since only one word is added to the layout.
This allows to make Row::Element::x2pos more readable.
Fixes: #9115.
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).
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.
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.
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.
The fact that the bug was still present in the features/str-metrics
branch comes from a goof in the initial implementation of 'virtual'
row elements (completion and end-of-par markers). Now that this is
corrected, everything works as it should.
The fact that the bug is present in master is due to some other reason
that is not useful to investigate now.
* 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.
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.
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.
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.
* 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()
* 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
Collect properly all strings to compute string metrics
Some changes with respect to existing code
- end of paragraph font is now the one of the text
- words longer than a line are not broken anymore. I think this is not useful if we have horizontal scrollbar
Other than that, the code is still compatible with rowWidth and friends.
The configuration time suffers mostly on checking, which of the export tests
is to be reverted.
1.) There is a new configuration flag now, "LYX_ENABLE_EXOPRT_TESTS.
If not set (default) no export tests are created.
2.) If set, then the optimization halves the time needed for creation of tests.
The effect on my side:
a.) Until now the time was: ~ 26 seconds
b.) The optimized time is now: ~ 16 seconds
c.) With not enabled export tests: ~ 5 seconds
The magic library can detect the charset used by a file. While this
detection is not full proof, actually the library seems to be infallible
as regards the binary nature of a file. So, use libmagic for the detection
and fallback to the previous method if the library is not installed or
its database cannot be loaded.
On startup, the default locale is "C", meaning that all system
functions assume an ascii codeset. The environment's locale
settings should be selected by calling setlocale(LC_ALL,"").
This is done by Qt during the QCoreApplication initialization
but this inizialization is never performed for batch processing
and, as a result, LyX is not able to process files whose names
contain non-ascii characters. This is not an issue on Windows,
where the file names are always stored as UTF-16, so the call is
only performed for unix-like platforms (this also includes cygwin,
due to its own filenames management that allows using characters
which are forbidden to native programs).