I am rendering numbers in iOS (targeting 7 and up) by storing them in an NSAttributedString and rendering with "drawAtPoint:". I am using Helvetica Neue.
I have noticed that digits of numbers drawn like this are not proportional – the glyphs all have the same width. Even a skinny "1" takes up the same space as a "0".
A 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);
}
With, elsewhere:
-(NSDictionary *) attributes
{
static NSDictionary * attributes;
if(!attributes)
{
attributes = @{
NSFontAttributeName: [UIFont systemFontOfSize:11],
NSForegroundColorAttributeName: [UIColor whiteColor]
};
}
return attributes;
}
This resulting glyphs all have the same width of 6.358 points.
Is there some rendering option I can turn on that to enable proportional digit glyphs? Is there another font (ideally similar to Helvetica Neue) that supports proportional digit glyphs (ideally, built in)? Anything else?
Thank you.