From fbdcdfc2774428db1efa330e18645280d1da84ab Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 8 Mar 2024 12:34:23 -0600 Subject: [PATCH] refactored method Signed-off-by: Matt Bruce --- VDS/Typography/Typogprahy+Styles.swift | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift index 0cd6e614..0136d3c4 100644 --- a/VDS/Typography/Typogprahy+Styles.swift +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -211,20 +211,9 @@ extension TextStyle { } public static func convert(font: UIFont) -> TextStyle { - var found: TextStyle? - - for textStyle in allCases { - if font.fontName == textStyle.fontFace.fontName && - font.pointSize == textStyle.pointSize { - found = textStyle - break - } + guard let found = allCases.first(where: { font.fontName == $0.fontFace.fontName && font.pointSize == $0.pointSize} ) else { + return TextStyle(rawValue: "Custom\(font.fontName)", fontFace: .custom(font), pointSize: font.pointSize) } - - guard let found else { - return TextStyle(rawValue: "Custom", fontFace: .custom(font.fontName), pointSize: font.pointSize) - } - return found } }