13

What is the most performant way to render fast changing text (10-15 numbers that change every single frame) in iOS? Those are the tries that I did so far:

1) CATextLayer + CTFont and NSString: Quite fast but no access to kerning, which I need. (If somebody knows a trick how to get kerning to work with CTFont and without NSAttributedString, that'd also be cool, but it's not the main question ;) )

2) CATextLayer + NSAttributedString: Slow and laggy. I see huge FPS drops compared to 1). In my app this change lets the FPS drop from 50-60 to 30.

3) Bitmap Fonts, using UIImageViews and UIImage to display the numbers: Quite fast as well, though not really satisfying as there should be a better way / a more natural way in iOS to render fonts efficiently.

EDIT:

4) UILabel + NSString - Quite Fast, but again no access to kerning.

5) UILabel + NSAttributedString - Slow and laggy again.

Rendering an NSAttributedString is a lot slower than rendering a basic NSString. This is really frustrating as all I need from NSAttributedString at the moment is the spacing between letters.

Jasper
  • 7,031
  • 3
  • 35
  • 43
Max
  • 2,699
  • 2
  • 27
  • 50
  • a great performance-oriented question. BTW did you simply try a UILabel, to see what the apple engineers have done? – Fattie Oct 27 '14 at 10:46
  • Thank you, I just tried it (edited into question), and it's quite fast as long as you don't use attributedText, which I need for changing the kerning. – Max Oct 27 '14 at 16:25
  • Maybe try Sprite Kit with a single texture of your fonts for an even faster bitmap blitting of your image based fonts - assuming Sprite Kit batches those draw calls and is good at this. SKView to the.... textscue. – Confused Oct 27 '14 at 17:31
  • Have you tried using a `CFAttributedString` to apply kerning with `CTFont` ? – Lefteris Jun 02 '15 at 13:20

1 Answers1

0

Apple added TextKit to iOS recently, you might start by checking this: TextKit documentation.

aout
  • 300
  • 1
  • 2
  • 10