Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1641)

Unified Diff: app/gfx/font_skia.cc

Issue 115586: Unified the ways Font and Canvas get the pixel size of strings, using pango (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/gfx/canvas_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/font_skia.cc
===================================================================
--- app/gfx/font_skia.cc (revision 16508)
+++ app/gfx/font_skia.cc (working copy)
@@ -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 @@
}
int Font::GetStringWidth(const std::wstring& text) const {
- const std::string utf8(base::SysWideToUTF8(text));
+ int width = 0, height = 0;
- 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;
-
- return breadth;
+ Canvas::SizeStringInt(text, *this, &width, &height, 0);
+ return width;
}
int Font::GetExpectedTextWidth(int length) const {
« no previous file with comments | « app/gfx/canvas_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698