summaryrefslogtreecommitdiffstats
path: root/src/svg/qsvggraphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg/qsvggraphics.cpp')
-rw-r--r--src/svg/qsvggraphics.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index 6552b69..cc3c170 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -332,11 +332,12 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
// Force the font to have a size of 100 pixels to avoid truncation problems
// when the font is very small.
- qreal scale = 100.0 / p->font().pointSizeF();
+ const qreal scale = qreal(100.0) / p->font().pointSizeF();
+ const qreal inv_scale = p->font().pointSizeF() / qreal(100.0); // like '1/scale' but with less rounding errors
Qt::Alignment alignment = states.textAnchor;
QTransform oldTransform = p->worldTransform();
- p->scale(1 / scale, 1 / scale);
+ p->scale(inv_scale, inv_scale);
qreal y = 0;
bool initial = true;
@@ -346,7 +347,7 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
if (m_type == TEXTAREA) {
if (alignment == Qt::AlignHCenter)
- px += scaledSize.width() / 2;
+ px += scaledSize.width() * qreal(0.5);
else if (alignment == Qt::AlignRight)
px += scaledSize.width();
}
@@ -459,7 +460,7 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
qreal x = 0;
if (alignment == Qt::AlignHCenter)
- x -= 0.5 * line.naturalTextWidth();
+ x -= qreal(0.5) * line.naturalTextWidth();
else if (alignment == Qt::AlignRight)
x -= line.naturalTextWidth();
@@ -479,7 +480,7 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
break;
}
- y += 1.1 * line.height();
+ y += qreal(1.1) * line.height();
}
tl.draw(p, QPointF(px, py), QVector<QTextLayout::FormatRange>(), bounds);