Commit accf09e6 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Fix GetFontWeightFromNSFont() followup

https://crrev.com/c/2337734 was landed without the promised fixups
because of user error. These are the fixes that were promised.

Bug: 1112998
Tbr: ellyjones@chromium.org
Change-Id: I3442658b2016e0b772a2201d1ded10c7da383a39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339720Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795210}
parent f057af79
...@@ -93,7 +93,9 @@ Font::Weight GetFontWeightFromNSFont(NSFont* font) { ...@@ -93,7 +93,9 @@ Font::Weight GetFontWeightFromNSFont(NSFont* font) {
// Map CoreText weights in a manner similar to ct_weight_to_fontstyle() from // Map CoreText weights in a manner similar to ct_weight_to_fontstyle() from
// SkFontHost_mac.cpp, but adjusted for the weights actually used by the // SkFontHost_mac.cpp, but adjusted for the weights actually used by the
// system fonts. See PlatformFontMacTest.FontWeightAPIConsistency for details. // system fonts. See PlatformFontMacTest.FontWeightAPIConsistency for details.
// Use ranges for paranoia. // The Mac uses specific float values, but to avoid float comparison
// inaccuracies as well as for paranoia in case float values other than these
// appear, use ranges.
constexpr struct { constexpr struct {
// A range of CoreText weights. // A range of CoreText weights.
CGFloat weight_lower; CGFloat weight_lower;
...@@ -127,7 +129,7 @@ Font::Weight GetFontWeightFromNSFont(NSFont* font) { ...@@ -127,7 +129,7 @@ Font::Weight GetFontWeightFromNSFont(NSFont* font) {
// .AppleSystemUIFontEmphasized: 0.40 (10.12-) // .AppleSystemUIFontEmphasized: 0.40 (10.12-)
// .AppleSystemUIFontHeavy: 0.56 (10.11-) // .AppleSystemUIFontHeavy: 0.56 (10.11-)
// .AppleSystemUIFontBlack: 0.62 (10.11-) // .AppleSystemUIFontBlack: 0.62 (10.11-)
{-1000, -0.70, Font::Weight::THIN}, // NSFontWeightUltraLight {-1.0, -0.70, Font::Weight::THIN}, // NSFontWeightUltraLight
{-0.70, -0.45, Font::Weight::EXTRA_LIGHT}, // NSFontWeightThin {-0.70, -0.45, Font::Weight::EXTRA_LIGHT}, // NSFontWeightThin
{-0.45, -0.10, Font::Weight::LIGHT}, // NSFontWeightLight {-0.45, -0.10, Font::Weight::LIGHT}, // NSFontWeightLight
{-0.10, 0.10, Font::Weight::NORMAL}, // NSFontWeightRegular {-0.10, 0.10, Font::Weight::NORMAL}, // NSFontWeightRegular
...@@ -135,7 +137,7 @@ Font::Weight GetFontWeightFromNSFont(NSFont* font) { ...@@ -135,7 +137,7 @@ Font::Weight GetFontWeightFromNSFont(NSFont* font) {
{0.27, 0.35, Font::Weight::SEMIBOLD}, // NSFontWeightSemibold {0.27, 0.35, Font::Weight::SEMIBOLD}, // NSFontWeightSemibold
{0.35, 0.50, Font::Weight::BOLD}, // NSFontWeightBold {0.35, 0.50, Font::Weight::BOLD}, // NSFontWeightBold
{0.50, 0.60, Font::Weight::EXTRA_BOLD}, // NSFontWeightHeavy {0.50, 0.60, Font::Weight::EXTRA_BOLD}, // NSFontWeightHeavy
{0.60, 1000, Font::Weight::BLACK}, // NSFontWeightBlack {0.60, 1.0, Font::Weight::BLACK}, // NSFontWeightBlack
}; };
base::ScopedCFTypeRef<CFDictionaryRef> traits( base::ScopedCFTypeRef<CFDictionaryRef> traits(
......
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