Gate subpixel scaling by RuntimeEnabledFeatures::subpixelFontScalingEnabled() on Mac

Synchronise releasing / default activating this feature with the other platforms.

BUG=378195
R=eae,dglazkov,eseidel

Review URL: https://codereview.chromium.org/304723002

git-svn-id: svn://svn.chromium.org/blink/trunk@175203 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 89693ac1
......@@ -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();
......
......@@ -31,6 +31,8 @@
#import <ApplicationServices/ApplicationServices.h>
#import <float.h>
#import <unicode/uchar.h>
#import "RuntimeEnabledFeatures.h"
#import "platform/LayoutTestSupport.h"
#import "platform/SharedBuffer.h"
#import "platform/fonts/Font.h"
#import "platform/fonts/FontCache.h"
......@@ -106,6 +108,14 @@ static NSString *webFallbackFontFamily(void)
return webFallbackFontFamily.get();
}
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();
}
const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const
{
if (key && !CFEqual(RetainPtr<CFStringRef>(AdoptCF, CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) {
......@@ -315,9 +325,8 @@ PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const Fo
float size = m_platformData.size() * scaleFactor;
FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toSize:size], size, false, false, m_platformData.orientation());
// Until we replace AppKit API (NSFontManager etc.), we always want to disable hinting,
// so we use the printerFont here.
scaledFontData.setFont([scaledFontData.font() printerFont]);
// AppKit forgets about hinting property when scaling, so we have to remind it.
scaledFontData.setFont(useHinting() ? [scaledFontData.font() screenFont] : [scaledFontData.font() printerFont]);
if (scaledFontData.font()) {
NSFontManager *fontManager = [NSFontManager sharedFontManager];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment