From: Manuel Nickschas Date: Fri, 6 Nov 2009 17:55:37 +0000 (+0100) Subject: Make sure that text lines aren't squeezed together in new Qt versions X-Git-Tag: 0.6-beta1~187 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=5bc6dee39199868071a4926ae9859daa587537f7;ds=sidebyside Make sure that text lines aren't squeezed together in new Qt versions In recent Qt 4.6 versions, there is a commit[1] that changes behavior wrt to lineSpacing() and friends. Since (at least on my box) the font leading (the distance between text lines) seems to be always -1 (for reasons as of yet unbeknownst to me), using lineSpacing() lets text lines in ChatView overlap. This workarounds this with using at least height(). [1] http://qt.gitorious.org/qt/qt/commit/04d18b38c38c5ff623b30366ea08d56128b9b7d0 --- diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index b1a071b8..c40fd34b 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -426,7 +426,8 @@ qreal ContentsChatItem::setGeometryByWidth(qreal w) { WrapColumnFinder finder(this); while(finder.nextWrapColumn(w) > 0) lines++; - qreal h = lines * fontMetrics()->lineSpacing(); + qreal spacing = qMax(fontMetrics()->lineSpacing(), fontMetrics()->height()); // cope with negative leading() + qreal h = lines * spacing; delete _data; _data = 0; @@ -443,6 +444,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { if(!wrapList.count()) return; // empty chatitem qreal h = 0; + qreal spacing = qMax(fontMetrics()->lineSpacing(), fontMetrics()->height()); // cope with negative leading() WrapColumnFinder finder(this); layout->beginLayout(); forever { @@ -469,7 +471,7 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { } line.setPosition(QPointF(0, h)); - h += fontMetrics()->lineSpacing(); + h += spacing; } layout->endLayout(); }