Swap baseDescriptor and currentDescriptor to allow semibold to come through

This commit is contained in:
Nate Weaver 2020-05-01 01:56:19 -05:00
parent 37f1ebc025
commit 688b24f18e

View File

@ -46,18 +46,16 @@ extension NSAttributedString {
guard let font = font as? Font else { return } guard let font = font as? Font else { return }
let currentDescriptor = font.fontDescriptor let currentDescriptor = font.fontDescriptor
let symbolicTraits = font.fontDescriptor.symbolicTraits let symbolicTraits = baseSymbolicTraits.union(currentDescriptor.symbolicTraits)
let newSymbolicTraits = baseSymbolicTraits.union(symbolicTraits)
var descriptor = baseDescriptor.addingAttributes(currentDescriptor.fontAttributes) var descriptor = currentDescriptor.addingAttributes(baseDescriptor.fontAttributes)
#if canImport(AppKit) #if canImport(AppKit)
descriptor = descriptor.withSymbolicTraits(newSymbolicTraits) descriptor = descriptor.withSymbolicTraits(symbolicTraits)
#else #else
descriptor = descriptor.withSymbolicTraits(newSymbolicTraits)! descriptor = descriptor.withSymbolicTraits(symbolicTraits)!
#endif #endif
let newFont = Font(descriptor: descriptor, size: size) let newFont = Font(descriptor: descriptor, size: size)
mutable.addAttribute(.font, value: newFont as Any, range: range) mutable.addAttribute(.font, value: newFont as Any, range: range)