Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
6.5.6
-
None
-
-
82e70e320 (dev), 72763a4d6 (6.8), b83bde860 (6.7), 4f405e9c4 (tqtc/lts-6.5)
Description
It seems like a workaround introduced in 65d96953a, which seems to be to prevent a runtime warning about negative point sizes by calculating the point size from the pixel
size, is causing a runtime warning about negative point sizes:
QFont::setPointSizeF: Point size <= 0 (-0.720000), must be greater than 0
Reverting the change, which was introduced in 6.5.6, removes the log output. The change seen below:
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp index 78002ffd..26490d07 100644 --- a/src/svg/qsvgtinydocument.cpp +++ b/src/svg/qsvgtinydocument.cpp @@ -240,6 +240,10 @@ void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds) p->setBrush(Qt::black); p->setRenderHint(QPainter::Antialiasing); p->setRenderHint(QPainter::SmoothPixmapTransform); + QFont font(p->font()); + if (font.pointSize() < 0) + font.setPointSizeF(font.pixelSize() * 72.0 / p->device()->logicalDpiY()); + p->setFont(font); QList<QSvgNode*>::iterator itr = m_renderers.begin(); applyStyle(p, m_states); while (itr != m_renderers.end()) {
Our debug output suggests that font.pixelSize() is 1, and p>device()->logicalDpiY() is 100. So the size ends up being < 0. Documentation suggests pointSize and pixelSize both return -1 if the size was set using the other property. But -1 is also the default value for both properties:
#include <QDebug> #include <QFont> int main() { QFont f; qCritical() << f.pointSizeF() << f.pixelSize(); }
The example prints -1 -1.
Attachments
Issue Links
- resulted from
-
QTBUG-122752 [Reg: 6.4.2 -> 6.5.3] QFont::setPixelSize warning when rendering svg files with painter font size set in pixels
- Closed
For Gerrit Dashboard: QTBUG-128583 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
588288,2 | Avoid further runtime warnings about negative font sizes | dev | qt/qtsvg | Status: MERGED | +2 | 0 |
588312,2 | Avoid further runtime warnings about negative font sizes | 6.8 | qt/qtsvg | Status: MERGED | +2 | 0 |
588458,2 | Avoid further runtime warnings about negative font sizes | 6.7 | qt/qtsvg | Status: MERGED | +2 | 0 |
588571,3 | Avoid further runtime warnings about negative font sizes | tqtc/lts-6.5 | qt/tqtc-qtsvg | Status: MERGED | +2 | 0 |
589173,1 | Avoid further runtime warnings about negative font sizes | tqtc/lts-6.2 | qt/tqtc-qtsvg | Status: ABANDONED | 0 | 0 |