Always prefer breaking at word boundaries

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 50ccbd2eab)
This commit is contained in:
Guillaume Munch 2016-11-06 15:14:29 +01:00
parent 8a1f936ff1
commit bac0780b27
2 changed files with 5 additions and 1 deletions

View File

@ -282,7 +282,8 @@ bool GuiFontMetrics::breakAt(docstring & s, int & x, bool const rtl, bool const
tl.setText(qs); tl.setText(qs);
tl.setFont(font_); tl.setFont(font_);
QTextOption to; QTextOption to;
to.setWrapMode(force ? QTextOption::WrapAnywhere : QTextOption::WordWrap); to.setWrapMode(force ? QTextOption::WrapAtWordBoundaryOrAnywhere
: QTextOption::WordWrap);
tl.setTextOption(to); tl.setTextOption(to);
tl.beginLayout(); tl.beginLayout();
QTextLine line = tl.createLine(); QTextLine line = tl.createLine();

View File

@ -133,6 +133,9 @@ What's new
- Fix bad painting of collapsable insets sub-label when selecting (bug 10475). - 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 * INTERNALS