OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_TEXT_UTILS_H_ | 5 #ifndef UI_GFX_TEXT_UTILS_H_ |
6 #define UI_GFX_TEXT_UTILS_H_ | 6 #define UI_GFX_TEXT_UTILS_H_ |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "ui/gfx/gfx_export.h" | 9 #include "ui/gfx/gfx_export.h" |
10 | 10 |
11 namespace gfx { | 11 namespace gfx { |
12 | 12 |
13 class FontList; | 13 class FontList; |
14 | 14 |
15 // Strip the accelerator char (typically '&') from a menu string. A double | 15 // Strip the accelerator char (typically '&') from a menu string. A double |
16 // accelerator char ('&&') will be converted to a single char. The out params | 16 // accelerator char ('&&') will be converted to a single char. The out params |
17 // |accelerated_char_pos| and |accelerated_char_span| will be set to the index | 17 // |accelerated_char_pos| and |accelerated_char_span| will be set to the index |
18 // and span of the last accelerated character, respectively, or -1 and 0 if | 18 // and span of the last accelerated character, respectively, or -1 and 0 if |
19 // there was none. | 19 // there was none. |
20 GFX_EXPORT base::string16 RemoveAcceleratorChar(const base::string16& s, | 20 GFX_EXPORT base::string16 RemoveAcceleratorChar(const base::string16& s, |
21 base::char16 accelerator_char, | 21 base::char16 accelerator_char, |
22 int* accelerated_char_pos, | 22 int* accelerated_char_pos, |
23 int* accelerated_char_span); | 23 int* accelerated_char_span); |
24 | 24 |
25 // Returns the number of horizontal pixels needed to display the specified | 25 // Returns the number of horizontal pixels needed to display the specified |
26 // |text| with |font_list|. | 26 // |text| with |font_list|. |
27 GFX_EXPORT int GetStringWidth(const base::string16& text, | 27 GFX_EXPORT int GetStringWidth(const base::string16& text, |
28 const FontList& font_list); | 28 const FontList& font_list); |
29 | 29 |
30 // Returns the pixel width needed to display the specified |text| with | |
31 //|font_list|. Note that the fractional width might be returned in some | |
Alexei Svitkine (slow)
2013/10/07 21:43:39
Nit: |in| -> |on|
jianli
2013/10/07 23:18:45
Done.
| |
32 // platforms. | |
33 GFX_EXPORT float GetStringWidthF(const base::string16& text, | |
34 const FontList& font_list); | |
35 | |
30 } // namespace gfx | 36 } // namespace gfx |
31 | 37 |
32 #endif // UI_GFX_TEXT_UTILS_H_ | 38 #endif // UI_GFX_TEXT_UTILS_H_ |
OLD | NEW |