update to look for a font with a found style to use our FontLabelAttribute

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-11-10 14:43:40 -06:00
parent e46017f315
commit 0b73207bd6

View File

@ -39,6 +39,11 @@ public extension NSAttributedString {
static func createAttributeModelFor(key: NSAttributedString.Key, range: NSRange, value: Any) -> (any LabelAttributeModel)? {
guard let value = value as? AnyHashable else { return nil }
return AnyAttribute(location: range.location, length: range.length, key: key, value: value)
guard let font = value as? UIFont, let style = TypographicalStyle.style(for: font.fontName, size: font.pointSize), key == .font
else {
return AnyAttribute(location: range.location, length: range.length, key: key, value: value)
}
return FontLabelAttribute(location: range.location, length: range.length, style: style)
}
}