From 0b73207bd6af80277d097362c3df374b096e5f1e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 10 Nov 2022 14:43:40 -0600 Subject: [PATCH] update to look for a font with a found style to use our FontLabelAttribute Signed-off-by: Matt Bruce --- VDS/Components/Label/Attributes/LabelAttributeModel.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Label/Attributes/LabelAttributeModel.swift b/VDS/Components/Label/Attributes/LabelAttributeModel.swift index 321e2074..7196a346 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeModel.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeModel.swift @@ -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) } }