vds_ios/VDS/Typography/Typography+Base.swift
Matt Bruce d98b08d26e removed old frameworks to add the 1 primary VDSTokens
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-01-23 10:09:09 -06:00

45 lines
1.3 KiB
Swift

//
// Typography.swift
// VDS
//
// Created by Matt Bruce on 8/16/22.
//
import Foundation
import UIKit
import VDSTokens
/// 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")
}
}