Make superscript/subscript work again

This commit is contained in:
Nate Weaver 2020-04-30 17:18:20 -05:00
parent 5d8604714c
commit ae40172b7c
1 changed files with 6 additions and 2 deletions

View File

@ -50,15 +50,19 @@ extension NSAttributedString {
mutable.enumerateAttribute(.font, in: fullRange, options: []) { (font: Any?, range: NSRange, stop: UnsafeMutablePointer<ObjCBool>) in
guard let font = font as? Font else { return }
let currentDescriptor = font.fontDescriptor
let symbolicTraits = font.fontDescriptor.symbolicTraits
let newSymbolicTraits = baseSymbolicTraits.union(symbolicTraits)
var descriptor = baseDescriptor.addingAttributes(currentDescriptor.fontAttributes)
#if canImport(AppKit)
let descriptor = baseDescriptor.withSymbolicTraits(newSymbolicTraits)
descriptor = descriptor.withSymbolicTraits(newSymbolicTraits)
#else
let descriptor = baseDescriptor.withSymbolicTraits(newSymbolicTraits)!
descriptor = descriptor.withSymbolicTraits(newSymbolicTraits)!
#endif
let newFont = Font(descriptor: descriptor, size: size)
mutable.addAttribute(.font, value: newFont as Any, range: range)