OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/compiler_specific.h" |
9 #include "ui/gfx/platform_font.h" | 10 #include "ui/gfx/platform_font.h" |
10 | 11 |
11 namespace gfx { | 12 namespace gfx { |
12 | 13 |
13 class PlatformFontMac : public PlatformFont { | 14 class PlatformFontMac : public PlatformFont { |
14 public: | 15 public: |
15 PlatformFontMac(); | 16 PlatformFontMac(); |
16 explicit PlatformFontMac(const Font& other); | 17 explicit PlatformFontMac(const Font& other); |
17 explicit PlatformFontMac(NativeFont native_font); | 18 explicit PlatformFontMac(NativeFont native_font); |
18 PlatformFontMac(const std::string& font_name, | 19 PlatformFontMac(const std::string& font_name, |
19 int font_size); | 20 int font_size); |
20 | 21 |
21 // Overridden from PlatformFont: | 22 // Overridden from PlatformFont: |
22 virtual Font DeriveFont(int size_delta, int style) const; | 23 virtual Font DeriveFont(int size_delta, int style) const OVERRIDE; |
23 virtual int GetHeight() const; | 24 virtual int GetHeight() const OVERRIDE; |
24 virtual int GetBaseline() const; | 25 virtual int GetBaseline() const OVERRIDE; |
25 virtual int GetAverageCharacterWidth() const; | 26 virtual int GetAverageCharacterWidth() const OVERRIDE; |
26 virtual int GetStringWidth(const string16& text) const; | 27 virtual int GetStringWidth(const string16& text) const OVERRIDE; |
27 virtual int GetExpectedTextWidth(int length) const; | 28 virtual int GetExpectedTextWidth(int length) const OVERRIDE; |
28 virtual int GetStyle() const; | 29 virtual int GetStyle() const OVERRIDE; |
29 virtual std::string GetFontName() const; | 30 virtual std::string GetFontName() const OVERRIDE; |
30 virtual int GetFontSize() const; | 31 virtual int GetFontSize() const OVERRIDE; |
31 virtual NativeFont GetNativeFont() const; | 32 virtual NativeFont GetNativeFont() const OVERRIDE; |
32 | 33 |
33 private: | 34 private: |
34 PlatformFontMac(const std::string& font_name, int font_size, int style); | 35 PlatformFontMac(const std::string& font_name, int font_size, int style); |
35 virtual ~PlatformFontMac() {} | 36 virtual ~PlatformFontMac() {} |
36 | 37 |
37 // Initialize the object with the specified parameters. | 38 // Initialize the object with the specified parameters. |
38 void InitWithNameSizeAndStyle(const std::string& font_name, | 39 void InitWithNameSizeAndStyle(const std::string& font_name, |
39 int font_size, | 40 int font_size, |
40 int style); | 41 int style); |
41 | 42 |
42 // Calculate and cache the font metrics. | 43 // Calculate and cache the font metrics. |
43 void CalculateMetrics(); | 44 void CalculateMetrics(); |
44 | 45 |
45 std::string font_name_; | 46 std::string font_name_; |
46 int font_size_; | 47 int font_size_; |
47 int style_; | 48 int style_; |
48 | 49 |
49 // Cached metrics, generated at construction | 50 // Cached metrics, generated at construction |
50 int height_; | 51 int height_; |
51 int ascent_; | 52 int ascent_; |
52 int average_width_; | 53 int average_width_; |
53 }; | 54 }; |
54 | 55 |
55 } // namespace gfx | 56 } // namespace gfx |
56 | 57 |
57 #endif // UI_GFX_PLATFORM_FONT_MAC_H_ | 58 #endif // UI_GFX_PLATFORM_FONT_MAC_H_ |
OLD | NEW |