Adding check to look for attachments and scale the accordingly.
This commit is contained in:
parent
7a86febc7c
commit
a47e8d4313
@ -324,14 +324,26 @@ public typealias ActionBlock = () -> Void
|
||||
if let originalAttributedString = originalAttributedString {
|
||||
let attributedString = NSMutableAttributedString(attributedString: originalAttributedString)
|
||||
attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length))
|
||||
originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in
|
||||
// Loop the original attributed string, resize the fonts.
|
||||
|
||||
// Loop the original attributed string, resize the fonts.
|
||||
originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: []) { value, range, stop in
|
||||
|
||||
if let fontObj = value as? UIFont, let stylerSize = MFStyler.sizeObjectGeneric(forCurrentDevice: fontObj.pointSize)?.getValueBased(onSize: size) {
|
||||
attributedString.addAttribute(.font, value: fontObj.withSize(stylerSize) as Any, range: range)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Loop the original attributed string, resize the image attachments.
|
||||
originalAttributedString.enumerateAttribute(.attachment, in: NSRange(location: 0, length: originalAttributedString.length), options: []) { value, range, stop in
|
||||
if value is NSTextAttachment, let attachment = value as? NSTextAttachment,
|
||||
let stylerSize = MFStyler.sizeObjectGeneric(forCurrentDevice: attachment.bounds.width)?.getValueBased(onSize: size) {
|
||||
|
||||
let dimension = round(stylerSize)
|
||||
attachment.bounds = CGRect(x: 0, y: 0, width: dimension, height: dimension)
|
||||
}
|
||||
}
|
||||
attributedText = attributedString
|
||||
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject: MFSizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) {
|
||||
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) {
|
||||
self.font = self.font.withSize(sizeObject.getValueBased(onSize: size))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user