Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save frankrausch/cdbee1681235652c903e56b9f23d66d2 to your computer and use it in GitHub Desktop.
Save frankrausch/cdbee1681235652c903e56b9f23d66d2 to your computer and use it in GitHub Desktop.
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