Enable subpixel rendering for raster on Mac
authorJiang Jiang <jiang.jiang@nokia.com>
Thu, 1 Dec 2011 10:21:28 +0000 (11:21 +0100)
committerQt by Nokia <qt-info@nokia.com>
Sun, 4 Dec 2011 22:39:34 +0000 (23:39 +0100)
Change-Id: I06e6465e03c17776974d361254abf5b750736080
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm

index 45656a2..6c3e403 100644 (file)
@@ -88,6 +88,7 @@ inline QString qt_mac_NSStringToQString(const NSString *nsstr)
 { return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
 
 int qt_antialiasing_threshold = 0;
+bool qt_enable_font_smoothing = true;
 
 QFont::StyleHint styleHintFromNSString(NSString *style)
 {
@@ -123,6 +124,12 @@ QCoreTextFontDatabase::QCoreTextFontDatabase()
     QVariant appleValue = appleSettings.value(QLatin1String("AppleAntiAliasingThreshold"));
     if (appleValue.isValid())
         qt_antialiasing_threshold = appleValue.toInt();
+
+    appleValue = appleSettings.value(QLatin1String("AppleFontSmoothing"));
+    // Only disable font smoothing when AppleFontSmoothing is set to 0,
+    // empty or non-zero means enabled
+    if (appleValue.isValid() && appleValue.toInt() == 0)
+        qt_enable_font_smoothing = false;
 }
 
 QCoreTextFontDatabase::~QCoreTextFontDatabase()
index 9a84dfc..f71dcc2 100644 (file)
@@ -400,7 +400,7 @@ void QCoreTextFontEngineMulti::loadEngine(int)
     Q_ASSERT(false);
 }
 
-extern int qt_antialiasing_threshold; // from qapplication.cpp
+extern int qt_antialiasing_threshold, qt_enable_font_smoothing;
 
 CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
 {
@@ -470,6 +470,9 @@ void QCoreTextFontEngine::init()
     Q_ASSERT(ctfont != NULL);
     Q_ASSERT(cgFont != NULL);
 
+    glyphFormat = qt_enable_font_smoothing ? QFontEngineGlyphCache::Raster_RGBMask
+                                           : QFontEngineGlyphCache::Raster_A8;
+
     QCFString family = CTFontCopyFamilyName(ctfont);
     fontDef.family = family;