updated to handle custom fonts
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
fbdcdfc277
commit
fd641a85cf
@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
/// Enum that is matched up for the Verizon fonts.
|
||||
public enum Font: FontProtocol {
|
||||
@ -14,7 +15,7 @@ public enum Font: FontProtocol {
|
||||
case dsLight
|
||||
case etxBold
|
||||
case etxRegular
|
||||
case custom(String)
|
||||
case custom(UIFont)
|
||||
|
||||
public var fontName: String {
|
||||
switch self {
|
||||
@ -28,8 +29,8 @@ public enum Font: FontProtocol {
|
||||
return "VerizonNHGeTX-Bold"
|
||||
case .etxRegular:
|
||||
return "VerizonNHGeTX-Regular"
|
||||
case .custom(let fontName):
|
||||
return fontName
|
||||
case .custom(let font):
|
||||
return font.fontName
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,4 +42,19 @@ public enum Font: FontProtocol {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import Foundation
|
||||
import UIKit
|
||||
|
||||
/// Used in Classes that require Fonts
|
||||
public protocol FontProtocol: Hashable {
|
||||
public protocol FontProtocol {
|
||||
var fontFileExtension: String { get }
|
||||
var fontName: String { get }
|
||||
static var allCases: [Self] { get }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user