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

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

Issue 1299653004: Revert "Reland 2: mac: Use a placeholder string for the family name of the system font." (branch 248 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@2485
Patch Set: Created 5 years, 4 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
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/fonts/mac/FontFamilyMatcherMac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/mac/FontCacheMac.mm
diff --git a/Source/platform/fonts/mac/FontCacheMac.mm b/Source/platform/fonts/mac/FontCacheMac.mm
index fae31d6e713ec2db93e883c8ecf0eacded0ef18d..14ac4e6ab7dea82b34f99dc4c7e997bc99e0faf2 100644
--- a/Source/platform/fonts/mac/FontCacheMac.mm
+++ b/Source/platform/fonts/mac/FontCacheMac.mm
@@ -82,6 +82,22 @@ void FontCache::platformInit()
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFontsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
}
+static int toAppKitFontWeight(FontWeight fontWeight)
+{
+ static int appKitFontWeights[] = {
+ 2, // FontWeight100
+ 3, // FontWeight200
+ 4, // FontWeight300
+ 5, // FontWeight400
+ 6, // FontWeight500
+ 8, // FontWeight600
+ 9, // FontWeight700
+ 10, // FontWeight800
+ 12, // FontWeight900
+ };
+ return appKitFontWeights[fontWeight];
+}
+
static inline bool isAppKitFontWeightBold(NSInteger appKitFontWeight)
{
return appKitFontWeight >= 7;
@@ -187,9 +203,10 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, float fontSize)
{
NSFontTraitMask traits = fontDescription.style() ? NSFontItalicTrait : 0;
+ NSInteger weight = toAppKitFontWeight(fontDescription.weight());
float size = fontSize;
- NSFont* nsFont = MatchNSFontFamily(creationParams.family(), traits, fontDescription.weight(), size);
+ NSFont *nsFont = MatchNSFontFamily(creationParams.family(),traits, weight, size);
if (!nsFont)
return 0;
@@ -200,8 +217,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
NSInteger actualWeight = [fontManager weightOfFont:nsFont];
NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerFont];
- NSInteger appKitWeight = toAppKitFontWeight(fontDescription.weight());
- bool syntheticBold = (isAppKitFontWeightBold(appKitWeight) && !isAppKitFontWeightBold(actualWeight)) || fontDescription.isSyntheticBold();
+ bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight)) || fontDescription.isSyntheticBold();
bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait)) || fontDescription.isSyntheticItalic();
// FontPlatformData::typeface() is null in the case of Chromium out-of-process font loading failing.
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/fonts/mac/FontFamilyMatcherMac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698