summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraavit <qt_aavit@ovi.com>2011-12-02 13:52:17 +0100
committeraavit <qt_aavit@ovi.com>2011-12-02 13:52:17 +0100
commit8762666d8b6854089ea35bb61ced690cdd59791c (patch)
tree4459aaebd84de23db6fc53d0ff6d3c5edacc8c5b
parent46db88be9fb0b8951916d706c39e1079f38f277d (diff)
parentbc25cfdd65452efa226cbd544c9ae9803eb6748a (diff)
downloadqt4-tools-8762666d8b6854089ea35bb61ced690cdd59791c.tar.gz
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-team
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp54
-rw-r--r--src/gui/text/qfontengine_coretext.mm10
-rw-r--r--src/gui/text/qfontengine_coretext_p.h1
3 files changed, 61 insertions, 4 deletions
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index 81500c73fa..a96224c53a 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -84,6 +84,46 @@ qDebug() << "first char" << hex << unicodeRange[0];
for (int i = 0; i < systems.count(); ++i)
family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
}
+#else
+// this could become a list of all languages used for each writing
+// system, instead of using the single most common language.
+static const char *languageForWritingSystem[] = {
+ 0, // Any
+ "en", // Latin
+ "el", // Greek
+ "ru", // Cyrillic
+ "hy", // Armenian
+ "he", // Hebrew
+ "ar", // Arabic
+ "syr", // Syriac
+ "div", // Thaana
+ "hi", // Devanagari
+ "bn", // Bengali
+ "pa", // Gurmukhi
+ "gu", // Gujarati
+ "or", // Oriya
+ "ta", // Tamil
+ "te", // Telugu
+ "kn", // Kannada
+ "ml", // Malayalam
+ "si", // Sinhala
+ "th", // Thai
+ "lo", // Lao
+ "bo", // Tibetan
+ "my", // Myanmar
+ "ka", // Georgian
+ "km", // Khmer
+ "zh-cn", // SimplifiedChinese
+ "zh-tw", // TraditionalChinese
+ "ja", // Japanese
+ "ko", // Korean
+ "vi", // Vietnamese
+ 0, // Symbol
+ 0, // Ogham
+ 0, // Runic
+ 0 // N'Ko
+};
+enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
#endif
static void initializeDb()
@@ -107,8 +147,18 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
QCFString family_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL);
QCFString style_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL);
QtFontFamily *family = db->family(family_name, true);
- for(int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws)
- family->writingSystems[ws] = QtFontFamily::Supported;
+
+ if (QCFType<CFArrayRef> languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) {
+ CFIndex length = CFArrayGetCount(languages);
+ for (int i = 1; i < LanguageCount; ++i) {
+ if (!languageForWritingSystem[i])
+ continue;
+ QCFString lang = CFStringCreateWithCString(NULL, languageForWritingSystem[i], kCFStringEncodingASCII);
+ if (CFArrayContainsValue(languages, CFRangeMake(0, length), lang))
+ family->writingSystems[i] = QtFontFamily::Supported;
+ }
+ }
+
QtFontFoundry *foundry = family->foundry(foundry_name, true);
QtFontStyle::Key styleKey;
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 153451e74b..154c44ff54 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -97,6 +97,7 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const
if (fontDef.stretch != 100) {
transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
}
+ transformAdvances = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7;
QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform);
@@ -225,6 +226,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl);
CFRange stringRange = CTRunGetStringRange(run);
+ CGAffineTransform textMatrix = CTRunGetTextMatrix(run);
int prepend = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5
UniChar beginGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location);
@@ -319,9 +321,13 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
for (CFIndex i = 0; i < glyphCount - 1; ++i) {
int idx = rtlOffset + rtlSign * i;
outGlyphs[idx] = tmpGlyphs[i] | fontIndex;
- outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x);
+ CGSize advance = CGSizeMake(tmpPoints[i + 1].x - tmpPoints[i].x, tmpPoints[i].y - tmpPoints[i + 1].y);
+ if (transformAdvances)
+ advance = CGSizeApplyAffineTransform(advance, textMatrix);
+
+ outAdvances_x[idx] = QFixed::fromReal(advance.width);
// Use negative y advance for flipped coordinate system
- outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i].y - tmpPoints[i + 1].y);
+ outAdvances_y[idx] = QFixed::fromReal(advance.height);
if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
outAdvances_x[idx] = outAdvances_x[idx].round();
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h
index 4bd80beb00..495e6387fc 100644
--- a/src/gui/text/qfontengine_coretext_p.h
+++ b/src/gui/text/qfontengine_coretext_p.h
@@ -146,6 +146,7 @@ private:
mutable QCFType<CFMutableDictionaryRef> attributeDict;
CGAffineTransform transform;
friend class QFontDialogPrivate;
+ bool transformAdvances;
};
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);