Make superscript/subscript work again
This commit is contained in:
parent
5d8604714c
commit
ae40172b7c
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue