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

Unified Diff: ui/gfx/platform_font_mac.mm

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for platforms other than win and targets other than chrome Created 4 years, 9 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 | « ui/gfx/platform_font_mac.h ('k') | ui/gfx/platform_font_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/platform_font_mac.mm
diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
index 3129489e5005deb08c4352be1f0eb34c7a5ebac1..2003f169ef2160bac97769b3f68a5e5ed404a783 100644
--- a/ui/gfx/platform_font_mac.mm
+++ b/ui/gfx/platform_font_mac.mm
@@ -65,38 +65,44 @@ PlatformFontMac::PlatformFontMac(NativeFont native_font)
: native_font_([native_font retain]),
font_name_(base::SysNSStringToUTF8([native_font_ familyName])),
font_size_([native_font_ pointSize]),
- font_style_(Font::NORMAL) {
+ font_style_(Font::NORMAL),
+ font_weight_(Font::Weight::NORMAL) {
NSFontSymbolicTraits traits = [[native_font fontDescriptor] symbolicTraits];
tapted 2016/03/23 23:00:06 Without a BUG= I can't grok the wider plan for thi
Mikus 2016/03/24 07:31:25 Done.
msw 2016/03/25 01:41:31 Please cite the bug you filed in the BUG= line of
tapted 2016/03/27 23:10:01 The bug still doesn't describe the _need_ for the
if (traits & NSFontItalicTrait)
font_style_ |= Font::ITALIC;
if (traits & NSFontBoldTrait)
- font_style_ |= Font::BOLD;
+ font_weight_ = Font::BOLD;
tapted 2016/03/23 23:00:06 Font::Weight::BOLD? - what you have shouldn't comp
Mikus 2016/03/24 07:31:25 Done.
+ else
+ font_weight_ = Font::NORMAL;
CalculateMetricsAndInitRenderParams();
}
-PlatformFontMac::PlatformFontMac(const std::string& font_name,
- int font_size)
+PlatformFontMac::PlatformFontMac(const std::string& font_name, int font_size)
: native_font_([NSFontWithSpec(font_name, font_size, Font::NORMAL) retain]),
font_name_(font_name),
font_size_(font_size),
- font_style_(Font::NORMAL) {
+ font_style_(Font::NORMAL),
+ font_weight_(Font::Weight::NORMAL) {
CalculateMetricsAndInitRenderParams();
}
////////////////////////////////////////////////////////////////////////////////
// PlatformFontMac, PlatformFont implementation:
-Font PlatformFontMac::DeriveFont(int size_delta, int style) const {
- if (native_font_ && style == font_style_) {
+Font PlatformFontMac::DeriveFont(int size_delta,
+ int style,
+ Font::Weight weight) const {
+ if (native_font_ && style == font_style_ && weight == font_weight_) {
// System fonts have special attributes starting with 10.11. They should be
// requested using the same descriptor to preserve these attributes.
- return Font(new PlatformFontMac(
- [NSFont fontWithDescriptor:[native_font_ fontDescriptor]
- size:font_size_ + size_delta]));
+ return Font(new PlatformFontMac([NSFont
+ fontWithDescriptor:[native_font_ fontDescriptor]
+ size:font_size_ + size_delta]));
}
- return Font(new PlatformFontMac(font_name_, font_size_ + size_delta, style));
+ return Font(
+ new PlatformFontMac(font_name_, font_size_ + size_delta, style, weight));
}
int PlatformFontMac::GetHeight() {
@@ -119,6 +125,10 @@ int PlatformFontMac::GetStyle() const {
return font_style_;
}
+Font::Weight PlatformFontMac::GetWeight() const {
+ return font_weight_;
+}
+
const std::string& PlatformFontMac::GetFontName() const {
return font_name_;
}
@@ -144,11 +154,13 @@ NativeFont PlatformFontMac::GetNativeFont() const {
PlatformFontMac::PlatformFontMac(const std::string& font_name,
int font_size,
- int font_style)
+ int font_style,
+ Font::Weight font_weight)
: native_font_([NSFontWithSpec(font_name, font_size, font_style) retain]),
font_name_(font_name),
font_size_(font_size),
- font_style_(font_style) {
+ font_style_(font_style),
+ font_weight_(font_weight) {
CalculateMetricsAndInitRenderParams();
}
@@ -186,6 +198,7 @@ void PlatformFontMac::CalculateMetricsAndInitRenderParams() {
query.families.push_back(font_name_);
query.pixel_size = font_size_;
query.style = font_style_;
+ query.weight = font_weight_;
render_params_ = gfx::GetFontRenderParams(query, NULL);
}
« no previous file with comments | « ui/gfx/platform_font_mac.h ('k') | ui/gfx/platform_font_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698