I process numbers in iOS (targeting 7 and above), storing them in NSAttributedString and rendering using drawAtPoint :. I am using Helvetica Neue.
I noticed that the digits of numbers drawn in this way are not proportional - all glyphs have the same width. Even the skinny "1" takes the same place as the "0".
The test confirms this:
for(NSInteger i=0; i<10; ++i) { NSString *iString = [NSString stringWithFormat: @"%d", i]; const CGSize iSize = [iString sizeWithAttributes: [self attributes]]; NSLog(@"Size of %d is %f", i, iSize.width); }
C, in another place:
-(NSDictionary *) attributes { static NSDictionary * attributes; if(!attributes) { attributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:11], NSForegroundColorAttributeName: [UIColor whiteColor] }; } return attributes; }
The resulting glyphs have the same width of 6.358 points.
Is there any rendering option that I can enable to include proportional characters ? Is there another font (ideally similar to Helvetica Neue) that supports proportional digital characters (ideally, embedded)? Anything else?
Thanks.
ios nsstring uifont uifontdescriptor
Benjohn
source share