We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ce7748a + 487e399 commit 4ebe6deCopy full SHA for 4ebe6de
Sources/AttributedStringBuilder/Attributes.swift
@@ -104,7 +104,10 @@ extension Attributes {
104
if bold { traits.formUnion(.bold) }
105
if italic { traits.formUnion(.italic )}
106
if !traits.isEmpty { fontDescriptor = fontDescriptor.withSymbolicTraits(traits) }
107
- let font = NSFont(descriptor: fontDescriptor, size: size)!
+ guard let font = NSFont(descriptor: fontDescriptor, size: size) else {
108
+ print("Font creation with traits failed: \(traits). Fallback to named font.")
109
+ return NSFont(name: family, size: size) ?? .systemFont(ofSize: size)
110
+ }
111
return font
112
}
113
0 commit comments