Originate / OriginateTheme

OriginateTheme is a lightweight user interface theming framework.
MIT License
5 stars 0 forks source link

Font Initialization Bug #36

Closed pkluz closed 7 years ago

pkluz commented 7 years ago

When a theme is instantiated without an underlying definition (Theme()), and subsequently proceeds to evaluating the following function:

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.

allewun commented 7 years ago

https://github.com/Originate/OriginateTheme/commit/639cb09869dfc924665ff642659390727a518f2c

pkluz commented 7 years ago

would you look at that.