@@ -56,6 +56,13 @@ public struct Font: Hashable, Sendable {
56
56
return font
57
57
}
58
58
59
+ /// Selects whether or not to italicize the font.
60
+ public func italic( _ italic: Bool = true ) -> Font {
61
+ var font = self
62
+ font. overlay. italicize = italic
63
+ return font
64
+ }
65
+
59
66
/// Overrides the font's weight. Takes an optional for convenience. Does
60
67
/// nothing if given `nil`.
61
68
public func weight( _ weight: Weight ? ) -> Font {
@@ -167,6 +174,10 @@ public struct Font: Hashable, Sendable {
167
174
/// overlay has been applied if one is present.
168
175
var emphasize : Bool = false
169
176
177
+ /// If `true`, overrides the font to be italicized. If `false`, does
178
+ /// nothing.
179
+ var italicize : Bool = false
180
+
170
181
/// Overrides the font's design.
171
182
var design : Design ?
172
183
@@ -185,6 +196,9 @@ public struct Font: Hashable, Sendable {
185
196
if emphasize {
186
197
resolvedFont. weight = emphasizedWeight
187
198
}
199
+ if italicize {
200
+ resolvedFont. isItalic = true
201
+ }
188
202
if let pointSize {
189
203
resolvedFont. pointSize = pointSize
190
204
}
@@ -212,6 +226,7 @@ public struct Font: Hashable, Sendable {
212
226
public var lineHeight : Double
213
227
public var weight : Weight
214
228
public var design : Design
229
+ public var isItalic : Bool
215
230
}
216
231
217
232
public struct Context : Sendable {
@@ -237,7 +252,8 @@ public struct Font: Hashable, Sendable {
237
252
// constant ratio).
238
253
lineHeight: ( size * 1.25 ) . rounded ( . awayFromZero) ,
239
254
weight: weight ?? . regular,
240
- design: design ?? . default
255
+ design: design ?? . default,
256
+ isItalic: false
241
257
)
242
258
}
243
259
case . dynamic( let textStyle) :
@@ -248,7 +264,8 @@ public struct Font: Hashable, Sendable {
248
264
pointSize: resolvedTextStyle. pointSize,
249
265
lineHeight: resolvedTextStyle. lineHeight,
250
266
weight: resolvedTextStyle. weight,
251
- design: . default
267
+ design: . default,
268
+ isItalic: false
252
269
)
253
270
}
254
271
0 commit comments