From 48411cb7c3dd9549cd376ed9f7112fdea48ebe34 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jul 2023 14:19:28 -0500 Subject: [PATCH] commented on Fonts Signed-off-by: Matt Bruce --- VDS/Fonts/Font.swift | 2 ++ VDS/Fonts/FontProtocol.swift | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VDS/Fonts/Font.swift b/VDS/Fonts/Font.swift index 57ad5962..ecd692de 100644 --- a/VDS/Fonts/Font.swift +++ b/VDS/Fonts/Font.swift @@ -7,6 +7,7 @@ import Foundation +/// Enum that is matched up for the Verizon fonts. public enum Font: String, FontProtocol { case dsBold case dsRegular @@ -29,6 +30,7 @@ public enum Font: String, FontProtocol { } } + /// File Extension for each of the Font enums. public var fontFileExtension: String { return "otf" } diff --git a/VDS/Fonts/FontProtocol.swift b/VDS/Fonts/FontProtocol.swift index 74ad8701..9ee21939 100644 --- a/VDS/Fonts/FontProtocol.swift +++ b/VDS/Fonts/FontProtocol.swift @@ -8,12 +8,15 @@ import Foundation import UIKit +/// Used in Classes that require Fonts public protocol FontProtocol: CaseIterable, RawRepresentable, Hashable { var fontFileExtension: String { get } var fontName: String { get } } extension FontProtocol { + + /// Registers the fonts used in the VDS Framework. public func register() { guard let bundle = Bundle(identifier: "com.vzw.vds") else { return } Self.allCases.forEach{ font in @@ -29,6 +32,8 @@ extension FontProtocol { } } + /// Registers a font from a fileLocation + /// - Parameter url: URL of the file location. public static func register(from url: URL) throws { guard let fontDataProvider = CGDataProvider(url: url as CFURL) else { throw NSError(domain: "www.verizon.com", code: 123, userInfo: ["description":"Could not create font data provider for \(url)."]) @@ -40,7 +45,11 @@ extension FontProtocol { } } - public func font(ofSize size: CGFloat, isScaled: Bool = true) -> UIFont{ + /// 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() }) guard let found = UIFont(name: self.fontName, size: size) else { return .systemFont(ofSize: size) } return found