From 92ae8746c412fbc87a97364eb4d86e470009f80d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 18 Feb 2020 21:43:41 +0100 Subject: Strip the quotes around the font family Due to changes in how QFont handles a family it should be given the whole string without quotes so it can find the family name correctly. Additionally, this changes it to use setFamilies instead of setFamily to make this more future-proof. Fixes: QTBUG-81926 Change-Id: I659950cf244c1f7a1a5dae6e7b0e136cfe274d47 Reviewed-by: Eirik Aavitsland --- src/svg/qsvghandler.cpp | 9 ++++++--- src/svg/qsvgstyle.cpp | 2 +- src/svg/qsvgstyle_p.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 86ca77e..afdecdc 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1361,9 +1361,12 @@ static void parseFont(QSvgNode *node, } if (!fontStyle) fontStyle = new QSvgFontStyle; - - if (!attributes.fontFamily.isEmpty() && attributes.fontFamily != QT_INHERIT) - fontStyle->setFamily(attributes.fontFamily.toString().trimmed()); + if (!attributes.fontFamily.isEmpty() && attributes.fontFamily != QT_INHERIT) { + QString family = attributes.fontFamily.toString().trimmed(); + if (family.at(0) == QLatin1Char('\'') || family.at(0) == QLatin1Char('\"')) + family = family.mid(1, family.length() - 2); + fontStyle->setFamily(family); + } if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) { // TODO: Support relative sizes 'larger' and 'smaller'. diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index c4edd25..6abedf3 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -232,7 +232,7 @@ void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states QFont font = m_oldQFont; if (m_familySet) { states.svgFont = m_svgFont; - font.setFamily(m_qfont.family()); + font.setFamilies(m_qfont.families()); } if (m_sizeSet) diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index 9d616d4..a8fb5ee 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -348,7 +348,7 @@ public: void setFamily(const QString &family) { - m_qfont.setFamily(family); + m_qfont.setFamilies({family}); m_familySet = 1; } -- cgit v1.2.1