1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_IOS_NSSTRING_CR_STRING_DRAWING_H_ 6 #define UI_IOS_NSSTRING_CR_STRING_DRAWING_H_ 7 8 #import <UIKit/UIKit.h> 9 10 @interface NSString (CrStringDrawing) 11 12 // Returns the size of the string if it were to be rendered with the specified 13 // font on a single line. The width and height of the CGSize returned are 14 // pixel-aligned. 15 // 16 // This method is a convenience wrapper around sizeWithAttributes: to avoid 17 // boilerplate required to put |font| in a dictionary of attributes. Do not pass 18 // nil into this method. 19 - (CGSize)cr_pixelAlignedSizeWithFont:(UIFont*)font; 20 21 // Deprecated: Use cr_pixelAlignedSizeWithFont: or sizeWithAttributes: 22 // Provides a drop-in replacement for sizeWithFont:, which was deprecated in iOS 23 // 7 in favor of -sizeWithAttributes:. Specifically, this method will return 24 // CGSizeZero if |font| is nil, and the width and height returned are rounded up 25 // to integer values. 26 // TODO(lliabraa): This method was added to ease the transition off of the 27 // deprecated sizeWithFont: method. New call sites should not be added and 28 // existing call sites should be audited to determine the correct behavior for 29 // nil |font| and rounding, then replaced with cr_pixelAlignedSizeWithFont: or 30 // sizeWithAttributes: (crbug.com/364419). 31 - (CGSize)cr_sizeWithFont:(UIFont*)font; 32 33 @end 34 35 #endif // UI_IOS_NSSTRING_CR_STRING_DRAWING_H_ 36