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

Side by Side Diff: ui/gfx/platform_font_mac.h

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use the std::tie in resource_bundle Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_PLATFORM_FONT_MAC_H_ 5 #ifndef UI_GFX_PLATFORM_FONT_MAC_H_
6 #define UI_GFX_PLATFORM_FONT_MAC_H_ 6 #define UI_GFX_PLATFORM_FONT_MAC_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "ui/gfx/font_render_params.h" 11 #include "ui/gfx/font_render_params.h"
12 #include "ui/gfx/platform_font.h" 12 #include "ui/gfx/platform_font.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 class PlatformFontMac : public PlatformFont { 16 class PlatformFontMac : public PlatformFont {
17 public: 17 public:
18 PlatformFontMac(); 18 PlatformFontMac();
19 explicit PlatformFontMac(NativeFont native_font); 19 explicit PlatformFontMac(NativeFont native_font);
20 PlatformFontMac(const std::string& font_name, 20 PlatformFontMac(const std::string& font_name,
21 int font_size); 21 int font_size);
22 22
23 // Overridden from PlatformFont: 23 // Overridden from PlatformFont:
24 Font DeriveFont(int size_delta, int style) const override; 24 Font DeriveFont(int size_delta,
25 int style,
26 Font::Weight weight) const override;
25 int GetHeight() override; 27 int GetHeight() override;
28 gfx::Font::Weight GetWeight() const override;
Alexei Svitkine (slow) 2016/04/04 16:34:51 No need for gfx:: prefix since this is in gfx:: na
Mikus 2016/04/05 16:18:34 Done.
26 int GetBaseline() override; 29 int GetBaseline() override;
27 int GetCapHeight() override; 30 int GetCapHeight() override;
28 int GetExpectedTextWidth(int length) override; 31 int GetExpectedTextWidth(int length) override;
29 int GetStyle() const override; 32 int GetStyle() const override;
30 const std::string& GetFontName() const override; 33 const std::string& GetFontName() const override;
31 std::string GetActualFontNameForTesting() const override; 34 std::string GetActualFontNameForTesting() const override;
32 int GetFontSize() const override; 35 int GetFontSize() const override;
33 const FontRenderParams& GetFontRenderParams() override; 36 const FontRenderParams& GetFontRenderParams() override;
34 NativeFont GetNativeFont() const override; 37 NativeFont GetNativeFont() const override;
35 38
36 private: 39 private:
37 PlatformFontMac(const std::string& font_name, int font_size, int font_style); 40 PlatformFontMac(const std::string& font_name,
41 int font_size,
42 int font_style,
43 Font::Weight font_weight);
38 ~PlatformFontMac() override; 44 ~PlatformFontMac() override;
39 45
40 // Calculates and caches the font metrics and inits |render_params_|. 46 // Calculates and caches the font metrics and inits |render_params_|.
41 void CalculateMetricsAndInitRenderParams(); 47 void CalculateMetricsAndInitRenderParams();
42 48
43 // The NSFont instance for this object. If this object was constructed from an 49 // The NSFont instance for this object. If this object was constructed from an
44 // NSFont instance, this holds that NSFont instance. Otherwise this NSFont 50 // NSFont instance, this holds that NSFont instance. Otherwise this NSFont
45 // instance is constructed from the name, size, and style, and if there is no 51 // instance is constructed from the name, size, and style, and if there is no
46 // active font that matched those criteria, this object may be nil. 52 // active font that matched those criteria, this object may be nil.
47 base::scoped_nsobject<NSFont> native_font_; 53 base::scoped_nsobject<NSFont> native_font_;
48 54
49 // The name/size/style trio that specify the font. Initialized in the 55 // The name/size/style trio that specify the font. Initialized in the
50 // constructors. 56 // constructors.
51 std::string font_name_; // Corresponds to -[NSFont fontFamily]. 57 std::string font_name_; // Corresponds to -[NSFont fontFamily].
52 int font_size_; 58 int font_size_;
53 int font_style_; 59 int font_style_;
60 Font::Weight font_weight_;
54 61
55 // Cached metrics, generated in CalculateMetrics(). 62 // Cached metrics, generated in CalculateMetrics().
56 int height_; 63 int height_;
57 int ascent_; 64 int ascent_;
58 int cap_height_; 65 int cap_height_;
59 int average_width_; 66 int average_width_;
60 67
61 // Details about how the font should be rendered. 68 // Details about how the font should be rendered.
62 FontRenderParams render_params_; 69 FontRenderParams render_params_;
63 70
64 DISALLOW_COPY_AND_ASSIGN(PlatformFontMac); 71 DISALLOW_COPY_AND_ASSIGN(PlatformFontMac);
65 }; 72 };
66 73
67 } // namespace gfx 74 } // namespace gfx
68 75
69 #endif // UI_GFX_PLATFORM_FONT_MAC_H_ 76 #endif // UI_GFX_PLATFORM_FONT_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698