61 lines
1.5 KiB
Swift
61 lines
1.5 KiB
Swift
//
|
|
// Fonts.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 7/27/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
/// Enum that is matched up for the Verizon fonts.
|
|
public enum Font: FontProtocol {
|
|
case edsBold
|
|
case edsRegular
|
|
case dsLight
|
|
case etxBold
|
|
case etxRegular
|
|
case custom(UIFont)
|
|
|
|
public var fontName: String {
|
|
switch self {
|
|
case .edsBold:
|
|
return "VerizonNHGeDS-Bold"
|
|
case .edsRegular:
|
|
return "VerizonNHGeDS-Regular"
|
|
case .dsLight:
|
|
return "VerizonNHGDS-Light"
|
|
case .etxBold:
|
|
return "VerizonNHGeTX-Bold"
|
|
case .etxRegular:
|
|
return "VerizonNHGeTX-Regular"
|
|
case .custom(let font):
|
|
return font.fontName
|
|
}
|
|
}
|
|
|
|
public static var allCases: [Font] {
|
|
[.edsBold, .edsRegular, .dsLight, .etxBold, .etxRegular]
|
|
}
|
|
|
|
/// File Extension for each of the Font enums.
|
|
public var fontFileExtension: String {
|
|
return "otf"
|
|
}
|
|
|
|
/// Returns a UIFont for the fontName and size given.
|
|
/// - Parameters:
|
|
/// - size: Size of the font
|
|
/// - Returns: UIFont for the fontName and Size.
|
|
public func font(ofSize size: CGFloat) -> UIFont{
|
|
DispatchQueue.once(block: { Self.register() })
|
|
switch self {
|
|
case .custom(let font):
|
|
return font
|
|
default:
|
|
guard let found = UIFont(name: self.fontName, size: size) else { return .systemFont(ofSize: size) }
|
|
return found
|
|
}
|
|
}
|
|
}
|