Impressia/Vernissage/Extensions/UIFont+Font.swift

43 lines
1.4 KiB
Swift
Raw Normal View History

2023-02-27 16:04:42 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
2023-03-28 10:35:38 +02:00
// Licensed under the Apache License 2.0.
2023-02-27 16:04:42 +01:00
//
2023-02-27 16:04:42 +01:00
import SwiftUI
extension UIFont {
class func preferredFont(from font: Font) -> UIFont {
let uiFont: UIFont
2023-02-27 16:04:42 +01:00
switch font {
case .largeTitle:
uiFont = UIFont.preferredFont(forTextStyle: .largeTitle)
case .title:
uiFont = UIFont.preferredFont(forTextStyle: .title1)
case .title2:
uiFont = UIFont.preferredFont(forTextStyle: .title2)
case .title3:
uiFont = UIFont.preferredFont(forTextStyle: .title3)
case .headline:
uiFont = UIFont.preferredFont(forTextStyle: .headline)
case .subheadline:
uiFont = UIFont.preferredFont(forTextStyle: .subheadline)
case .callout:
uiFont = UIFont.preferredFont(forTextStyle: .callout)
case .caption:
uiFont = UIFont.preferredFont(forTextStyle: .caption1)
case .caption2:
uiFont = UIFont.preferredFont(forTextStyle: .caption2)
case .footnote:
uiFont = UIFont.preferredFont(forTextStyle: .footnote)
case .body:
uiFont = UIFont.preferredFont(forTextStyle: .body)
2023-02-27 16:04:42 +01:00
default:
uiFont = UIFont.preferredFont(forTextStyle: .body)
}
2023-02-27 16:04:42 +01:00
return uiFont
}
}