DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

CCLabelBMFont might have an issue with accidentally inserting double \n when resizing width for content #1490

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When the string for a CCLabelBMFont contains a \n, for example "Hello 
there\nhow are you doing?"  If you are trying to resize the content to fix a 
specific size, there is a situation where the updateLabel method can put \n\n 
into the string, as its resizing.  

I think the problem is here on line 624:

NSString *trimmedString = [multilineString 
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];  

I believe it should be:

NSString *trimmedString = [multilineString 
stringByTrimmingCharactersInSet:[NSCharacterSet 
whitespaceAndNewlineCharacterSet]];

I might be wrong and it may be working as intended, but after this change, the 
updateLabel call would no long insert \n\n into strings while it was resizing 
them an correctly moves the \n to the right location to fit within the new 
resized area.

Original issue reported on code.google.com by GoodGame...@gmail.com on 8 Jun 2013 at 4:59