Description
There's a strange bug.
1.Create a cocos2d v3.x project with "cocos2d iOS"
2.In "IntroScene.m", find "-(id)init" function, and add the following lines under "[self addChild:helloWorldButton];"
//************** under [self addChild:helloWordButton]; (line53)
NSMutableAttributedString* as=[[NSMutableAttributedString alloc] initWithString:@"ABCDE"];
NSRange fullRange=NSMakeRange(0, as.length);
UIFont* font1=[UIFont fontWithName:@"Times New Roman" size:30.0];
[as addAttribute:NSFontAttributeName value:font1 range:fullRange];
[as addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:fullRange];
UIFont* font2=[font1 fontWithSize:15.0];
[as addAttribute:NSFontAttributeName value:font2 range:NSMakeRange(2,2)];
[as addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(2, 2)];
CCLabelTTF* la=[CCLabelTTF labelWithAttributedString:as];
la.position=ccp(100,100);
[self addChild:la];
//**************
3.The result should be a label with "ABCDE". Among the 5 letters, "A" "B" and "E" should be in white color and full size(30.0), "C" and "D" should be in yellow color and half size(15.0). See the picture below:
4.However, the actual result is:
To avoid that bug, you'll have to either change the size of "UIFont* font2" from "15.0" to "15.001" or use 32-bit CPU simulator or device.
Here are my develop environment:
OS X: 10.9.3
XCode: 5.1.1
cocos2d-iphone: v3.0.0
iOS simulator: iPhone Retina 64-bit with iOS 7.1
iOS device: iPad Air with iOS 7.1