I have an existing NSAttributedString that may include user edited attributes (i.e. Bold, Italic, Underline). I need to be able to change the base font from say Georgia to Helvetica, while maintaining the format attributes. Setting the font like so, overrides all format attributes (i.e. Georgia-Bold):
NSDictionary *fontFaceStyle = [[NSDictionary alloc] init];
fontFaceStyle = @{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:12.0]};
[combinedAttributedTextString setAttributes:fontFaceStyle range:NSMakeRange(0, combinedAttributedTextString.length)];
I have seen some different but related threads that suggest enumerating over each attribute span in the string, make font change, then reapply the applicable format attributes. This seems pretty intensive, and I'm not sure how you'd apply it when multiple attributes could be present (i.e. Bold AND Italic AND Underline).
Thanks for any suggestions.
NSFontAttributedName
. Adding the underline shouldn't be an issue, but the font, yes. – Larme