added helper for TextStyle extension

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-02-12 17:31:13 -06:00
parent e3b335e6a6
commit 29f43b7861

View File

@ -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
}
}