new LabelTTF stroke and shadow drawing above the base texture

new LabelTTF stroke and shadow drawing above the base texture
0.0 0


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 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);


        if (!context)
            delete[] data;

        // 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)


Here’s a screen shot of my hacked version - the left edge of the stroke is getting cut off and I don’t think all of the offsets are correct, but overall It’s much closer to how it should look:

EDIT first image is messed up and I can’t seem to edit it, look at the second image attached instead