From 57a6561733a8bb4202fe151e3ff61c1e02927a48 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Wed, 8 Apr 2020 06:50:54 -0500 Subject: [PATCH] Use superscript/subscript font feature --- .../Timeline/Cell/NSAttributedString+NetNewsWire.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift b/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift index 60869c98c..6be8a0501 100644 --- a/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift +++ b/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift @@ -54,10 +54,14 @@ extension NSAttributedString { if superscript != 0 { let font = mutable.attribute(.font, at: range.location, effectiveRange: nil) as! NSFont - let size = font.pointSize * 0.6 - let newFont = NSFont(descriptor: font.fontDescriptor, size: size) + let features: [NSFontDescriptor.FeatureKey: Any] = [.typeIdentifier: kVerticalPositionType, .selectorIdentifier: superscript > 0 ? kSuperiorsSelector : kInferiorsSelector] + let attributes: [NSFontDescriptor.AttributeName: Any] = [.featureSettings: [features]] + let descriptor = font.fontDescriptor.addingAttributes(attributes) + + let newFont = NSFont(descriptor: descriptor, size: font.pointSize) mutable.addAttribute(.font, value: newFont as Any, range: range) + mutable.addAttribute(.superscript, value: 0, range: range) } }