diff options
Diffstat (limited to 'ui/gfx/canvas.cc')
-rw-r--r-- | ui/gfx/canvas.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc index eb0834b..69f10cf 100644 --- a/ui/gfx/canvas.cc +++ b/ui/gfx/canvas.cc @@ -4,6 +4,7 @@ #include "ui/gfx/canvas.h" +#include <cmath> #include <limits> #include "base/i18n/rtl.h" @@ -84,6 +85,21 @@ void Canvas::RecreateBackingCanvas(const Size& size, // static void Canvas::SizeStringInt(const base::string16& text, + const FontList& font_list, + int* width, + int* height, + int line_height, + int flags) { + float fractional_width = *width; + float factional_height = *height; + SizeStringFloat(text, font_list, &fractional_width, + &factional_height, line_height, flags); + *width = std::ceil(fractional_width); + *height = std::ceil(factional_height); +} + +// static +void Canvas::SizeStringInt(const base::string16& text, const Font& font, int* width, int* height, @@ -101,6 +117,14 @@ int Canvas::GetStringWidth(const base::string16& text, } // static +float Canvas::GetStringWidthF(const base::string16& text, + const FontList& font_list) { + float width = 0, height = 0; + SizeStringFloat(text, font_list, &width, &height, 0, NO_ELLIPSIS); + return width; +} + +// static int Canvas::GetStringWidth(const base::string16& text, const Font& font) { int width = 0, height = 0; SizeStringInt(text, FontList(font), &width, &height, 0, NO_ELLIPSIS); |