diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2024-03-11 13:15:10 +0100 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2024-03-18 10:37:17 +0100 |
commit | 863929f44639203c6678ca0f1a16e69e2d941cf0 (patch) | |
tree | a91238faf1a45b5fca36c501d2e544916313d987 | |
parent | b91081f3ab51d35f75a0e22d48d0adc6cbe832f7 (diff) |
Avoid runtime warnings about negative font sizes
The calculations assume that fonts have a point size, and not a pixel
size set. But if an svg was rendered to a paint device (eg. a widget)
that had a pixel sized font, runtime warnings would be produced, since
the point size in that case is reported as -1.
Fix by ensuring the painter is initially reset to a default, point
sized font.
Fixes: QTBUG-122752
Pick-to: 6.7 6.6 6.5 5.15
Change-Id: I5cfbb95ac3f5ac1299ae8a111bf8278836bf397b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r-- | src/svg/qsvgnode.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp index f6b52e9..8ad2240 100644 --- a/src/svg/qsvgnode.cpp +++ b/src/svg/qsvgnode.cpp @@ -615,6 +615,10 @@ void QSvgNode::initPainter(QPainter *p) 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); } bool QSvgNode::shouldDrawNode(QPainter *p, QSvgExtraStates &states) const |