| OLD | NEW |
| 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_FONT_H_ | 5 #ifndef UI_GFX_FONT_H_ |
| 6 #define UI_GFX_FONT_H_ | 6 #define UI_GFX_FONT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "ui/base/ui_export.h" | 12 #include "ui/base/ui_export.h" |
| 13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 class PlatformFont; | 17 class PlatformFont; |
| 18 | 18 |
| 19 // Font provides a wrapper around an underlying font. Copy and assignment | 19 // Font provides a wrapper around an underlying font. Copy and assignment |
| 20 // operators are explicitly allowed, and cheap. | 20 // operators are explicitly allowed, and cheap. |
| 21 class UI_EXPORT Font { | 21 class UI_EXPORT Font { |
| 22 public: | 22 public: |
| 23 // The following constants indicate the font style. | 23 // The following constants indicate the font style. |
| 24 enum FontStyle { | 24 enum FontStyle { |
| 25 NORMAL = 0, | 25 NORMAL = 0, |
| 26 BOLD = 1, | 26 BOLD = 1, |
| 27 ITALIC = 2, | 27 ITALIC = 2, |
| 28 UNDERLINED = 4, | 28 UNDERLINE = 4, |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // Creates a font with the default name and style. | 31 // Creates a font with the default name and style. |
| 32 Font(); | 32 Font(); |
| 33 | 33 |
| 34 // Creates a font that is a clone of another font object. | 34 // Creates a font that is a clone of another font object. |
| 35 Font(const Font& other); | 35 Font(const Font& other); |
| 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. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 in pixels to add to the current font. For example, | 51 // |size_deta| is the size in pixels to add to the current font. For example, |
| 52 // a value of 5 results in a font 5 pixels bigger than this font. | 52 // a value of 5 results in a font 5 pixels 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 in pixels to add to the current font. See the | 56 // |size_delta| is the size in pixels to add to the current font. See the |
| 57 // single argument version of this method for an example. | 57 // single argument version of this method for an example. |
| 58 // The style parameter specifies the new style for the font, and is a | 58 // The style parameter specifies the new style for the font, and is a |
| 59 // bitmask of the values: BOLD, ITALIC and UNDERLINED. | 59 // bitmask of the values: BOLD, ITALIC and UNDERLINE. |
| 60 Font DeriveFont(int size_delta, int style) const; | 60 Font DeriveFont(int size_delta, int style) const; |
| 61 | 61 |
| 62 // Returns the number of vertical pixels needed to display characters from | 62 // Returns the number of vertical pixels needed to display characters from |
| 63 // the specified font. This may include some leading, i.e. height may be | 63 // the specified font. This may include some leading, i.e. height may be |
| 64 // greater than just ascent + descent. Specifically, the Windows and Mac | 64 // greater than just ascent + descent. Specifically, the Windows and Mac |
| 65 // implementations include leading and the Linux one does not. This may | 65 // implementations include leading and the Linux one does not. This may |
| 66 // need to be revisited in the future. | 66 // need to be revisited in the future. |
| 67 int GetHeight() const; | 67 int GetHeight() const; |
| 68 | 68 |
| 69 // Returns the baseline, or ascent, of the font. | 69 // Returns the baseline, or ascent, of the font. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 PlatformFont* platform_font() const { return platform_font_.get(); } | 105 PlatformFont* platform_font() const { return platform_font_.get(); } |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 // Wrapped platform font implementation. | 108 // Wrapped platform font implementation. |
| 109 scoped_refptr<PlatformFont> platform_font_; | 109 scoped_refptr<PlatformFont> platform_font_; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace gfx | 112 } // namespace gfx |
| 113 | 113 |
| 114 #endif // UI_GFX_FONT_H_ | 114 #endif // UI_GFX_FONT_H_ |
| OLD | NEW |