CCLabelTTF and word wrapping on spaces

I tried the following code:

auto chatTextSize = CCSizeMake(300,200); CCLabelTTF *chatText = CCLabelTTF::create("This is supposed to be extremely long text that wraps.", "Marker Felt", 24, chatTextSize, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop); chatText->setPosition(ccp(chatTextSize.width/2,chatTextSize.height/2)); layer->addChild(chatText);

But it seems like CCLabelTTF has no capability to wrap test on spaces rather than on letters. This makes the use of this label component extremely limited for wrapping text.

I’ve seen the code here: http://www.cocos2d-x.org/wiki/How_does_CCLabelTTF_support_line_breaks_and_wrapping
And I’m not sure if they just get lucky with the numbers, but their breaks seem to occur on spaces. What am I missing? Is it the way I’m creating my label?

Thanks!!

Could you paste an image to describe the problem?
Thanks.

The result just looks like a label like this:

This is supposed to be extremely lo
ng text that wraps.

Instead of the desired:

This is supposed to be extremely
long text that wraps.

Using a BMFont works, but I’d really like to use TTF if possible. Does this make sense?

I also got same issue. I use the newest 2.2.3 under VS2012. Is this maybe I’m Using Marmalade?
Any clue?

I’ve found a commented section in the CCImage.cpp of the Marmalade section. I decommented it, make some changes, and now the wrap feature is working:

if (cLastCh == ' ' || cLastCh == ',' || cLastCh == '.' || cLastCh == '!' || cLastCh == '?')
		{
			char *pText_temp = (char *)pText;
			int	iCurXCursor_temp = 0;
			while((strlen(pText_temp) > 0) && (*pText_temp!=' ') && (*pText_temp !=',') && (*pText_temp != '.') && (*pText_temp != '!') && (*pText_temp != '?') && (*pText_temp != '/0') && (*pText_temp != '/n'))
			{
				iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText_temp), FT_LOAD_DEFAULT);

				if (iError) {
					return false;
					//break;
				}
				// iCurXCursor_temp += SHIFT6(face->glyph->metrics.horiAdvance) + iInterval; 
				iCurXCursor_temp += RSHIFT6(face->glyph->metrics.horiAdvance) + m_iInterval;
				if (iCurXCursor + iCurXCursor_temp > iMaxWidth && iMaxWidth > 0)
				{
					buildLine(ss, face , iCurXCursor, cLastCh);

					// iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
					iCurXCursor = -RSHIFT6(face->glyph->metrics.horiBearingX); 
				}
				pText_temp++;
			}
		}

If this is a bug, could someone add it on the newest Cocos version?

Thanks,
Zapp