summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/svg/qsvggenerator.cpp17
-rw-r--r--src/svg/qsvghandler.cpp4
-rw-r--r--src/svg/qsvgstyle.cpp42
-rw-r--r--src/svg/qsvgstyle_p.h2
4 files changed, 14 insertions, 51 deletions
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp
index 91c34a5..f69e420 100644
--- a/src/svg/qsvggenerator.cpp
+++ b/src/svg/qsvggenerator.cpp
@@ -521,22 +521,7 @@ public:
else
d->attributes.font_size = QString::number(d->font.pixelSize());
- int svgWeight = d->font.weight();
- switch (svgWeight) {
- case QFont::Light:
- svgWeight = 100;
- break;
- case QFont::Normal:
- svgWeight = 400;
- break;
- case QFont::Bold:
- svgWeight = 700;
- break;
- default:
- svgWeight *= 10;
- }
-
- d->attributes.font_weight = QString::number(svgWeight);
+ d->attributes.font_weight = QString::number(d->font.weight());
d->attributes.font_family = d->font.family();
d->attributes.font_style = d->font.italic() ? QLatin1String("italic") : QLatin1String("normal");
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 62fe3d3..15fb46b 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -1369,9 +1369,9 @@ static void parseFont(QSvgNode *node,
fontStyle->setWeight(weightNum);
} else {
if (attributes.fontWeight == QLatin1String("normal")) {
- fontStyle->setWeight(400);
+ fontStyle->setWeight(QFont::Normal);
} else if (attributes.fontWeight == QLatin1String("bold")) {
- fontStyle->setWeight(700);
+ fontStyle->setWeight(QFont::Bold);
} else if (attributes.fontWeight == QLatin1String("bolder")) {
fontStyle->setWeight(QSvgFontStyle::BOLDER);
} else if (attributes.fontWeight == QLatin1String("lighter")) {
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index f36dda8..d425923 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -54,14 +54,14 @@
QT_BEGIN_NAMESPACE
QSvgExtraStates::QSvgExtraStates()
- : fillOpacity(1.0)
- , strokeOpacity(1.0)
- , svgFont(0)
- , textAnchor(Qt::AlignLeft)
- , fontWeight(400)
- , fillRule(Qt::WindingFill)
- , strokeDashOffset(0)
- , vectorEffect(false)
+ : fillOpacity(1.0),
+ strokeOpacity(1.0),
+ svgFont(0),
+ textAnchor(Qt::AlignLeft),
+ fontWeight(QFont::Normal),
+ fillRule(Qt::WindingFill),
+ strokeDashOffset(0),
+ vectorEffect(false)
{
}
@@ -199,26 +199,6 @@ QSvgFontStyle::QSvgFontStyle()
{
}
-int QSvgFontStyle::SVGToQtWeight(int weight) {
- switch (weight) {
- case 100:
- case 200:
- return QFont::Light;
- case 300:
- case 400:
- return QFont::Normal;
- case 500:
- case 600:
- return QFont::DemiBold;
- case 700:
- case 800:
- return QFont::Bold;
- case 900:
- return QFont::Black;
- }
- return QFont::Normal;
-}
-
void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
{
m_oldQFont = p->font();
@@ -246,13 +226,13 @@ void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states
if (m_weightSet) {
if (m_weight == BOLDER) {
- states.fontWeight = qMin(states.fontWeight + 100, 900);
+ states.fontWeight = qMin(states.fontWeight + 100, static_cast<int>(QFont::Black));
} else if (m_weight == LIGHTER) {
- states.fontWeight = qMax(states.fontWeight - 100, 100);
+ states.fontWeight = qMax(states.fontWeight - 100, static_cast<int>(QFont::Thin));
} else {
states.fontWeight = m_weight;
}
- font.setWeight(SVGToQtWeight(states.fontWeight));
+ font.setWeight(QFont::Weight(states.fontWeight));
}
p->setFont(font);
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index da36a20..420dd67 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -363,8 +363,6 @@ public:
m_variantSet = 1;
}
- static int SVGToQtWeight(int weight);
-
void setWeight(int weight)
{
m_weight = weight;