New features of the San Francisco font

Hey guys,


I've got two questions concerning the new features of the San Francisco font:

In the WWDC session 'Introducing the New System Fonts' the guy mentioned the possibility of an alternate six and nine in order to avoid confusion. He said this feature is available with code:

UIFontFeatureTypeIdentifierKey: kStylisticAlternativesType
UIFontFeatureSelectorIdentifierKey: kStylisticAltOneOnSelector

That's all well and good, but regrettably that doesn't mean anything to me. I just don't know how to implement and use this feature. Can you give me an example?

2. In iOS 9, proportional numbers are enabled by default instead of monospaced numbers (former default). But how to get the monospaced numbers in iOS 9? Does anyone of you have a clue?


Cheers,


Alex

Hi,


I suggest taking a look

UIFontDescriptor.


Dirk

See this question on Stack Overflow http://stackoverflow.com/questions/21569861/how-to-stop-a-time-uilabel-from-resizing-at-every-time-increment


It's actually about fixed-width numbers, but the same technique applies to the kStylisticAlternativesType feature. You might want to do both.


It looks like the new forum doesn't handle screenshots, so here's a public dropbox link to some images that shows my iOS app ****** on iOS 9 with fixed-width numbers and the normal/alternate style for 6 and 9 digits: https://dl.dropboxusercontent.com/u/6668513/SanFransiconAlternateSixNine.zip

Hi Dirk,


thanks to your hint with UIFontDescriptor question number one has been settled. Regarding question number two: Is there a possibility to get the whole SF font monospaced and not just the digits? In the WWDC session, they said you can get monospaced numbers this way:

NSFont.monospacedDigitsSystemFontOfSize(mySize weight:)

But regrettably they didn't mention a way to get digits and letters monospaced ... Does anyone have a clue how to do that?

EDIT: To get monospaced letters and the alternate six and nine, I've already tried this:

NSArray *monospacedSetting = @[
@{UIFontFeatureTypeIdentifierKey:@(kStylisticAlternativesType), UIFontFeatureSelectorIdentifierKey: @(kStylisticAltOneOnSelector)}, 
@{UIFontFeatureTypeIdentifierKey:@(kTextSpacingType), UIFontFeatureSelectorIdentifierKey: @(kMonospacedTextSelector)}
];
UIFontDescriptor *newDescriptor = [[[UIFont fontWithName:@"SFUIText-Medium" size:12.8] fontDescriptor]
fontDescriptorByAddingAttributes:@{UIFontDescriptorFeatureSettingsAttribute:monospacedSetting}];

Regrettably, I just get the alternate six and nine and not the monospaced letters. Am I doing anything wrong or does kTextSpacingType: kMonospacedTextSelector not work on iOS 9 or rather with the SF font?


Kind regards,


Alex

The San Francisco font contains two sets of glyphs for numbers: one set that has proportional digits, and one set that has monospaced digits. (Many OpenType fonts have this feature.) But there are no glyphs in the font for letters and other characters which are designed to be monospaced. So kMonospacedTextSelector will not do anything.

I did some research and managed to figure out much of the special typographic features mentioned in the WWDC talk, as well as a few others. I've documented the ones found here:

https://github.com/djfitz/SFFontFeatures

Here is a list of features that I support with my library:
  • Straight-sided six and nine

  • Open Four

  • Vertically Centered Colon

  • High Legibility

  • One Story a

  • Upper Case Small Capitals

  • Lower Case Small Capitals

  • Contextual Fractional Forms

  • Monospaced/Proportional Numbers

  • Superiors/Superscripts

  • Inferiors/Subscripts

Good luck!

Doug Hill
New features of the San Francisco font
 
 
Q