I am trying to get the index of the closest character to a point.
The code below works perfectly fine as ling as my text alignment is set to left, as soon as I chage it to right or center it gives me the wrong index. What would be the solution to consider the text alignment while getting closest index to a point?
CTLineRef line = (CTLineRef)[lines objectAtIndex:i];
index = CTLineGetStringIndexForPosition(line, point);
EDIT:
My text alignment is done by adding a paragraph style that has it's textAlignment setting to kCTCenterTextAlignment