jellyflood/Shared/Extensions/Font.swift

44 lines
1.4 KiB
Swift

//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
//
import SwiftUI
extension Font {
var uiFont: UIFont {
switch self {
#if os(iOS)
case .largeTitle:
return UIFont.preferredFont(forTextStyle: .largeTitle)
#endif
case .title:
return UIFont.preferredFont(forTextStyle: .title1)
case .title2:
return UIFont.preferredFont(forTextStyle: .title2)
case .title3:
return UIFont.preferredFont(forTextStyle: .title3)
case .headline:
return UIFont.preferredFont(forTextStyle: .headline)
case .subheadline:
return UIFont.preferredFont(forTextStyle: .subheadline)
case .callout:
return UIFont.preferredFont(forTextStyle: .callout)
case .caption:
return UIFont.preferredFont(forTextStyle: .caption1)
case .caption2:
return UIFont.preferredFont(forTextStyle: .caption2)
case .footnote:
return UIFont.preferredFont(forTextStyle: .footnote)
case .body:
return UIFont.preferredFont(forTextStyle: .body)
default:
return UIFont.preferredFont(forTextStyle: .body)
}
}
}