//
//  AppFont.swift
//  1Weather
//
//  Created by Dmitry Stepanets on 28.11.2020.
//

import UIKit

public struct AppFont {
    private static func fontDescriptor(size:CGFloat, weight:UIFont.Weight) -> UIFontDescriptor {
        let traitsDict = [UIFontDescriptor.TraitKey.weight: weight]
        let descriptor = UIFontDescriptor(fontAttributes: [UIFontDescriptor.AttributeName.size : size,
                                                           UIFontDescriptor.AttributeName.family : "SF Pro",
                                                           UIFontDescriptor.AttributeName.traits : traitsDict
        ])
        
        return descriptor
    }
    
    public struct SFPro {
        static func regular(size: CGFloat) -> UIFont {
            let descriptor = AppFont.fontDescriptor(size: size, weight: .regular)
            return UIFont(descriptor: descriptor, size: size)
        }
        
        static func bold(size: CGFloat) -> UIFont {
            let descriptor = AppFont.fontDescriptor(size: size, weight: .bold)
            return UIFont(descriptor: descriptor, size: size)
        }
        
        static func medium(size:CGFloat) -> UIFont {
            let descriptor = AppFont.fontDescriptor(size: size, weight: .medium)
            return UIFont(descriptor: descriptor, size: size)
        }
        
        static func semibold(size: CGFloat) -> UIFont {
            let descriptor = AppFont.fontDescriptor(size: size, weight: .semibold)
            return UIFont(descriptor: descriptor, size: size)
        }
    }
}
