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
Post a Comment