Index: ui/ios/NSString+CrStringDrawing.mm |
diff --git a/ui/ios/NSString+CrStringDrawing.mm b/ui/ios/NSString+CrStringDrawing.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2ef03e0bd3b0cc65e9affc02d26f62dde2c66cbd |
--- /dev/null |
+++ b/ui/ios/NSString+CrStringDrawing.mm |
@@ -0,0 +1,18 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "ui/ios/NSString+CrStringDrawing.h" |
+ |
+@implementation NSString (CrStringDrawing) |
+ |
+- (CGSize)cr_sizeWithFont:(UIFont*)font { |
+ if (!font) |
+ return CGSizeZero; |
+ NSDictionary* attributes = @{ NSFontAttributeName : font }; |
+ CGSize sizeWithAttributes = [self sizeWithAttributes:attributes]; |
+ return CGSizeMake(ceil(sizeWithAttributes.width), |
+ ceil(sizeWithAttributes.height)); |
stuartmorgan
2014/08/25 20:17:37
Do we actually want the ceil? That's just to exact
lliabraa
2014/08/28 12:13:20
I've split this into two methods. One is a drop-in
|
+} |
+ |
+@end |