CCLabelTTF read visible string?

Hello I’m using CCLabelTTF with specified size like this:

CCLabelTTF* pText = CCLabelTTF::create(text.c_str(), FONT_NAME_TEXT, FONT_SIZE_TEXT, CCSizeMake(650, 700), kCCTextAlignmentLeft);

but given text is too long and only part of text is visible. I need to get some information about label(Visible text, length of visible text or something like that). Is there any way to do it?

Thanks

Hi.
Don’t know, is there a simple way to get visible length of text. But you can set auto-wrapping to text in LabelTTF, just set height to 0. Refer to http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_does_CCLabelTTF_support_line_breaks_and_wrapping

Or, if you really want to know visible length… Try to get width of each character at current fontSize and kerning between each two characters - with that information you can calculate the length.