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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // Returns a new FontList with the same font names and style but resized. | 77 // Returns a new FontList with the same font names and style but resized. |
78 // |size_delta| is the size in pixels to add to the current font size. | 78 // |size_delta| is the size in pixels to add to the current font size. |
79 FontList DeriveWithSizeDelta(int size_delta) const; | 79 FontList DeriveWithSizeDelta(int size_delta) const; |
80 | 80 |
81 // Returns a new FontList with the same font names and size but the given | 81 // Returns a new FontList with the same font names and size but the given |
82 // style. |font_style| specifies the new style, which is a bitmask of the | 82 // style. |font_style| specifies the new style, which is a bitmask of the |
83 // values: Font::BOLD, Font::ITALIC and Font::UNDERLINE. | 83 // values: Font::BOLD, Font::ITALIC and Font::UNDERLINE. |
84 FontList DeriveWithStyle(int font_style) const; | 84 FontList DeriveWithStyle(int font_style) const; |
85 | 85 |
| 86 // Shrinks the font size until the font list fits within |height| while |
| 87 // having its cap height vertically centered. Returns a new FontList with |
| 88 // the correct height. |
| 89 // |
| 90 // The expected layout: |
| 91 // +--------+-----------------------------------------------+------------+ |
| 92 // | | y offset | space | |
| 93 // | +--------+-------------------+------------------+ above | |
| 94 // | | | | internal leading | cap height | |
| 95 // | box | font | ascent (baseline) +------------------+------------+ |
| 96 // | height | height | | cap height | |
| 97 // | | |-------------------+------------------+------------+ |
| 98 // | | | descent (height - baseline) | space | |
| 99 // | +--------+--------------------------------------+ below | |
| 100 // | | space at bottom | cap height | |
| 101 // +--------+-----------------------------------------------+------------+ |
| 102 // Goal: |
| 103 // center of box height == center of cap height |
| 104 // (i.e. space above cap height == space below cap height) |
| 105 // Restrictions: |
| 106 // y offset >= 0 |
| 107 // space at bottom >= 0 |
| 108 // (i.e. Entire font must be visible inside the box.) |
| 109 gfx::FontList DeriveWithHeightUpperBound(int height) const; |
| 110 |
86 // Returns the height of this font list, which is max(ascent) + max(descent) | 111 // Returns the height of this font list, which is max(ascent) + max(descent) |
87 // for all the fonts in the font list. | 112 // for all the fonts in the font list. |
88 int GetHeight() const; | 113 int GetHeight() const; |
89 | 114 |
90 // Returns the baseline of this font list, which is max(baseline) for all the | 115 // Returns the baseline of this font list, which is max(baseline) for all the |
91 // fonts in the font list. | 116 // fonts in the font list. |
92 int GetBaseline() const; | 117 int GetBaseline() const; |
93 | 118 |
94 // Returns the cap height of this font list. | 119 // Returns the cap height of this font list. |
95 // Currently returns the cap height of the primary font. | 120 // Currently returns the cap height of the primary font. |
(...skipping 25 matching lines...) Expand all Loading... |
121 explicit FontList(FontListImpl* impl); | 146 explicit FontList(FontListImpl* impl); |
122 | 147 |
123 static const scoped_refptr<FontListImpl>& GetDefaultImpl(); | 148 static const scoped_refptr<FontListImpl>& GetDefaultImpl(); |
124 | 149 |
125 scoped_refptr<FontListImpl> impl_; | 150 scoped_refptr<FontListImpl> impl_; |
126 }; | 151 }; |
127 | 152 |
128 } // namespace gfx | 153 } // namespace gfx |
129 | 154 |
130 #endif // UI_GFX_FONT_LIST_H_ | 155 #endif // UI_GFX_FONT_LIST_H_ |
OLD | NEW |