]> git.lyx.org Git - features.git/commit
Fix computation of string width when using a QTextLayout
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 28 Aug 2017 10:05:35 +0000 (12:05 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 29 Aug 2017 13:15:39 +0000 (15:15 +0200)
commit48904cc5a1bfb1b80182fb36e140c9bb48ffb22d
tree2dd75c26fcb679a24b5557b360bfbdf19a4de3a2
parent6b0509da0cec235b86af73e2ee34b5e2ed7a63e3
Fix computation of string width when using a QTextLayout

It was not a good idea to rely on QTextLine::naturalTextWidth() to
compute a string width. The correct method is horizontalAdvance().

Also round the value to the nearest pixel, since this is what
QFontMetrics::width() does.

By contrast with the code in 2.3.x/master, this code had to be adapted
for Qt < 4.7, where horizontalAdvance() is not defined and
naturalTextWidth() has to be used instead. The fix is thus only
effective starting from Qt 4.7.

Fixes bug #10700 (and maybe others).

(cherry picked from commit c874641e95b763a6d4691fb12fba893580f3018a)
src/frontends/qt4/GuiFontMetrics.cpp
status.22x