]> git.lyx.org Git - features.git/commitdiff
Always prefer breaking at word boundaries
authorGuillaume Munch <gm@lyx.org>
Sun, 6 Nov 2016 14:14:29 +0000 (15:14 +0100)
committerGuillaume Munch <gm@lyx.org>
Mon, 7 Nov 2016 22:28:07 +0000 (23:28 +0100)
An overlong word containing a hyphen could be broken anywhere, instead of after
the hyphen.

Example: compare the line breaking of

   aaaaa-aaaaa-aaaaa-aaaaa

with

   aaa aaaaa-aaaaa-aaaaa-aaaaa

(with a very narrow window)

This also improves Chinese text in some situations (#10299)

(cherry picked from commit 50ccbd2eab8cb01ff9f7c80d3fe726297dca6fae)

src/frontends/qt4/GuiFontMetrics.cpp
status.22x

index 1d472b5ceb0832780bcdf89bfbc16a633c30fe43..a1d5b400945a59cffe81a435e8e105bb224e28fb 100644 (file)
@@ -282,7 +282,8 @@ bool GuiFontMetrics::breakAt(docstring & s, int & x, bool const rtl, bool const
        tl.setText(qs);
        tl.setFont(font_);
        QTextOption to;
-       to.setWrapMode(force ? QTextOption::WrapAnywhere : QTextOption::WordWrap);
+       to.setWrapMode(force ? QTextOption::WrapAtWordBoundaryOrAnywhere
+                            : QTextOption::WordWrap);
        tl.setTextOption(to);
        tl.beginLayout();
        QTextLine line = tl.createLine();
index b9aed110db5506b01adde066c17c4fe58dc9a282..492f08b8bf03a58c93300ec90577334db68d6a44 100644 (file)
@@ -133,6 +133,9 @@ What's new
 
 - Fix bad painting of collapsable insets sub-label when selecting (bug 10475).
 
+- Always prefer breaking lines at word boundaries even for very long words. This
+  fixes line breaking issues most noticeably in languages where spaces are rare
+  such as Chinese (bug 10299).
 
 * INTERNALS