added helper for scaledFonts
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
61e843f8f8
commit
02150f8e8c
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user