Is there a way to add as an attribute for NSAttributedString ( NSMuttableAttributeString ) not just a font, but a font family for a range ? The client-server application receives the product description formatted in HTML, it is necessary to preserve the size, thickness, italics (if any) of the font, but replace its family. If you specify a font with a size as an attribute, the formatting associated with the size and thickness of the font is erased.
UPDATED: Decided with a crutch
let d : NSMutableAttributedString = try NSMutableAttributedString(data: ((здесь html текст).dataUsingEncoding(NSUTF8StringEncoding))!, options: [NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType], documentAttributes: nil) d.enumerateAttribute(NSFontAttributeName, inRange: NSMakeRange(0, d.length), options: NSAttributedStringEnumerationOptions()) { value, range, stop in let oldFont = value as! UIFont var newFontName : String if oldFont.fontName.lowercaseString.containsString("bold") { newFontName = Decorator.fontArray["Bold"]! } else if oldFont.fontName.lowercaseString.containsString("italic") { newFontName = Decorator.fontArray["Italic"]! } else { newFontName = Decorator.fontArray["Regular"]! } let newFont = UIFont(name: newFontName, size: 14) d.addAttribute(NSFontAttributeName, value : newFont!, range : range) } Where Decorator.fontArray is a Dictionary<String, String> with keys with font type names, values — font names for these types. It will not work if the font name is not bold or italic, which means the question remains valid))