ios - San Francisco font + SpriteKit -


is possible use ios 9's new san francisco font in spritekit's sklabelnode? apple has explicitly asked not instantiate font name, that's way sklabelnode provides selecting fonts.

get system font name property fontname of uifont:

let mylabel = sklabelnode(fontnamed:uifont.systemfontofsize(45.0).fontname) 

print result of font name:

.sfuidisplay-regular 

edit:

in terms of wwdc 2015 video: introducing new system fonts, page 298 of pdf says don’t access system font name, e.g.

let myfont = uifont.systemfontofsize(mysize) // …later in code… let myotherfont = uifont.fontwithname(myfont.familyname size:mysize) 

the better practice (page 299) do reuse font descriptors, e.g.

let systemfont = uifont.systemfontofsize(mysize) // …later in code… let myotherfont = uifont.fontwithdescriptor(systemfont.fontdescriptor()  size:mysize) 

please note code describing situation need access font (myfont) defined earlier. in order keep consistency font in app, you'd better use fontdescriptor has been defined rather accessing complete new font without setting attributes. don't confused.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -