If I remove the following attribute pair (value/key), everything works (color, font, etc.).

(id)paragraphStyle, (NSString*)kCTParagraphStyleAttributeName,

If I put this attribute on attrs dictionary, the program enters on an infinite loop when I use CTFrameGetVisibleStringRange.

What I'm doing wrong?

UPDATE: After Mattias answer I figured out that the code wasn't the problem. There were some HTML tags lost in the middle of the text (garbage) and for some reason the FrameSetter was getting lost and returning and empty range. When there's no HTML tags on text everything went ok.

1 Answer
1

I would suspect that CTParagraphStyleCreate returns NULL for some reason causing dictionaryWithObjectsAndKeys: to create an empty dictionary. But I can't see any error with your paragraph style setting.

Take a look at my CoreTextLabel.m class source which uses paragraph style settings.

I just noticed that when I enable that line, CTFrameGetVisibleStringRange returns CTFrame: visible string range = (14058, 0). This is an empty range as length == 0. This is causing the infinite loop because I'm adding frame.length to the textPosition to process the visible columns.
–
javsmoNov 4 '11 at 18:29

Hmm ok. Can you make your example more complete?
–
Mattias WadmanNov 4 '11 at 19:24

Sorry, I figured out what was the problem. There were some HTML tags lost in the middle of the text (garbage) and for some reason the FrameSetter was getting lost and returning and empty range. When there's no HTML tags on text everything went ok.
–
javsmoNov 4 '11 at 20:31