summaryrefslogtreecommitdiffstats
path: root/ui/gfx/text_utils_ios.mm
diff options
context:
space:
mode:
authorlliabraa <lliabraa@chromium.org>2014-09-03 13:36:55 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-03 20:41:22 +0000
commitc018ddc14ace7181edda4d4be225cf6e88e44d2c (patch)
treeeb10f86f596a6c6c00a72ad1bd18008fd8fdf699 /ui/gfx/text_utils_ios.mm
parent0bd44664493d6783c2d901e2c2c7a01d9a174998 (diff)
downloadchromium_src-c018ddc14ace7181edda4d4be225cf6e88e44d2c.zip
chromium_src-c018ddc14ace7181edda4d4be225cf6e88e44d2c.tar.gz
chromium_src-c018ddc14ace7181edda4d4be225cf6e88e44d2c.tar.bz2
Add NSString category for providing iOS6-style string drawing APIs.
The iOS6-style APIs have been deprecated, but the replacements are more verbose and brittle so this category wraps the replacements in methods similar to the iOS6-style APIs. This category lives in a new target and directory: src/ui/ios, so this CL sets up all the gyp/DEPS stuff and only adds a single method. There will be more methods added in subsequent CLs. BUG=364419 Review URL: https://codereview.chromium.org/497503004 Cr-Commit-Position: refs/heads/master@{#293193}
Diffstat (limited to 'ui/gfx/text_utils_ios.mm')
-rw-r--r--ui/gfx/text_utils_ios.mm6
1 files changed, 2 insertions, 4 deletions
diff --git a/ui/gfx/text_utils_ios.mm b/ui/gfx/text_utils_ios.mm
index e687f35..c6b8570 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