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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_TEXT_UTILS_H_
6 #define UI_GFX_TEXT_UTILS_H_
8 #include "base/strings/string16.h"
9 #include "ui/gfx/gfx_export.h"
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
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
20 GFX_EXPORT
base::string16
RemoveAcceleratorChar(const base::string16
& s
,
21 base::char16 accelerator_char
,
22 int* accelerated_char_pos
,
23 int* accelerated_char_span
);
25 // Returns the number of horizontal pixels needed to display the specified
26 // |text| with |font_list|.
27 GFX_EXPORT
int GetStringWidth(const base::string16
& text
,
28 const FontList
& font_list
);
30 // This is same as GetStringWidth except that fractional width is returned.
31 GFX_EXPORT
float GetStringWidthF(const base::string16
& text
,
32 const FontList
& font_list
);
34 // Returns a valid cut boundary at or before |index|. The surrogate pair and
35 // combining characters should not be separated.
37 FindValidBoundaryBefore(const base::string16
& text
, size_t index
);
39 // Returns a valid cut boundary at or after |index|. The surrogate pair and
40 // combining characters should not be separated.
42 FindValidBoundaryAfter(const base::string16
& text
, size_t index
);
46 #endif // UI_GFX_TEXT_UTILS_H_