I am a developing an iPad application in which i have to use CTRunDelegate
. I have defined all the the callbacks that are required viz CTRunDelegateGetAscentCallback
, CTRunDelegateGetDescentCallback
, CTRunDelegateGetWidthCallback
. I dont know how to use CTRunDelegateRef
object that I am creating. Right now what is happening is that my callbacks are not getting called.
Any pointers in this regard will be highly appreciated.
Thanx in advance.
You should add your run delegate as an attribute for a range of characters in your attributed string. See Core Text String Attributes. When drawing, Core Text will call your callbacks to get the sizing of that characters.
Update
This is a sample code for a view drawing a simple text (Note that there's no memory management code here).
The size of the space character between "delegate" and "space" in the text are controlled by the run delegate.