45 lines
1.3 KiB
Swift
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")
|
|
}
|
|
}
|