diff options
author | derat <derat@chromium.org> | 2014-10-27 12:33:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-27 19:34:31 +0000 |
commit | 07813d33da008b90a2046bcc3ae6c6c4d06effb0 (patch) | |
tree | 025a8ddcfeccc9701f41bf68c963c74df06329dd | |
parent | 84d0c31b212e09618cfc202a00d58857dfa80d5f (diff) | |
download | chromium_src-07813d33da008b90a2046bcc3ae6c6c4d06effb0.zip chromium_src-07813d33da008b90a2046bcc3ae6c6c4d06effb0.tar.gz chromium_src-07813d33da008b90a2046bcc3ae6c6c4d06effb0.tar.bz2 |
mac: Avoid PlatformFontMac log spam.
Update PlatformFontMac to call the mac implementation of
FontRenderParams.
BUG=427319
Review URL: https://codereview.chromium.org/681773002
Cr-Commit-Position: refs/heads/master@{#301412}
-rw-r--r-- | ui/gfx/platform_font_mac.h | 8 | ||||
-rw-r--r-- | ui/gfx/platform_font_mac.mm | 20 |
2 files changed, 18 insertions, 10 deletions
diff --git a/ui/gfx/platform_font_mac.h b/ui/gfx/platform_font_mac.h index aa85f82..d8f8e85 100644 --- a/ui/gfx/platform_font_mac.h +++ b/ui/gfx/platform_font_mac.h @@ -7,6 +7,7 @@ #include "base/compiler_specific.h" #include "base/mac/scoped_nsobject.h" +#include "ui/gfx/font_render_params.h" #include "ui/gfx/platform_font.h" namespace gfx { @@ -35,8 +36,8 @@ class PlatformFontMac : public PlatformFont { PlatformFontMac(const std::string& font_name, int font_size, int font_style); ~PlatformFontMac() override; - // Calculates and caches the font metrics. - void CalculateMetrics(); + // Calculates and caches the font metrics and inits |render_params_|. + void CalculateMetricsAndInitRenderParams(); // The NSFont instance for this object. If this object was constructed from an // NSFont instance, this holds that NSFont instance. Otherwise this NSFont @@ -56,6 +57,9 @@ class PlatformFontMac : public PlatformFont { int cap_height_; int average_width_; + // Details about how the font should be rendered. + FontRenderParams render_params_; + DISALLOW_COPY_AND_ASSIGN(PlatformFontMac); }; diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm index bec41f7..3721f06 100644 --- a/ui/gfx/platform_font_mac.mm +++ b/ui/gfx/platform_font_mac.mm @@ -61,7 +61,7 @@ PlatformFontMac::PlatformFontMac() font_name_(base::SysNSStringToUTF8([native_font_ familyName])), font_size_([NSFont systemFontSize]), font_style_(Font::NORMAL) { - CalculateMetrics(); + CalculateMetricsAndInitRenderParams(); } PlatformFontMac::PlatformFontMac(NativeFont native_font) @@ -75,7 +75,7 @@ PlatformFontMac::PlatformFontMac(NativeFont native_font) if (traits & NSFontBoldTrait) font_style_ |= Font::BOLD; - CalculateMetrics(); + CalculateMetricsAndInitRenderParams(); } PlatformFontMac::PlatformFontMac(const std::string& font_name, @@ -84,7 +84,7 @@ PlatformFontMac::PlatformFontMac(const std::string& font_name, font_name_(font_name), font_size_(font_size), font_style_(Font::NORMAL) { - CalculateMetrics(); + CalculateMetricsAndInitRenderParams(); } //////////////////////////////////////////////////////////////////////////////// @@ -127,9 +127,7 @@ int PlatformFontMac::GetFontSize() const { } const FontRenderParams& PlatformFontMac::GetFontRenderParams() const { - NOTIMPLEMENTED(); - static FontRenderParams params; - return params; + return render_params_; } NativeFont PlatformFontMac::GetNativeFont() const { @@ -146,13 +144,13 @@ PlatformFontMac::PlatformFontMac(const std::string& font_name, font_name_(font_name), font_size_(font_size), font_style_(font_style) { - CalculateMetrics(); + CalculateMetricsAndInitRenderParams(); } PlatformFontMac::~PlatformFontMac() { } -void PlatformFontMac::CalculateMetrics() { +void PlatformFontMac::CalculateMetricsAndInitRenderParams() { NSFont* font = native_font_.get(); if (!font) { // This object was constructed from a font name that doesn't correspond to @@ -171,6 +169,12 @@ void PlatformFontMac::CalculateMetrics() { cap_height_ = SkScalarCeilToInt([font capHeight]); average_width_ = NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]); + + FontRenderParamsQuery query(false); + query.families.push_back(font_name_); + query.pixel_size = font_size_; + query.style = font_style_; + render_params_ = gfx::GetFontRenderParams(query, NULL); } //////////////////////////////////////////////////////////////////////////////// |