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 |