diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-09-29 16:41:38 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-09-30 09:56:19 (GMT) |
commit | 4cd4160d85dc1e158a545422cac895792b14eda6 (patch) | |
tree | 8834c8c98f825047f55626354bbdc5d7dfa8eec2 /src/svg | |
parent | 086a349d770eafe007136f3dda6ef7d6093a86a9 (diff) | |
download | Qt-4cd4160d85dc1e158a545422cac895792b14eda6.zip Qt-4cd4160d85dc1e158a545422cac895792b14eda6.tar.gz Qt-4cd4160d85dc1e158a545422cac895792b14eda6.tar.bz2 |
Fixed parsing of SVGs with absolute font sizes.
Task-number: QTBUG-14070
Reviewed-by: Gunnar
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qsvghandler.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index bf19a88..c17ca7a 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1282,8 +1282,39 @@ static void parseFont(QSvgNode *node, fontStyle->setFamily(attributes.fontFamily.toString().trimmed()); if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) { + // TODO: Support relative sizes 'larger' and 'smaller'. QSvgHandler::LengthType dummy; // should always be pixel size - fontStyle->setSize(parseLength(attributes.fontSize.toString(), dummy, handler)); + qreal size = 0; + static const qreal sizeTable[] = { qreal(6.9), qreal(8.3), qreal(10.0), qreal(12.0), qreal(14.4), qreal(17.3), qreal(20.7) }; + enum AbsFontSize { XXSmall, XSmall, Small, Medium, Large, XLarge, XXLarge }; + switch (attributes.fontSize.at(0).unicode()) { + case 'x': + if (attributes.fontSize == QLatin1String("xx-small")) + size = sizeTable[XXSmall]; + else if (attributes.fontSize == QLatin1String("x-small")) + size = sizeTable[XSmall]; + else if (attributes.fontSize == QLatin1String("x-large")) + size = sizeTable[XLarge]; + else if (attributes.fontSize == QLatin1String("xx-large")) + size = sizeTable[XXLarge]; + break; + case 's': + if (attributes.fontSize == QLatin1String("small")) + size = sizeTable[Small]; + break; + case 'm': + if (attributes.fontSize == QLatin1String("medium")) + size = sizeTable[Medium]; + break; + case 'l': + if (attributes.fontSize == QLatin1String("large")) + size = sizeTable[Large]; + break; + default: + size = parseLength(attributes.fontSize.toString(), dummy, handler); + break; + } + fontStyle->setSize(size); } if (!attributes.fontStyle.isEmpty() && attributes.fontStyle != QT_INHERIT) { |