I’m having a problem with the new stroke and shadow systems. You can see it in the screen shot I’ve attached, which has a 1 point stroke and a shadow with blur of 1.
In normal stroke and shadow systems, the original texture is drawn on top of the stroke and the shadow. With the new system, the stroke and shadow seems to be drawing on top of the original texture, resulting in some strange effects.
I hacked CCImage._initWithString() to draw the string twice, ignoring the shadow and stroke textures the second time through. This results in a much improved appearance, but seems rather wasteful and I don’t think the offsets are correct in the rendering (the original text draws down and to the left of where it should be). I’ve included the code I added below (starts on line 400 of the CCImage.mm I have). I’m pretty sure this could be done more efficiently using the push/pop context system, but I haven’t dug into that.
I’ve also noticed that the variable textOrigingY has an extra ‘g’ in it.
// draw text
colorSpace = CGColorSpaceCreateDeviceRGB();
context = CGBitmapContextCreate(data,
(int)(dim.width) * 4,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
// text color
CGContextSetRGBFillColor(context, pInfo->tintColorR, pInfo->tintColorG, pInfo->tintColorB, 1);
// move Y rendering to the top of the image
CGContextTranslateCTM(context, 0.0f, (dim.height - shadowStrokePaddingY) );
CGContextScaleCTM(context, 1.0f, -1.0f); //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential
// store the current context
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
// pop the context
// release the context
I’d much appreciate it if someone who is more familiar with the texture rendering could write up a proper fix for this.
Screen Shot 2013-06-21 at 3.55.29 PM.png (54.0 KB)