I ended up fixing it, but found a lack of information on the Internet about it, so I decided to write my decision here.
NSOriginalFont attributes are created when the font used does not support one or more characters per line. NSAttributedString adds these attributes that track that the font was “presumably” before the Helvetica replacement took place. I could make a situation where this is useful (the all-caps font that you sometimes use uppercaseString: on?), But this was not useful to me.
In fact, it was harmful. As I repeated my font-related attributes to reduce the size as shown above, the visible size of the text was reduced, but the NSOriginalFont attribute kept the link to a large size.
There is no built-in constant for NSOriginalFont, but if you call it by name, it can be separated from NSMutableAttributedString. If you do this, you will get the correct results from sizeThatFits, boundingRectWithSize and other similar functions, assuming that you are passing the correct parameters.
I ended up creating a simple category method in NSMutableAttributedString, which is shown below, which works well.
NSMutableAttributedString + StripOriginalFont.h
@interface NSMutableAttributedString (StripOriginalFont) - (void) stripOriginalFont; @end
NSMutableAttributedString + StripOriginalFont.m
@implementation NSMutableAttributedString (StripOriginalFont) - (void) stripOriginalFont{ [self enumerateAttribute:@"NSOriginalFont" inRange:NSMakeRange(0, self.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { if (value){ [self removeAttribute:@"NSOriginalFont" range:range]; } }]; } @end
Presumably, you can just change it to keep it in-sync, and not delete it completely, but it wasn’t useful to me for this particular project.