DNESS / cocos2d-iphone

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

CCLabelTTF linebreak and size calculation #1067

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I want to anounce two CCLabelTTF issues with the current release 0.99.5 rc1

A) Line Break / Wordwrap Issue
B) Size Calculation Issue

Attached is also a working FontLabelStringDrawing.m which fixes both Issues.
------------------------------

A) Line Break / Wordwrap Issue
What steps will reproduce the problem?
1.Create a CCLabelTTF which ends with a "(" on the Line-End
e.g. 
This is a Testline (This should be in the next Line).

What is the expected output? What do you see instead?
Expected wordwrap: 
This is a Testline
(This should be in the
next Line).

Instead:
This is a TestLine (
This should be in the
next Line).

What cocos2d version / SVN revision are you using ?
0.9.55 rc1

What iPhoneSDK are you using ?
SDK 4.2

Debug or Release ?
both

Does this happens on device ? or on the simulator ? or on both ?
both

Please provide any additional information below.
I added a Diff-File which should correct it (in my tests it works like a charm).

------------------------
B) Size Calculation Issue
1.CGSize textSize = [TextBox sizeWithString:text 
constrainedToSize:CGSizeMake(self.contentLayer.contentSize.width, 0) 
fontName:@"comic.ttf" fontSize:12];

What is the expected output? What do you see instead?
Excpected: Size in Width and Height of the Text
Instead: Width-Size is correct, but Height is only 1 Line.

What cocos2d version / SVN revision are you using ?
0.9.55 rc1

What iPhoneSDK are you using ?
SDK 4.2

Debug or Release ?
both

Does this happens on device ? or on the simulator ? or on both ?
both

Please provide any additional information below.
Problem : "BOOL lastLine" will be set to YES if height of current row exceeds 
the given height (which is zero, because we dont know the height yet).

Solution : there are three Places in FontLabelStringDrawing.m where lastLine 
will be set to YES. Before setting it to yes check if we have a given 
constrained.height. e.g :

if (retValue.height + currentFont.ascender > constrainedSize.height) 
{
  if ( constrainedSize.height > 0 )
  {
    lastLine = YES;
  }
// ..yada, yada.
----------------------------

Original issue reported on code.google.com by hamm.h...@googlemail.com on 21 Dec 2010 at 4:12

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 17 Mar 2011 at 7:09