Fix compatibility with Qt 5.9.
This commit is contained in:
parent
2d512e57b2
commit
1fb9d82f61
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringView>
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto LatinWritingSystem(QChar c) -> bool
|
auto LatinWritingSystem(QChar c) -> bool
|
||||||
|
@ -1486,6 +1485,7 @@ auto NkoWritingSystem(QChar c) -> bool
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto WritingSystemSample(SVGFontWritingSystem writingSystem) -> QString
|
auto WritingSystemSample(SVGFontWritingSystem writingSystem) -> QString
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
return [&]() -> QStringView
|
return [&]() -> QStringView
|
||||||
{
|
{
|
||||||
switch (writingSystem)
|
switch (writingSystem)
|
||||||
|
@ -1563,4 +1563,222 @@ auto WritingSystemSample(SVGFontWritingSystem writingSystem) -> QString
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
.toString();
|
.toString();
|
||||||
|
#else
|
||||||
|
QString sample;
|
||||||
|
switch (writingSystem)
|
||||||
|
{
|
||||||
|
case SVGFontWritingSystem::Any:
|
||||||
|
case SVGFontWritingSystem::Symbol:
|
||||||
|
sample += QLatin1String("AaBbzZ");
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Latin:
|
||||||
|
sample = QLatin1String("Aa");
|
||||||
|
sample += QChar(0x00C3);
|
||||||
|
sample += QChar(0x00E1);
|
||||||
|
sample += QLatin1String("Zz");
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Greek:
|
||||||
|
sample += QChar(0x0393);
|
||||||
|
sample += QChar(0x03B1);
|
||||||
|
sample += QChar(0x03A9);
|
||||||
|
sample += QChar(0x03C9);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Cyrillic:
|
||||||
|
sample += QChar(0x0414);
|
||||||
|
sample += QChar(0x0434);
|
||||||
|
sample += QChar(0x0436);
|
||||||
|
sample += QChar(0x044f);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Armenian:
|
||||||
|
sample += QChar(0x053f);
|
||||||
|
sample += QChar(0x054f);
|
||||||
|
sample += QChar(0x056f);
|
||||||
|
sample += QChar(0x057f);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Hebrew:
|
||||||
|
sample += QChar(0x05D0);
|
||||||
|
sample += QChar(0x05D1);
|
||||||
|
sample += QChar(0x05D2);
|
||||||
|
sample += QChar(0x05D3);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Arabic:
|
||||||
|
sample += QChar(0x0623);
|
||||||
|
sample += QChar(0x0628);
|
||||||
|
sample += QChar(0x062C);
|
||||||
|
sample += QChar(0x062F);
|
||||||
|
sample += QChar(0x064A);
|
||||||
|
sample += QChar(0x0629);
|
||||||
|
sample += QChar(0x0020);
|
||||||
|
sample += QChar(0x0639);
|
||||||
|
sample += QChar(0x0631);
|
||||||
|
sample += QChar(0x0628);
|
||||||
|
sample += QChar(0x064A);
|
||||||
|
sample += QChar(0x0629);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Syriac:
|
||||||
|
sample += QChar(0x0715);
|
||||||
|
sample += QChar(0x0725);
|
||||||
|
sample += QChar(0x0716);
|
||||||
|
sample += QChar(0x0726);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Thaana:
|
||||||
|
sample += QChar(0x0784);
|
||||||
|
sample += QChar(0x0794);
|
||||||
|
sample += QChar(0x078c);
|
||||||
|
sample += QChar(0x078d);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Devanagari:
|
||||||
|
sample += QChar(0x0905);
|
||||||
|
sample += QChar(0x0915);
|
||||||
|
sample += QChar(0x0925);
|
||||||
|
sample += QChar(0x0935);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Bengali:
|
||||||
|
sample += QChar(0x0986);
|
||||||
|
sample += QChar(0x0996);
|
||||||
|
sample += QChar(0x09a6);
|
||||||
|
sample += QChar(0x09b6);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Gurmukhi:
|
||||||
|
sample += QChar(0x0a05);
|
||||||
|
sample += QChar(0x0a15);
|
||||||
|
sample += QChar(0x0a25);
|
||||||
|
sample += QChar(0x0a35);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Gujarati:
|
||||||
|
sample += QChar(0x0a85);
|
||||||
|
sample += QChar(0x0a95);
|
||||||
|
sample += QChar(0x0aa5);
|
||||||
|
sample += QChar(0x0ab5);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Oriya:
|
||||||
|
sample += QChar(0x0b06);
|
||||||
|
sample += QChar(0x0b16);
|
||||||
|
sample += QChar(0x0b2b);
|
||||||
|
sample += QChar(0x0b36);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Tamil:
|
||||||
|
sample += QChar(0x0b89);
|
||||||
|
sample += QChar(0x0b99);
|
||||||
|
sample += QChar(0x0ba9);
|
||||||
|
sample += QChar(0x0bb9);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Telugu:
|
||||||
|
sample += QChar(0x0c05);
|
||||||
|
sample += QChar(0x0c15);
|
||||||
|
sample += QChar(0x0c25);
|
||||||
|
sample += QChar(0x0c35);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Kannada:
|
||||||
|
sample += QChar(0x0c85);
|
||||||
|
sample += QChar(0x0c95);
|
||||||
|
sample += QChar(0x0ca5);
|
||||||
|
sample += QChar(0x0cb5);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Malayalam:
|
||||||
|
sample += QChar(0x0d05);
|
||||||
|
sample += QChar(0x0d15);
|
||||||
|
sample += QChar(0x0d25);
|
||||||
|
sample += QChar(0x0d35);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Sinhala:
|
||||||
|
sample += QChar(0x0d90);
|
||||||
|
sample += QChar(0x0da0);
|
||||||
|
sample += QChar(0x0db0);
|
||||||
|
sample += QChar(0x0dc0);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Thai:
|
||||||
|
sample += QChar(0x0e02);
|
||||||
|
sample += QChar(0x0e12);
|
||||||
|
sample += QChar(0x0e22);
|
||||||
|
sample += QChar(0x0e32);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Lao:
|
||||||
|
sample += QChar(0x0e8d);
|
||||||
|
sample += QChar(0x0e9d);
|
||||||
|
sample += QChar(0x0ead);
|
||||||
|
sample += QChar(0x0ebd);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Tibetan:
|
||||||
|
sample += QChar(0x0f00);
|
||||||
|
sample += QChar(0x0f01);
|
||||||
|
sample += QChar(0x0f02);
|
||||||
|
sample += QChar(0x0f03);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Myanmar:
|
||||||
|
sample += QChar(0x1000);
|
||||||
|
sample += QChar(0x1001);
|
||||||
|
sample += QChar(0x1002);
|
||||||
|
sample += QChar(0x1003);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Georgian:
|
||||||
|
sample += QChar(0x10a0);
|
||||||
|
sample += QChar(0x10b0);
|
||||||
|
sample += QChar(0x10c0);
|
||||||
|
sample += QChar(0x10d0);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Khmer:
|
||||||
|
sample += QChar(0x1780);
|
||||||
|
sample += QChar(0x1790);
|
||||||
|
sample += QChar(0x17b0);
|
||||||
|
sample += QChar(0x17c0);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::SimplifiedChinese:
|
||||||
|
sample += QChar(0x4e2d);
|
||||||
|
sample += QChar(0x6587);
|
||||||
|
sample += QChar(0x8303);
|
||||||
|
sample += QChar(0x4f8b);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::TraditionalChinese:
|
||||||
|
sample += QChar(0x4e2d);
|
||||||
|
sample += QChar(0x6587);
|
||||||
|
sample += QChar(0x7bc4);
|
||||||
|
sample += QChar(0x4f8b);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Japanese:
|
||||||
|
sample += QChar(0x30b5);
|
||||||
|
sample += QChar(0x30f3);
|
||||||
|
sample += QChar(0x30d7);
|
||||||
|
sample += QChar(0x30eb);
|
||||||
|
sample += QChar(0x3067);
|
||||||
|
sample += QChar(0x3059);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Korean:
|
||||||
|
sample += QChar(0xac00);
|
||||||
|
sample += QChar(0xac11);
|
||||||
|
sample += QChar(0xac1a);
|
||||||
|
sample += QChar(0xac2f);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Vietnamese:
|
||||||
|
{
|
||||||
|
static const char vietnameseUtf8[] = {
|
||||||
|
char(0xef), char(0xbb), char(0xbf), char(0xe1), char(0xbb), char(0x97), char(0xe1), char(0xbb),
|
||||||
|
char(0x99), char(0xe1), char(0xbb), char(0x91), char(0xe1), char(0xbb), char(0x93),
|
||||||
|
};
|
||||||
|
sample += QString::fromUtf8(vietnameseUtf8, sizeof(vietnameseUtf8));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SVGFontWritingSystem::Ogham:
|
||||||
|
sample += QChar(0x1681);
|
||||||
|
sample += QChar(0x1682);
|
||||||
|
sample += QChar(0x1683);
|
||||||
|
sample += QChar(0x1684);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Runic:
|
||||||
|
sample += QChar(0x16a0);
|
||||||
|
sample += QChar(0x16a1);
|
||||||
|
sample += QChar(0x16a2);
|
||||||
|
sample += QChar(0x16a3);
|
||||||
|
break;
|
||||||
|
case SVGFontWritingSystem::Nko:
|
||||||
|
sample += QChar(0x7ca);
|
||||||
|
sample += QChar(0x7cb);
|
||||||
|
sample += QChar(0x7cc);
|
||||||
|
sample += QChar(0x7cd);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sample;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ auto ParseFontWeight(const QString &fontWeight) -> SVGFontWeight
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto InitFont(const QXmlStreamAttributes &fontAttr) -> VSvgFont
|
auto InitFont(const QXmlStreamAttributes &fontAttr) -> VSvgFont
|
||||||
{
|
{
|
||||||
const QStringView hax = fontAttr.value(QLatin1String("horiz-adv-x"));
|
const auto hax = fontAttr.value(QLatin1String("horiz-adv-x"));
|
||||||
qreal horizAdvX = hax.toDouble();
|
qreal horizAdvX = hax.toDouble();
|
||||||
|
|
||||||
QString id = fontAttr.value(QLatin1String("id")).toString();
|
QString id = fontAttr.value(QLatin1String("id")).toString();
|
||||||
|
@ -332,7 +332,7 @@ void VSvgFontReader::SetFontFace(VSvgFont *font)
|
||||||
{
|
{
|
||||||
QXmlStreamAttributes fontFaceAttr = attributes();
|
QXmlStreamAttributes fontFaceAttr = attributes();
|
||||||
QString fontFamily = fontFaceAttr.value(QLatin1String("font-family")).toString();
|
QString fontFamily = fontFaceAttr.value(QLatin1String("font-family")).toString();
|
||||||
const QStringView unitsPerEmStr = fontFaceAttr.value(QLatin1String("units-per-em"));
|
const auto unitsPerEmStr = fontFaceAttr.value(QLatin1String("units-per-em"));
|
||||||
|
|
||||||
qreal unitsPerEm = unitsPerEmStr.toDouble();
|
qreal unitsPerEm = unitsPerEmStr.toDouble();
|
||||||
if (qFuzzyIsNull(unitsPerEm))
|
if (qFuzzyIsNull(unitsPerEm))
|
||||||
|
@ -340,14 +340,14 @@ void VSvgFontReader::SetFontFace(VSvgFont *font)
|
||||||
unitsPerEm = 1000;
|
unitsPerEm = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringView ascentStr = fontFaceAttr.value(QLatin1String("ascent"));
|
const auto ascentStr = fontFaceAttr.value(QLatin1String("ascent"));
|
||||||
qreal ascent = ascentStr.toDouble();
|
qreal ascent = ascentStr.toDouble();
|
||||||
if (qFuzzyIsNull(ascent))
|
if (qFuzzyIsNull(ascent))
|
||||||
{
|
{
|
||||||
ascent = 800;
|
ascent = 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringView descentStr = fontFaceAttr.value(QLatin1String("descent"));
|
const auto descentStr = fontFaceAttr.value(QLatin1String("descent"));
|
||||||
qreal descent = descentStr.toDouble();
|
qreal descent = descentStr.toDouble();
|
||||||
if (qFuzzyIsNull(descent))
|
if (qFuzzyIsNull(descent))
|
||||||
{
|
{
|
||||||
|
@ -392,9 +392,9 @@ void VSvgFontReader::SetFontFace(VSvgFont *font)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSvgFontReader::ParseSvgGlyph(VSvgFontEngine *engine, const QXmlStreamAttributes &glyphAttr)
|
void VSvgFontReader::ParseSvgGlyph(VSvgFontEngine *engine, const QXmlStreamAttributes &glyphAttr)
|
||||||
{
|
{
|
||||||
QStringView uncStr = glyphAttr.value(QLatin1String("unicode"));
|
auto uncStr = glyphAttr.value(QLatin1String("unicode"));
|
||||||
QStringView havStr = glyphAttr.value(QLatin1String("horiz-adv-x"));
|
auto havStr = glyphAttr.value(QLatin1String("horiz-adv-x"));
|
||||||
QStringView pathStr = glyphAttr.value(QLatin1String("d"));
|
auto pathStr = glyphAttr.value(QLatin1String("d"));
|
||||||
|
|
||||||
QChar unicode = (uncStr.isEmpty()) ? u'\0' : uncStr.at(0);
|
QChar unicode = (uncStr.isEmpty()) ? u'\0' : uncStr.at(0);
|
||||||
qreal havx = (havStr.isEmpty()) ? -1 : havStr.toDouble();
|
qreal havx = (havStr.isEmpty()) ? -1 : havStr.toDouble();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user