CTLineGetImageBounds is a very extensive operation
-
13-10-2019 - |
Question
I'm working on a library that does some rich text abstraction using Core Text (https://github.com/pothibo/CMFramework), Everything is working and right now, I'm trying to find some major flaw in the code that could speed up the object at runtime.
Running the Time Profiler, I found that CTLineGetImageBounds is a very heavy operation, it takes twice as long to execute than CTLineDraw. However, I need to get the bounds of the line when I render the text so I cannot not use it.
Would anyone know a solution to speed up this process? You can see the whole code here
Solution
I have actually found something. CTLineGetTypographicBounds yields the same result and doesn't require to actually have a CGContextRef.
Result can be seen here