Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UIFontDescriptor for SF UI high-legibility figures
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