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

Unified Diff: ui/gfx/platform_font_pango.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix trybots Created 7 years, 2 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
Index: ui/gfx/platform_font_pango.cc
diff --git a/ui/gfx/platform_font_pango.cc b/ui/gfx/platform_font_pango.cc
index 856acc2c432a209b0e451bfa86c8883db92d7e90..d8764b3c8a43239ec423846423148cac447285a2 100644
--- a/ui/gfx/platform_font_pango.cc
+++ b/ui/gfx/platform_font_pango.cc
@@ -18,6 +18,7 @@
#include "third_party/skia/include/core/SkTypeface.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
+#include "ui/gfx/font_list.h"
#include "ui/gfx/pango_util.h"
#if defined(TOOLKIT_GTK)
@@ -202,6 +203,11 @@ int PlatformFontPango::GetStringWidth(const base::string16& text) const {
Font(const_cast<PlatformFontPango*>(this)));
}
+float PlatformFontPango::GetStringWidthF(const base::string16& text) const {
+ return Canvas::GetStringWidthF(
+ text, FontList(Font(const_cast<PlatformFontPango*>(this))));
+}
+
int PlatformFontPango::GetExpectedTextWidth(int length) const {
double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth();
return round(static_cast<float>(length) * char_width);

Powered by Google App Engine
This is Rietveld 408576698