damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

FontManager.swift (3599B)


      1 //
      2 //  FontManager.swift
      3 //  damus
      4 //
      5 //  Created by Ben Weeks on 27/05/2023.
      6 //
      7 import Foundation
      8 import SwiftUI
      9 
     10 struct FontManager {
     11     struct dynamicSize {
     12         public static var largeTitle: CGFloat = UIFont.preferredFont(forTextStyle: .largeTitle).pointSize // - 1
     13         public static var title1: CGFloat = UIFont.preferredFont(forTextStyle: .title1).pointSize //- 0
     14         public static var title2: CGFloat = UIFont.preferredFont(forTextStyle: .title2).pointSize //- 0
     15         public static var title3: CGFloat = UIFont.preferredFont(forTextStyle: .title3).pointSize //- 0
     16         public static var body: CGFloat = UIFont.preferredFont(forTextStyle: .body).pointSize //- 1
     17         public static var callout: CGFloat = UIFont.preferredFont(forTextStyle: .callout).pointSize //- 1
     18         public static var caption1: CGFloat = UIFont.preferredFont(forTextStyle: .caption1).pointSize //- 1
     19         public static var caption2: CGFloat = UIFont.preferredFont(forTextStyle: .caption2).pointSize //- 1
     20         public static var footnote: CGFloat = UIFont.preferredFont(forTextStyle: .footnote).pointSize //- 1
     21         public static var headline: CGFloat = UIFont.preferredFont(forTextStyle: .headline).pointSize //- 1
     22         public static var subheadline: CGFloat = UIFont.preferredFont(forTextStyle: .subheadline).pointSize //- 1
     23         // repeat for all the dynamic sizes
     24     }
     25 
     26     struct Inter {
     27         static let familyRoot = "Inter"
     28 
     29         static let bold = "\(familyRoot)-Bold"
     30         static let regular = "\(familyRoot)-Regular"
     31         static let light = "\(familyRoot)-Light"
     32         static let medium = "\(familyRoot)-Medium"
     33         static let semibold = "\(familyRoot)-SemiBold"
     34         static let italic = "\(familyRoot)-Italic"
     35 
     36         static let largeTitle: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.largeTitle)
     37         static let title1: Font = Font.custom(FontManager.Inter.semibold, size: FontManager.dynamicSize.title1)
     38         static let title2: Font = Font.custom(FontManager.Inter.semibold, size: FontManager.dynamicSize.title2)
     39         static let title3: Font = Font.custom(FontManager.Inter.semibold, size: FontManager.dynamicSize.title3)
     40         static let body: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.body)
     41         static let caption1: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.caption1)
     42         static let caption2: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.caption2)
     43         static let footnote: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.footnote)
     44         static let headline: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.headline)
     45         static let subheadline: Font = Font.custom(FontManager.Inter.regular, size: FontManager.dynamicSize.subheadline)
     46         // repeat for other sizes
     47     }
     48 }
     49 
     50 extension Font {
     51     public static var largeTitle = FontManager.Inter.largeTitle
     52     public static var title1 = FontManager.Inter.title1
     53     public static var title2 = FontManager.Inter.title2
     54     public static var title3 = FontManager.Inter.title3
     55     public static var body = FontManager.Inter.body
     56     public static var caption1 = FontManager.Inter.caption1
     57     public static var caption2 = FontManager.Inter.caption2
     58     public static var footnote = FontManager.Inter.footnote
     59     public static var headline = FontManager.Inter.headline
     60     public static var subheadline = FontManager.Inter.subheadline
     61     // repeat for the rest of the dynamic sizes
     62 }