From 29f43b7861c14f65c84b2e375d580da9f590ca34 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 12 Feb 2024 17:31:13 -0600 Subject: [PATCH] added helper for TextStyle extension Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift b/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift index 09fc5dcd..996274e3 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-TextStyle.swift @@ -29,3 +29,17 @@ extension Styler.Font { } } +extension VDS.Font { + internal static func from(fontName: String) -> Self? { + Self.allCases.filter({$0.fontName == fontName }).first + } +} + +extension VDS.TextStyle { + internal static func style(from font: VDS.Font, pointSize: CGFloat) -> TextStyle? { + guard let first = allCases.filter({$0.fontFace == font && $0.pointSize == pointSize}).first else { + return TextStyle(rawValue: "Custom-TextStyle", fontFace: font, pointSize: pointSize) + } + return first + } +}