I have a date countdown in my application in which I would like to use the function of the fixed-width number in San Francisco. I am currently extracting a font using this code:
UIFontDescriptor *countdownFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
NSArray *additionalFontSettings = @[@{UIFontFeatureTypeIdentifierKey: @(kNumberSpacingType), UIFontFeatureSelectorIdentifierKey: @(kMonospacedNumbersSelector)},
@{UIFontFeatureTypeIdentifierKey: @(kTextSpacingType), UIFontFeatureSelectorIdentifierKey: @(kMonospacedTextSelector)}];
countdownFontDescriptor = [countdownFontDescriptor fontDescriptorByAddingAttributes: @{UIFontDescriptorFeatureSettingsAttribute: additionalFontSettings}];
UIFont *desiredFont = [UIFont fontWithDescriptor:countdownFontDescriptor size:14];
I get monospace numbers as they should appear, but I have semicolons in my line that separate the numbers. Sometimes I see how this character moves. How can I also get the semicolon width? (That's why I tried to add kTextSpacingType)
Ricky source
share