ReactantUI icon indicating copy to clipboard operation
ReactantUI copied to clipboard

Add global fonts.

Open matoushybl opened this issue 7 years ago • 0 comments

OpenSans.font.xml

<font>
    <variant name="light" identifier="OpenSans-Light" />
    <variant name="regular" identifier="OpenSans" />
    <variant name="semibold" identifier="OpenSans-Semibold" />
    <variant name="bold" identifier="OpenSans-Bold" />
    <variant name="extrabold" identifier="OpenSans-Extrabold" />
</font>

output:

extension UIFont {
    enum OpenSans {
        case light
        case regular
        case semibold
        case bold
        case extrabold

        private var identifier: String {
            switch self {
            case .light:
                return "OpenSans-Light"
            case .regular:
                return "OpenSans"
            case .semibold:
                return "OpenSans-Semibold"
            case .bold:
                return "OpenSans-Bold"
            case .extrabold:
                return "OpenSans-Extrabold"
            }
        }

        subscript(size: CGFloat) -> UIFont {
            return font(size: size)
        }

        func font(size: CGFloat) -> UIFont {
            return UIFont(identifier, size)
        }
    }
}

matoushybl avatar Jun 08 '17 10:06 matoushybl