summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/platform_font_mac.h8
-rw-r--r--ui/gfx/platform_font_mac.mm20
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);
}
////////////////////////////////////////////////////////////////////////////////