blob: 75875520bdbb06acf7018feaa51b4385ec7d3bff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
//
// UIFont+Weight.swift
// MullvadVPN
//
// Created by Jon Petersson on 2023-05-23.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import UIKit
extension UIFont {
static func preferredFont(forTextStyle style: TextStyle, weight: Weight) -> UIFont {
return .preferredFont(forTextStyle: style).withWeight(weight)
}
func withWeight(_ weight: UIFont.Weight) -> UIFont {
let newDescriptor = fontDescriptor.addingAttributes([
.traits: [
UIFontDescriptor.TraitKey.weight: weight
]
])
return UIFont(descriptor: newDescriptor, size: pointSize)
}
}
|