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_H_ | 5 #ifndef UI_GFX_PLATFORM_FONT_H_ |
6 #define UI_GFX_PLATFORM_FONT_H_ | 6 #define UI_GFX_PLATFORM_FONT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "ui/base/ui_export.h" | 13 #include "ui/base/ui_export.h" |
14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 class Font; | 18 class Font; |
19 | 19 |
20 class UI_EXPORT PlatformFont : public base::RefCounted<PlatformFont> { | 20 class UI_EXPORT PlatformFont : public base::RefCounted<PlatformFont> { |
21 public: | 21 public: |
22 // Creates an appropriate PlatformFont implementation. | 22 // Creates an appropriate PlatformFont implementation. |
23 static PlatformFont* CreateDefault(); | 23 static PlatformFont* CreateDefault(); |
24 static PlatformFont* CreateFromFont(const Font& other); | 24 static PlatformFont* CreateFromFont(const Font& other); |
25 static PlatformFont* CreateFromNativeFont(NativeFont native_font); | 25 static PlatformFont* CreateFromNativeFont(NativeFont native_font); |
26 // Creates a PlatformFont implementation with the specified |font_name| and | 26 // Creates a PlatformFont implementation with the specified |font_name| |
27 // |font_size| in pixels. | 27 // (encoded in UTF-8) and |font_size| in pixels. |
28 static PlatformFont* CreateFromNameAndSize(const string16& font_name, | 28 static PlatformFont* CreateFromNameAndSize(const std::string& font_name, |
29 int font_size); | 29 int font_size); |
30 | 30 |
31 // Returns a new Font derived from the existing font. | 31 // Returns a new Font derived from the existing font. |
32 // |size_delta| is the size in pixels to add to the current font. | 32 // |size_delta| is the size in pixels to add to the current font. |
33 // The style parameter specifies the new style for the font, and is a | 33 // The style parameter specifies the new style for the font, and is a |
34 // bitmask of the values: BOLD, ITALIC and UNDERLINED. | 34 // bitmask of the values: BOLD, ITALIC and UNDERLINED. |
35 virtual Font DeriveFont(int size_delta, int style) const = 0; | 35 virtual Font DeriveFont(int size_delta, int style) const = 0; |
36 | 36 |
37 // Returns the number of vertical pixels needed to display characters from | 37 // Returns the number of vertical pixels needed to display characters from |
38 // the specified font. This may include some leading, i.e. height may be | 38 // the specified font. This may include some leading, i.e. height may be |
(...skipping 13 matching lines...) Expand all Loading... |
52 virtual int GetStringWidth(const string16& text) const = 0; | 52 virtual int GetStringWidth(const string16& text) const = 0; |
53 | 53 |
54 // Returns the expected number of horizontal pixels needed to display the | 54 // Returns the expected number of horizontal pixels needed to display the |
55 // specified length of characters. Call GetStringWidth() to retrieve the | 55 // specified length of characters. Call GetStringWidth() to retrieve the |
56 // actual number. | 56 // actual number. |
57 virtual int GetExpectedTextWidth(int length) const = 0; | 57 virtual int GetExpectedTextWidth(int length) const = 0; |
58 | 58 |
59 // Returns the style of the font. | 59 // Returns the style of the font. |
60 virtual int GetStyle() const = 0; | 60 virtual int GetStyle() const = 0; |
61 | 61 |
62 // Returns the font name. | 62 // Returns the font name in UTF-8. |
63 virtual string16 GetFontName() const = 0; | 63 virtual std::string GetFontName() const = 0; |
64 | 64 |
65 // Returns the font size in pixels. | 65 // Returns the font size in pixels. |
66 virtual int GetFontSize() const = 0; | 66 virtual int GetFontSize() const = 0; |
67 | 67 |
68 // Returns the native font handle. | 68 // Returns the native font handle. |
69 virtual NativeFont GetNativeFont() const = 0; | 69 virtual NativeFont GetNativeFont() const = 0; |
70 | 70 |
71 protected: | 71 protected: |
72 virtual ~PlatformFont() {} | 72 virtual ~PlatformFont() {} |
73 | 73 |
74 private: | 74 private: |
75 friend class base::RefCounted<PlatformFont>; | 75 friend class base::RefCounted<PlatformFont>; |
76 }; | 76 }; |
77 | 77 |
78 } // namespace gfx | 78 } // namespace gfx |
79 | 79 |
80 #endif // UI_GFX_PLATFORM_FONT_H_ | 80 #endif // UI_GFX_PLATFORM_FONT_H_ |
81 | 81 |
OLD | NEW |