Get rid of requiresOpenType() helper
There is already an array of writing systems for which GSUB|GPOS table is required (also rename it from "openType" to "capabilityForWritingSystem", to reflect its meaning). Change-Id: I7cfd4a80d5ca13f9312b3644b2bd738d6015c71c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
75bd795c9f
commit
db2764db34
@ -62,12 +62,6 @@ static inline int mapToQtWeightForRange(int fcweight, int fcLower, int fcUpper,
|
||||
return qtLower + ((fcweight - fcLower) * (qtUpper - qtLower)) / (fcUpper - fcLower);
|
||||
}
|
||||
|
||||
static inline bool requiresOpenType(int writingSystem)
|
||||
{
|
||||
return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
|
||||
|| writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
|
||||
}
|
||||
|
||||
static inline int weightFromFcWeight(int fcweight)
|
||||
{
|
||||
// Font Config uses weights from 0 to 215 (the highest enum value) while QFont ranges from
|
||||
@ -293,10 +287,10 @@ static const char *languageForWritingSystem[] = {
|
||||
Q_STATIC_ASSERT(sizeof(languageForWritingSystem) / sizeof(const char *) == QFontDatabase::WritingSystemsCount);
|
||||
|
||||
#if FC_VERSION >= 20297
|
||||
// Newer FontConfig let's us sort out fonts that contain certain glyphs, but no
|
||||
// open type tables for is directly. Do this so we don't pick some strange
|
||||
// pseudo unicode font
|
||||
static const char *openType[] = {
|
||||
// Newer FontConfig let's us sort out fonts that report certain scripts support,
|
||||
// but no open type tables for handling them correctly.
|
||||
// Check the reported script presence in the FC_CAPABILITY's "otlayout:" section.
|
||||
static const char *capabilityForWritingSystem[] = {
|
||||
0, // Any
|
||||
0, // Latin
|
||||
0, // Greek
|
||||
@ -332,7 +326,7 @@ static const char *openType[] = {
|
||||
0, // Runic
|
||||
"nko " // N'Ko
|
||||
};
|
||||
Q_STATIC_ASSERT(sizeof(openType) / sizeof(const char *) == QFontDatabase::WritingSystemsCount);
|
||||
Q_STATIC_ASSERT(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritingSystem) == QFontDatabase::WritingSystemsCount);
|
||||
#endif
|
||||
|
||||
static const char *getFcFamilyForStyleHint(const QFont::StyleHint style)
|
||||
@ -438,11 +432,10 @@ static void populateFromPattern(FcPattern *pattern)
|
||||
#if FC_VERSION >= 20297
|
||||
FcChar8 *cap = Q_NULLPTR;
|
||||
for (int j = 1; j < QFontDatabase::WritingSystemsCount; ++j) {
|
||||
if (writingSystems.supported(QFontDatabase::WritingSystem(j))
|
||||
&& requiresOpenType(j) && openType[j]) {
|
||||
if (capabilityForWritingSystem[j] && writingSystems.supported(QFontDatabase::WritingSystem(j))) {
|
||||
if (cap == Q_NULLPTR)
|
||||
res = FcPatternGetString(pattern, FC_CAPABILITY, 0, &cap);
|
||||
if (res == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), openType[j]) == 0)
|
||||
if (res == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), capabilityForWritingSystem[j]) == 0)
|
||||
writingSystems.setSupported(QFontDatabase::WritingSystem(j),false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user