Skip to content

Commit 921e268

Browse files
committed
Merge pull request #953 from sarah-j-smith/v3.1
Handle odd line seperators in CCLabelBMFont.
2 parents f637111 + 858b6a9 commit 921e268

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cocos2d-ui-tests/tests/CCBMFontTest.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
static NSString *TEST_STRINGS[] = {
1313
@"ABCDEFGHIJKLM\nNOPQRSTUVWXYZ",
1414
@"abcdefghijklm\nnopqrstuvwxyz",
15+
@"first line\u2028second line",
1516
@",.?!;:'\"",
1617
@"()[]{}<>\\|/\n",
1718
@"@#$%^&*+-=_",

cocos2d/CCLabelBMFont.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ -(void) createFontChars
762762
// since the Y position needs to be calcualted before hand
763763
for(NSUInteger i=0; i < stringLen-1;i++) {
764764
unichar c = [_string characterAtIndex:i];
765-
if( c=='\n')
765+
if([[NSCharacterSet newlineCharacterSet] characterIsMember:c])
766766
quantityOfLines++;
767767
}
768768

@@ -776,7 +776,7 @@ -(void) createFontChars
776776
for(NSUInteger i = 0; i<stringLen; i++) {
777777
unichar c = [_string characterAtIndex:i];
778778

779-
if (c == '\n') {
779+
if ([[NSCharacterSet newlineCharacterSet] characterIsMember:c]) {
780780
nextFontPositionX = 0;
781781
nextFontPositionY -= _configuration->_commonHeight;
782782
continue;

0 commit comments

Comments
 (0)