GitHawkApp/StyledTextKit

CATextLayer?

ahmedk92 opened this issue · 3 comments

First, thanks for this amazing library.

This is a question though, not an issue.

Doesn't CATextLayer provide a similar functionality? I specifically mean the async drawing bit, great work!

CATextLayer has an inherited drawsAsynchronously property. The docs says:

When this property is set to true, the graphics context used to draw the layer’s contents queues drawing commands and executes them on a background thread rather than executing them synchronously. Performing these commands asynchronously can improve performance in some apps. However, you should always measure the actual performance benefits before enabling this capability.

Aside from caching, what advantage does asynchronously outputting to a CGImage have over what CATextLayer provides?

Thanks!

To be honest, I'm not that familiar w/ CATextLayer. I'd love to try using it. I wonder if we lose some rendering control? Like we still use TextKit to draw. I'm not sure this does. I definitely want to read up more on it.

I wonder if we lose some rendering control

Good point! I didn't think about that.

Another unclear thing about CATextLayer is the possibility of thread explosions. drawsAsynchronously offloads rendering to a background thread, but I don't see how can we control what queue/thread will be used. So, what will happen in case of many CATextLayers?

I prefer your current approach. ☺️

Thanks for bringing up the idea!

Sent with GitHawk