Text Rendering iOS - Most performant way to render fast changing text
Asked Answered
T

1

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.

Topping answered 27/10, 2014 at 10:19 Comment(4)
a great performance-oriented question. BTW did you simply try a UILabel, to see what the apple engineers have done?Paquette
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.Topping
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.Ofay
Have you tried using a CFAttributedString to apply kerning with CTFont ?Dolley
C
0

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

Cermet answered 4/6, 2015 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.