Closed pkluz closed 7 years ago
When a theme is instantiated without an underlying definition (Theme()), and subsequently proceeds to evaluating the following function:
Theme()
extension UIFont { class func font(_ keyPath: String, dictionary: [String: Any], fallback: UIFont) -> UIFont { let size = Float(dictionary[keyPath: KeyPath("\(keyPath).size")] as? String ?? "0.0") ?? Float(UIFont.systemFontSize) let name = dictionary[keyPath: KeyPath(keyPath)] as? String ?? fallback.fontName return UIFont(name: name, size: CGFloat(size)) ?? fallback } }
the fallback is NOT returned correctly. Instead, the correct font name with size 0 is returned, which makes the return statement never produce nil. Instead it returns Helvetica at size 0.0, which is not the desired behavior.
nil
Helvetica
0.0
https://github.com/Originate/OriginateTheme/commit/639cb09869dfc924665ff642659390727a518f2c
would you look at that.
When a theme is instantiated without an underlying definition (
Theme()
), and subsequently proceeds to evaluating the following function:the fallback is NOT returned correctly. Instead, the correct font name with size 0 is returned, which makes the return statement never produce
nil
. Instead it returnsHelvetica
at size0.0
, which is not the desired behavior.