| 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_LIST_H_ | 5 #ifndef UI_GFX_FONT_LIST_H_ |
| 6 #define UI_GFX_FONT_LIST_H_ | 6 #define UI_GFX_FONT_LIST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Sets the description string for default FontList construction. If it's | 59 // Sets the description string for default FontList construction. If it's |
| 60 // empty, FontList will initialize using the default Font constructor. | 60 // empty, FontList will initialize using the default Font constructor. |
| 61 // | 61 // |
| 62 // The client code must call this function before any call of the default | 62 // The client code must call this function before any call of the default |
| 63 // constructor. This should be done on the UI thread. | 63 // constructor. This should be done on the UI thread. |
| 64 // | 64 // |
| 65 // ui::ResourceBundle may call this function more than once when UI language | 65 // ui::ResourceBundle may call this function more than once when UI language |
| 66 // is changed. | 66 // is changed. |
| 67 static void SetDefaultFontDescription(const std::string& font_description); | 67 static void SetDefaultFontDescription(const std::string& font_description); |
| 68 | 68 |
| 69 // Returns a new FontList with the given |font_style| flags. | |
| 70 FontList DeriveFontList(int font_style) const; | |
| 71 | |
| 72 // Returns a new FontList with the same font names and style but with the | |
| 73 // given font |size| in pixels. | |
| 74 FontList DeriveFontListWithSize(int size) const; | |
| 75 | |
| 76 // Returns a new FontList with the same font names and style but resized. | |
| 77 // |size_delta| is the size in pixels to add to the current font size. | |
| 78 FontList DeriveFontListWithSizeDelta(int size_delta) const; | |
| 79 | |
| 80 // Returns a new FontList with the same font names but resized and the given | 69 // Returns a new FontList with the same font names but resized and the given |
| 81 // style. |size_delta| is the size in pixels to add to the current font size. | 70 // style. |size_delta| is the size in pixels to add to the current font size. |
| 82 // |font_style| specifies the new style, which is a bitmask of the values: | 71 // |font_style| specifies the new style, which is a bitmask of the values: |
| 83 // Font::BOLD, Font::ITALIC and Font::UNDERLINE. | 72 // Font::BOLD, Font::ITALIC and Font::UNDERLINE. |
| 73 FontList Derive(int size_delta, int font_style) const; |
| 74 |
| 75 // Returns a new FontList with the same font names and style but resized. |
| 76 // |size_delta| is the size in pixels to add to the current font size. |
| 77 FontList DeriveWithSizeDelta(int size_delta) const; |
| 78 |
| 79 // Obsolete versions. Use the abolve methods instead. |
| 80 FontList DeriveFontListWithSizeDelta(int size_delta) const; |
| 84 FontList DeriveFontListWithSizeDeltaAndStyle(int size_delta, | 81 FontList DeriveFontListWithSizeDeltaAndStyle(int size_delta, |
| 85 int font_style) const; | 82 int font_style) const; |
| 86 | 83 |
| 87 // Returns the height of this font list, which is max(ascent) + max(descent) | 84 // Returns the height of this font list, which is max(ascent) + max(descent) |
| 88 // for all the fonts in the font list. | 85 // for all the fonts in the font list. |
| 89 int GetHeight() const; | 86 int GetHeight() const; |
| 90 | 87 |
| 91 // Returns the baseline of this font list, which is max(baseline) for all the | 88 // Returns the baseline of this font list, which is max(baseline) for all the |
| 92 // fonts in the font list. | 89 // fonts in the font list. |
| 93 int GetBaseline() const; | 90 int GetBaseline() const; |
| 94 | 91 |
| 95 // Returns the cap height of this font list. | 92 // Returns the cap height of this font list. |
| 96 // Currently returns the cap height of the primary font. | 93 // Currently returns the cap height of the primary font. |
| 97 int GetCapHeight() const; | 94 int GetCapHeight() const; |
| 98 | 95 |
| 99 // Returns the number of horizontal pixels needed to display |text|. | |
| 100 int GetStringWidth(const base::string16& text) const; | |
| 101 | |
| 102 // Returns the expected number of horizontal pixels needed to display the | 96 // Returns the expected number of horizontal pixels needed to display the |
| 103 // specified length of characters. Call GetStringWidth() to retrieve the | 97 // specified length of characters. Call GetStringWidth() to retrieve the |
| 104 // actual number. | 98 // actual number. |
| 105 int GetExpectedTextWidth(int length) const; | 99 int GetExpectedTextWidth(int length) const; |
| 106 | 100 |
| 107 // Returns the |gfx::Font::FontStyle| style flags for this font list. | 101 // Returns the |gfx::Font::FontStyle| style flags for this font list. |
| 108 int GetFontStyle() const; | 102 int GetFontStyle() const; |
| 109 | 103 |
| 110 // Returns a string representing font names, styles, and size. If the FontList | 104 // Returns a string representing font names, styles, and size. If the FontList |
| 111 // is initialized by a vector of Font, use the first font's style and size | 105 // is initialized by a vector of Font, use the first font's style and size |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 mutable int common_baseline_; | 141 mutable int common_baseline_; |
| 148 | 142 |
| 149 // Cached font style and size. | 143 // Cached font style and size. |
| 150 mutable int font_style_; | 144 mutable int font_style_; |
| 151 mutable int font_size_; | 145 mutable int font_size_; |
| 152 }; | 146 }; |
| 153 | 147 |
| 154 } // namespace gfx | 148 } // namespace gfx |
| 155 | 149 |
| 156 #endif // UI_GFX_FONT_LIST_H_ | 150 #endif // UI_GFX_FONT_LIST_H_ |
| OLD | NEW |