summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/mac
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-09-10 10:29:48 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-09-10 14:33:34 +0200
commit8610534f53b228d996279e1208fcf3ec0f125398 (patch)
tree635c37ca8228fd4069f7dfeca8cd907f9a7fad8f /src/platformsupport/fontdatabases/mac
parent2368e62f32e39abdad54260fa4a7b1b6018e5b04 (diff)
OSX: Properly detect language support in fonts
The language support detection in Cocoa does not report the correct set of languages for all fonts. One consequence of this is that e.g. Mkhedruli (Georgian) was not supported on Mac because the 'ka' language code was not reported for e.g. the Arial Unicode MS font. This was never detected in Qt 4, because the writing system support we set for each font was never used for font matching, since we let CoreText do the matching in Qt 4. To remedy this, we also detect writing system support based on the OS/2 table in the font. We add this in addition to the current test in case the language list has information about fonts with incomplete OS/2 tables, to avoid regressing. [ChangeLog][OS X] Fixed detection of writing system support in fonts for some scripts such as Mkhedruli. Change-Id: I26c2a42ef45112e17d6794d8798a57c8d8aaaafa Task-number: QTBUG-41208 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/platformsupport/fontdatabases/mac')
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm22
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm2
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h2
3 files changed, 25 insertions, 1 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 8e4c1c07a8..a775f745fd 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -52,6 +52,7 @@
#include "qfontengine_coretext_p.h"
#include <QtCore/QSettings>
#include <QtGui/QGuiApplication>
+#include <QtCore/QtEndian>
QT_BEGIN_NAMESPACE
@@ -262,6 +263,27 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
fd->stretch = QFont::Unstretched;
fd->fixedPitch = false;
+ if (QCFType<CTFontRef> tempFont = CTFontCreateWithFontDescriptor(font, 0.0, 0)) {
+ uint length = 0;
+ uint tag = MAKE_TAG('O', 'S', '/', '2');
+ CTFontRef tempFontRef = tempFont;
+ void *userData = reinterpret_cast<void *>(&tempFontRef);
+ if (QCoreTextFontEngine::ct_getSfntTable(userData, tag, 0, &length)) {
+ QVarLengthArray<uchar> os2Table(length);
+ if (length >= 86 && QCoreTextFontEngine::ct_getSfntTable(userData, tag, os2Table.data(), &length)) {
+ quint32 unicodeRange[4] = {
+ qFromBigEndian<quint32>(os2Table.data() + 42),
+ qFromBigEndian<quint32>(os2Table.data() + 46),
+ qFromBigEndian<quint32>(os2Table.data() + 50),
+ qFromBigEndian<quint32>(os2Table.data() + 54)
+ };
+ quint32 codePageRange[2] = { qFromBigEndian<quint32>(os2Table.data() + 78),
+ qFromBigEndian<quint32>(os2Table.data() + 82) };
+ fd->writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
+ }
+ }
+ }
+
if (styles) {
if (CFNumberRef weightValue = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
double normalizedWeight;
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 6e2c8a2a9a..f96163fc5b 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
-static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length)
+bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length)
{
CTFontRef ctfont = *(CTFontRef *)user_data;
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
index b9593b983e..e39f514878 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -118,6 +118,8 @@ public:
#endif
}
+ static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length);
+
static int antialiasingThreshold;
static QFontEngine::GlyphFormat defaultGlyphFormat;