Swap baseDescriptor and currentDescriptor to allow semibold to come through
This commit is contained in:
parent
37f1ebc025
commit
688b24f18e
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue