Skip to content

Instantly share code, notes, and snippets.

@soffes
Last active June 22, 2021 22:25
Show Gist options
  • Select an option

  • Save soffes/691ea4bc6b6e194b8ef181f534a7215f to your computer and use it in GitHub Desktop.

Select an option

Save soffes/691ea4bc6b6e194b8ef181f534a7215f to your computer and use it in GitHub Desktop.
import UIKit
extension UIFont {
func withMonospacedNumbers() -> Self {
let fontDescriptor = UIFontDescriptor(name: fontName, size: pointSize).addingAttributes([
.featureSettings: [
[
UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType,
UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector
]
]
])
return Self(descriptor: fontDescriptor, size: pointSize)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment