From 4b2c73b4767bcb512cbc17f65186eac5d004db07 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 17 Dec 2013 09:49:40 +0200 Subject: Fix writingSystems determination by code page range bits Do exactly what windows font database does to determine writingSystems in case of non-truetype fonts. Task-number: QTBUG-13585 Change-Id: I4a1a48d74c36e403c31f20847cf80295d89a34bc Reviewed-by: Lars Knoll --- src/gui/text/qplatformfontdatabase.cpp | 44 +++++++++++++++++++++- .../platforms/windows/qwindowsfontdatabase.cpp | 3 -- .../platforms/windows/qwindowsfontdatabase_ft.cpp | 3 -- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 7076fba41b..37610a9099 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -459,10 +459,20 @@ static const ushort requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = }; enum { + Latin1CsbBit = 0, + CentralEuropeCsbBit = 1, + TurkishCsbBit = 4, + BalticCsbBit = 7, + CyrillicCsbBit = 2, + GreekCsbBit = 3, + HebrewCsbBit = 5, + ArabicCsbBit = 6, + VietnameseCsbBit = 8, SimplifiedChineseCsbBit = 18, TraditionalChineseCsbBit = 20, JapaneseCsbBit = 17, - KoreanCsbBit = 21 + KoreanCsbBit = 19, + KoreanJohabCsbBit = 21 }; /*! @@ -492,6 +502,36 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q } } } + if (codePageRange[0] & ((1 << Latin1CsbBit) | (1 << CentralEuropeCsbBit) | (1 << TurkishCsbBit) | (1 << BalticCsbBit))) { + writingSystems.setSupported(QFontDatabase::Latin); + hasScript = true; + //qDebug("font %s supports Latin", familyName.latin1()); + } + if (codePageRange[0] & (1 << CyrillicCsbBit)) { + writingSystems.setSupported(QFontDatabase::Cyrillic); + hasScript = true; + //qDebug("font %s supports Cyrillic", familyName.latin1()); + } + if (codePageRange[0] & (1 << GreekCsbBit)) { + writingSystems.setSupported(QFontDatabase::Greek); + hasScript = true; + //qDebug("font %s supports Greek", familyName.latin1()); + } + if (codePageRange[0] & (1 << HebrewCsbBit)) { + writingSystems.setSupported(QFontDatabase::Hebrew); + hasScript = true; + //qDebug("font %s supports Hebrew", familyName.latin1()); + } + if (codePageRange[0] & (1 << ArabicCsbBit)) { + writingSystems.setSupported(QFontDatabase::Arabic); + hasScript = true; + //qDebug("font %s supports Arabic", familyName.latin1()); + } + if (codePageRange[0] & (1 << VietnameseCsbBit)) { + writingSystems.setSupported(QFontDatabase::Vietnamese); + hasScript = true; + //qDebug("font %s supports Vietnamese", familyName.latin1()); + } if (codePageRange[0] & (1 << SimplifiedChineseCsbBit)) { writingSystems.setSupported(QFontDatabase::SimplifiedChinese); hasScript = true; @@ -507,7 +547,7 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q hasScript = true; //qDebug("font %s supports Japanese", familyName.latin1()); } - if (codePageRange[0] & (1 << KoreanCsbBit)) { + if (codePageRange[0] & ((1 << KoreanCsbBit) | (1 << KoreanJohabCsbBit))) { writingSystems.setSupported(QFontDatabase::Korean); hasScript = true; //qDebug("font %s supports Korean", familyName.latin1()); diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index c2c8c15a30..3a6f9f72e3 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -627,7 +627,6 @@ static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSe case EASTEUROPE_CHARSET: case BALTIC_CHARSET: case TURKISH_CHARSET: - case OEM_CHARSET: return QFontDatabase::Latin; case GREEK_CHARSET: return QFontDatabase::Greek; @@ -652,8 +651,6 @@ static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSe return QFontDatabase::Vietnamese; case SYMBOL_CHARSET: return QFontDatabase::Symbol; - // ### case MAC_CHARSET: - // ### case DEFAULT_CHARSET: default: break; } diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index 8d14adf828..51f79736f2 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -81,7 +81,6 @@ static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSe case EASTEUROPE_CHARSET: case BALTIC_CHARSET: case TURKISH_CHARSET: - case OEM_CHARSET: return QFontDatabase::Latin; case GREEK_CHARSET: return QFontDatabase::Greek; @@ -106,8 +105,6 @@ static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSe return QFontDatabase::Vietnamese; case SYMBOL_CHARSET: return QFontDatabase::Symbol; - // ### case MAC_CHARSET: - // ### case DEFAULT_CHARSET: default: break; } -- cgit v1.2.3