It took me almost 3 days to figured out that my problem was that I set the label font to Helvetica .And every time I will want to change it's text will lag.So my question is whats the problem with Helvetica and SKLabel node.When I set it out I thought it was Helvetica Neue.
Asked
Active
Viewed 115 times
1 Answers
3
There is no problem with the font itself but with how the SKLabelNode
handles the Font usage. The problem is, that the SKLabelNode checks/loads the font each time you access it. To stop Swift from doing that, you should create the font at start like that:
let theFont = UIFont(name: "Helvetica", size: 17)
//Access the font like that in your label
theFont?.fontName
The trick here is, that Swift has a reference to your font and doesn't have to load the font new each time. Because currently Swift checks the Font each time.
Something else you could try is, if you didn't do it already, to preload the font:
var yourLabel = SKLabelNode(fontNamed: "Helvetica Neue")

Christian
- 22,585
- 9
- 80
- 106
-
But this is happening only with helvetica – Stefan Scoarta Apr 21 '15 at 18:34
-
That shouldn't be the case. Check the solution if it might work. – Christian Apr 21 '15 at 18:35
-
Now I know what happened,I had a typo.I hate strings because I wrote it Helveltica – Stefan Scoarta Apr 21 '15 at 18:38
-
This saved me! Thank you. The trick was to create an SKLabelNode with a fontName which was used as preloaded reference for all the future labels. Performance is silky smooth now. – Krekin Nov 24 '16 at 14:22