Skip to content

Add global fonts. #6

Open
Open
@matoushybl

Description

@matoushybl

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)
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions