Move declaration/initialization of attributes dictionary closer to use

This commit is contained in:
Nate Weaver 2020-04-30 12:11:52 -05:00
parent 070981553d
commit 951ffeb899

View File

@ -225,8 +225,6 @@ extension NSAttributedString {
let currentDescriptor = currentFont.fontDescriptor let currentDescriptor = currentFont.fontDescriptor
var descriptor = currentDescriptor.copy() as! FontDescriptor var descriptor = currentDescriptor.copy() as! FontDescriptor
var attributes: [NSAttributedString.Key: Any] = [:]
var symbolicTraits = currentDescriptor.symbolicTraits var symbolicTraits = currentDescriptor.symbolicTraits
if styles.contains(.bold) { if styles.contains(.bold) {
@ -262,6 +260,8 @@ extension NSAttributedString {
descriptor = descriptor.addingAttributes(descriptorAttributes) descriptor = descriptor.addingAttributes(descriptorAttributes)
} }
var attributes = [NSAttributedString.Key: Any]()
attributes[.font] = Font(descriptor: descriptor, size: baseFont.pointSize) attributes[.font] = Font(descriptor: descriptor, size: baseFont.pointSize)
if styles.contains(.strikethrough) { if styles.contains(.strikethrough) {