vds_ios/VDS/Typography/Typography.swift
Matt Bruce dffede1350 refactored Typography into new files
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2023-07-21 10:44:24 -05:00

44 lines
1.3 KiB
Swift

//
// Typography.swift
// VDS
//
// Created by Matt Bruce on 8/16/22.
//
import Foundation
import VDSTypographyTokens
/// This is the Definition that will determine how the Text is drawn
public struct TextStyle: Equatable, RawRepresentable {
public let rawValue: String
public let pointSize: CGFloat
public let lineHeight: CGFloat
public let letterSpacing: CGFloat
public let fontFace: Font
public let edgeInsets: UIEdgeInsets
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
self.edgeInsets = style.edgeInsets
}
public init(rawValue: String, fontFace: Font, pointSize: CGFloat = 0.0, lineHeight: CGFloat = 0.0, letterSpacing: CGFloat = 0.0, edgeInsets: UIEdgeInsets = .zero) {
self.rawValue = rawValue
self.fontFace = fontFace
self.pointSize = pointSize
self.lineHeight = lineHeight
self.letterSpacing = letterSpacing
self.edgeInsets = edgeInsets
}
public var isBold: Bool {
rawValue.hasPrefix("bold")
}
}