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
1 changed files with 4 additions and 6 deletions

View File

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