From a0ac8991f74ce9714b87fe76b11b0dac9e82f81b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 16 Jun 2023 08:37:45 -0500 Subject: [PATCH] added raw representable Signed-off-by: Matt Bruce --- VDS/Typography/Typography.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/VDS/Typography/Typography.swift b/VDS/Typography/Typography.swift index 8d815ad3..3759cb26 100644 --- a/VDS/Typography/Typography.swift +++ b/VDS/Typography/Typography.swift @@ -23,13 +23,22 @@ public enum TextPosition: String, CaseIterable { } } -public struct TextStyle: Equatable { +public struct TextStyle: Equatable, RawRepresentable { public let rawValue: String public let pointSize: CGFloat public let lineHeight: CGFloat public let letterSpacing: CGFloat public let fontFace: Fonts + public init?(rawValue: String) { + guard let style = TextStyle.textStyle(for: rawValue) else { return nil } + self.rawValue = style.rawValue + self.pointSize = style.pointSize + self.lineHeight = style.lineHeight + self.letterSpacing = style.letterSpacing + self.fontFace = style.fontFace + } + public init(rawValue: String, fontFace: Fonts, pointSize: CGFloat, lineHeight: CGFloat, letterSpacing: CGFloat) { self.rawValue = rawValue self.fontFace = fontFace