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

Unified Diff: ui/gfx/canvas.h

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync 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
« no previous file with comments | « no previous file | ui/gfx/canvas.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas.h
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 9aa7a0a4e4d6cc126b000520ea9bbca9afcd91f3..4470023afebd786fcde10a64d850e42554d4c28e 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -139,6 +139,15 @@ class GFX_EXPORT Canvas {
int line_height,
int flags);
+ // This is same as SizeStringInt except that fractional size is returned.
+ // See comment in GetStringWidthF for its usage.
+ static void SizeStringFloat(const base::string16& text,
+ const FontList& font_list,
+ float* width,
+ float* height,
+ int line_height,
+ int flags);
+
// Returns the number of horizontal pixels needed to display the specified
// |text| with |font_list|.
static int GetStringWidth(const base::string16& text,
@@ -146,6 +155,14 @@ class GFX_EXPORT Canvas {
// Obsolete version. Use the above version which takes FontList.
static int GetStringWidth(const base::string16& text, const Font& font);
+ // This is same as GetStringWidth except that fractional width is returned.
+ // Use this method for the scenario that multiple string widths need to be
+ // summed up. This is because GetStringWidth returns the ceiled width and
+ // adding multiple ceiled widths could cause more precision loss for certain
+ // platform like Mac where the fractioal width is used.
+ static float GetStringWidthF(const base::string16& text,
+ const FontList& font_list);
+
// Returns the default text alignment to be used when drawing text on a
// Canvas based on the directionality of the system locale language.
// This function is used by Canvas::DrawStringInt when the text alignment
« no previous file with comments | « no previous file | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698