Created
May 26, 2020 20:42
-
-
Save frankrausch/cdbee1681235652c903e56b9f23d66d2 to your computer and use it in GitHub Desktop.
UIFontDescriptor for SF UI high-legibility figures
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
func fontDescriptorWithHighLegibilityMonospacedFigures(for fontDescriptor: UIFontDescriptor) -> UIFontDescriptor { | |
return fontDescriptor.addingAttributes( | |
[ | |
UIFontDescriptor.AttributeName.featureSettings: | |
[ | |
[ // High legibility 6 and 9 | |
UIFontDescriptor.FeatureKey.featureIdentifier: kStylisticAlternativesType, | |
UIFontDescriptor.FeatureKey.typeIdentifier: kStylisticAltOneOnSelector, | |
], | |
[ // High legibility 4 | |
UIFontDescriptor.FeatureKey.featureIdentifier: kStylisticAlternativesType, | |
UIFontDescriptor.FeatureKey.typeIdentifier: kStylisticAltTwoOnSelector, | |
], | |
[ | |
UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType, | |
UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector | |
] | |
] | |
] | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment