Using the fontWithSize API in San Francisco

The new fonts in San Francisco in iOS 9 are optimized for the size at which it will be used by adjusting tracking and dynamically switching between SF Display and SF Text. At a WWDC 804 session, it was noted that developers should not use San Francisco when trying to initialize UIFont with fontWithName , for example:

 UIFont *originalFont = [UIFont systemFontOfSize:11]; UIFont *newFont = [UIFont fontWithName:originalFont.fontName size:44]; 

This is because the system cannot optimize the font for the new size when using the fontWithName API.

Instead, it was recommended to get a UIFontDescriptor from the original font and create a new font with a new size, for example:

 UIFont *originalFont = [UIFont systemFontOfSize:11]; UIFont *newFont = [UIFont fontWithDescriptor:originalFont.fontDescriptor size:44]; 

However, they did not mention whether the following optimizations allow or not:

 UIFont *originalFont = [UIFont systemFontOfSize:11]; UIFont *newFont = [originalFont fontWithSize:44]; 

My question is, does the fontWithSize API fontWithSize as the fontWithName API or the fontWithDescriptor API - does this lead to font optimization for the new size or not?

+2
source share
1 answer

I can confirm that fontWithSize creates an optimized font with a new size.

 Printing description of originalFont: <UICTFont: 0x7f8d9ba85340> font-family: ".SFUIText-Regular"; font-weight: normal; font-style: normal; font-size: 11.00pt Printing description of newFont: <UICTFont: 0x7f8d9ba7fe70> font-family: ".SFUIDisplay-Regular"; font-weight: normal; font-style: normal; font-size: 44.00pt 
+4
source

Source: https://habr.com/ru/post/1447034/


All Articles