diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 21:05:28 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 21:05:28 +0000 |
commit | f4536d718822a03c571b2c989586d55122c8eaea (patch) | |
tree | 2f4f7d419697a3fcaa9f62f9ecbf3e599ecb1c0d /app/gfx/font_skia.cc | |
parent | 609b52dc06d5f1c6d35bf743c0281cf629022934 (diff) | |
download | chromium_src-f4536d718822a03c571b2c989586d55122c8eaea.zip chromium_src-f4536d718822a03c571b2c989586d55122c8eaea.tar.gz chromium_src-f4536d718822a03c571b2c989586d55122c8eaea.tar.bz2 |
Unified the ways Font and Canvas get the pixel size of strings, using pango
Review URL: http://codereview.chromium.org/115586
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/font_skia.cc')
-rw-r--r-- | app/gfx/font_skia.cc | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/app/gfx/font_skia.cc b/app/gfx/font_skia.cc index 0b0b979..0443ace 100644 --- a/app/gfx/font_skia.cc +++ b/app/gfx/font_skia.cc @@ -4,6 +4,8 @@ #include "app/gfx/font.h" +#include "app/gfx/canvas.h" + #include "base/logging.h" #include "base/sys_string_conversions.h" @@ -126,21 +128,10 @@ void Font::PaintSetup(SkPaint* paint) const { } int Font::GetStringWidth(const std::wstring& text) const { - const std::string utf8(base::SysWideToUTF8(text)); - - SkPaint paint; - PaintSetup(&paint); - paint.setTextEncoding(SkPaint::kUTF8_TextEncoding); - SkScalar width = paint.measureText(utf8.data(), utf8.size()); - - int breadth = static_cast<int>(ceilf(SkScalarToFloat(width))); - // Check for overflow. We should probably be returning an unsigned - // int, but in practice we'll never have a screen massive enough - // to show that much text anyway. - if (breadth < 0) - return INT_MAX; + int width = 0, height = 0; - return breadth; + Canvas::SizeStringInt(text, *this, &width, &height, 0); + return width; } int Font::GetExpectedTextWidth(int length) const { |