OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 GFX_FONT_H_ | 5 #ifndef GFX_FONT_H_ |
6 #define GFX_FONT_H_ | 6 #define GFX_FONT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 gfx::Font& operator=(const Font& other); | 36 gfx::Font& operator=(const Font& other); |
37 | 37 |
38 // Creates a font from the specified native font. | 38 // Creates a font from the specified native font. |
39 explicit Font(NativeFont native_font); | 39 explicit Font(NativeFont native_font); |
40 | 40 |
41 // Construct a Font object with the specified PlatformFont object. The Font | 41 // Construct a Font object with the specified PlatformFont object. The Font |
42 // object takes ownership of the PlatformFont object. | 42 // object takes ownership of the PlatformFont object. |
43 explicit Font(PlatformFont* platform_font); | 43 explicit Font(PlatformFont* platform_font); |
44 | 44 |
45 // Creates a font with the specified name and size. | 45 // Creates a font with the specified name and size. |
46 Font(const std::wstring& font_name, int font_size); | 46 Font(const string16& font_name, int font_size); |
47 | 47 |
48 ~Font(); | 48 ~Font(); |
49 | 49 |
50 // Returns a new Font derived from the existing font. | 50 // Returns a new Font derived from the existing font. |
51 // size_deta is the size to add to the current font. For example, a value | 51 // size_deta is the size to add to the current font. For example, a value |
52 // of 5 results in a font 5 units bigger than this font. | 52 // of 5 results in a font 5 units bigger than this font. |
53 Font DeriveFont(int size_delta) const; | 53 Font DeriveFont(int size_delta) const; |
54 | 54 |
55 // Returns a new Font derived from the existing font. | 55 // Returns a new Font derived from the existing font. |
56 // size_delta is the size to add to the current font. See the single | 56 // size_delta is the size to add to the current font. See the single |
(...skipping 21 matching lines...) Expand all Loading... |
78 | 78 |
79 // Returns the expected number of horizontal pixels needed to display the | 79 // Returns the expected number of horizontal pixels needed to display the |
80 // specified length of characters. Call GetStringWidth() to retrieve the | 80 // specified length of characters. Call GetStringWidth() to retrieve the |
81 // actual number. | 81 // actual number. |
82 int GetExpectedTextWidth(int length) const; | 82 int GetExpectedTextWidth(int length) const; |
83 | 83 |
84 // Returns the style of the font. | 84 // Returns the style of the font. |
85 int GetStyle() const; | 85 int GetStyle() const; |
86 | 86 |
87 // Returns the font name. | 87 // Returns the font name. |
88 const std::wstring& GetFontName() const; | 88 const string16& GetFontName() const; |
89 | 89 |
90 // Returns the font size in pixels. | 90 // Returns the font size in pixels. |
91 int GetFontSize() const; | 91 int GetFontSize() const; |
92 | 92 |
93 // Returns the native font handle. | 93 // Returns the native font handle. |
94 // Lifetime lore: | 94 // Lifetime lore: |
95 // Windows: This handle is owned by the Font object, and should not be | 95 // Windows: This handle is owned by the Font object, and should not be |
96 // destroyed by the caller. | 96 // destroyed by the caller. |
97 // Mac: Caller must release this object. | 97 // Mac: Caller must release this object. |
98 // Gtk: This handle is created on demand, and must be freed by calling | 98 // Gtk: This handle is created on demand, and must be freed by calling |
99 // pango_font_description_free() when the caller is done using it. | 99 // pango_font_description_free() when the caller is done using it. |
100 NativeFont GetNativeFont() const; | 100 NativeFont GetNativeFont() const; |
101 | 101 |
102 // Raw access to the underlying platform font implementation. Can be | 102 // Raw access to the underlying platform font implementation. Can be |
103 // static_cast to a known implementation type if needed. | 103 // static_cast to a known implementation type if needed. |
104 PlatformFont* platform_font() const { return platform_font_.get(); } | 104 PlatformFont* platform_font() const { return platform_font_.get(); } |
105 | 105 |
106 private: | 106 private: |
107 // Wrapped platform font implementation. | 107 // Wrapped platform font implementation. |
108 scoped_refptr<PlatformFont> platform_font_; | 108 scoped_refptr<PlatformFont> platform_font_; |
109 }; | 109 }; |
110 | 110 |
111 } // namespace gfx | 111 } // namespace gfx |
112 | 112 |
113 #endif // GFX_FONT_H_ | 113 #endif // GFX_FONT_H_ |
114 | 114 |
OLD | NEW |