diff --git a/VDS/Fonts/FontProtocol.swift b/VDS/Fonts/FontProtocol.swift index 9524f2a4..74ad8701 100644 --- a/VDS/Fonts/FontProtocol.swift +++ b/VDS/Fonts/FontProtocol.swift @@ -39,13 +39,16 @@ extension FontProtocol { throw error!.takeUnretainedValue() } } - - public func font(ofSize size: CGFloat) -> UIFont{ + + public func font(ofSize size: CGFloat, isScaled: Bool = true) -> UIFont{ DispatchQueue.once(block: { self.register() }) - if let font = UIFont(name: self.fontName, size: size){ - return UIFontMetrics.default.scaledFont(for: font) - } else { - return UIFontMetrics.default.scaledFont(for: UIFont.systemFont(ofSize: size)) - } + guard let found = UIFont(name: self.fontName, size: size) else { return .systemFont(ofSize: size) } + return found + } +} + +extension UIFont { + public var scaledFont: UIFont { + UIFontMetrics.default.scaledFont(for: self) } }