Last active
October 20, 2020 18:32
-
-
Save krzyzanowskim/e986890689e4b2f980d96be07de365f8 to your computer and use it in GitHub Desktop.
Private "NSCTFontUIUsageAttribute" overwrites public "NSFontFamilyAttribute" attribute ππ if both set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/krzyzanowskim/status/1142800558480351232 | |
// Private "NSCTFontUIUsageAttribute" overwrites public "NSFontFamilyAttribute" attribute ππ if both set. | |
extension UIFontDescriptor.AttributeName { | |
static let fontUIUsageAttribute = UIFontDescriptor.AttributeName.init(rawValue: "NSCTFontUIUsageAttribute") | |
} | |
extension UIFontDescriptor { | |
class func preferredFontDescriptor(withTextStyle style: UIFont.TextStyle, family: String) -> UIFontDescriptor { | |
let preferredFontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style).withFamily(family) | |
let finalAttributes = preferredFontDescriptor.fontAttributes.filter({ $0.key != .fontUIUsageAttribute }) | |
return UIFontDescriptor(fontAttributes: finalAttributes) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment