Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1735)

Unified Diff: Source/platform/fonts/mac/FontCacheMac.mm

Issue 304723002: Gate subpixel scaling by RuntimeEnabledFeatures::subpixelFontScalingEnabled() on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/fonts/mac/FontCacheMac.mm
diff --git a/Source/platform/fonts/mac/FontCacheMac.mm b/Source/platform/fonts/mac/FontCacheMac.mm
index 95d85f51db4860b494582be4d5cfca3bd160b2fb..dff0cc05c877dce6277f314196a9c70dc504cf04 100644
--- a/Source/platform/fonts/mac/FontCacheMac.mm
+++ b/Source/platform/fonts/mac/FontCacheMac.mm
@@ -31,6 +31,7 @@
#import "platform/fonts/FontCache.h"
#import <AppKit/AppKit.h>
+#import "RuntimeEnabledFeatures.h"
#import "platform/LayoutTestSupport.h"
#import "platform/fonts/FontDescription.h"
#import "platform/fonts/FontPlatformData.h"
@@ -65,6 +66,14 @@ static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCe
invalidateFontCache(0);
}
+static bool useHinting()
+{
+ // Enable hinting when subpixel font scaling is disabled or
+ // when running the set of standard non-subpixel layout tests,
+ // otherwise use subpixel glyph positioning.
+ return (isRunningLayoutTest() && !isFontAntialiasingEnabledForTest()) || !RuntimeEnabledFeatures::subpixelFontScalingEnabled();
+}
+
void FontCache::platformInit()
{
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFontsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
@@ -161,10 +170,7 @@ PassRefPtr<SimpleFontData> FontCache::platformFallbackForCharacter(const FontDes
}
}
- // Enable hinting, which is equivalent to using the screen font,
- // only when running the set of standard non-subpixel layout tests,
- // otherwise use subpixel glyph positioning.
- substituteFont = !isRunningLayoutTest() || isFontAntialiasingEnabledForTest() ? [substituteFont printerFont] : [substituteFont screenFont];
+ substituteFont = useHinting() ? [substituteFont screenFont] : [substituteFont printerFont];
substituteFontTraits = [fontManager traitsOfFont:substituteFont];
substituteFontWeight = [fontManager weightOfFont:substituteFont];
@@ -211,10 +217,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
actualTraits = [fontManager traitsOfFont:nsFont];
NSInteger actualWeight = [fontManager weightOfFont:nsFont];
- // Enable hinting, which is equivalent to using the screen font,
- // only when running the set of standard non-subpixel layout tests,
- // otherwise use subpixel glyph positioning.
- NSFont *platformFont = !isRunningLayoutTest() || isFontAntialiasingEnabledForTest() ? [nsFont printerFont] : [nsFont screenFont];
+ NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerFont];
bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight)) || fontDescription.isSyntheticBold();
bool syntheticOblique = ((traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait)) || fontDescription.isSyntheticItalic();
« no previous file with comments | « no previous file | Source/platform/fonts/mac/SimpleFontDataMac.mm » ('j') | Source/platform/fonts/mac/SimpleFontDataMac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698