From ae40172b7c29b4ce386d93f8fd3744130ed0de18 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Thu, 30 Apr 2020 17:18:20 -0500 Subject: [PATCH] Make superscript/subscript work again --- Shared/Extensions/NSAttributedString+NetNewsWire.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Shared/Extensions/NSAttributedString+NetNewsWire.swift b/Shared/Extensions/NSAttributedString+NetNewsWire.swift index 2fcaee14c..a45039d21 100644 --- a/Shared/Extensions/NSAttributedString+NetNewsWire.swift +++ b/Shared/Extensions/NSAttributedString+NetNewsWire.swift @@ -50,15 +50,19 @@ extension NSAttributedString { mutable.enumerateAttribute(.font, in: fullRange, options: []) { (font: Any?, range: NSRange, stop: UnsafeMutablePointer) 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)