Created
August 13, 2019 01:45
-
-
Save cjmlgrto/a32bc64f32a982110202182602caddf4 to your computer and use it in GitHub Desktop.
Tabular Fonts
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
import Foundation | |
import UIKit | |
extension UIFont { | |
static func tabularSystemFont(ofSize: CGFloat, weight: UIFont.Weight) -> UIFont { | |
let features = [ | |
[ | |
UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType, | |
UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector | |
] | |
] | |
let fontDescriptor = UIFont.systemFont(ofSize: ofSize, weight: weight).fontDescriptor.addingAttributes([UIFontDescriptor.AttributeName.featureSettings: features]) | |
return UIFont(descriptor: fontDescriptor, size: ofSize) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment