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

Unified Diff: ui/gfx/text_utils_ios.mm

Issue 497503004: Add NSString category for providing iOS6-style string drawing APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't cache scale Created 6 years, 3 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 | « ui/gfx/platform_font_ios.mm ('k') | ui/ios/NSString+CrStringDrawing.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/text_utils_ios.mm
diff --git a/ui/gfx/text_utils_ios.mm b/ui/gfx/text_utils_ios.mm
index e687f3545474d46f90927510ca173735ed07175d..c6b8570239caea2143531c91051b6e369f0abaf2 100644
--- a/ui/gfx/text_utils_ios.mm
+++ b/ui/gfx/text_utils_ios.mm
@@ -10,6 +10,7 @@
#include "base/strings/sys_string_conversions.h"
#include "ui/gfx/font_list.h"
+#include "ui/ios/NSString+CrStringDrawing.h"
namespace gfx {
@@ -20,10 +21,7 @@ int GetStringWidth(const base::string16& text, const FontList& font_list) {
float GetStringWidthF(const base::string16& text, const FontList& font_list) {
NSString* ns_text = base::SysUTF16ToNSString(text);
NativeFont native_font = font_list.GetPrimaryFont().GetNativeFont();
- if (!native_font)
- return 0;
- NSDictionary* attributes = @{ NSFontAttributeName : native_font };
- return std::ceil([ns_text sizeWithAttributes:attributes].width);
+ return [ns_text cr_sizeWithFont:native_font].width;
}
} // namespace gfx
« no previous file with comments | « ui/gfx/platform_font_ios.mm ('k') | ui/ios/NSString+CrStringDrawing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698