Hi,
I’m trying to create a Label* (using a TTF font file), and adding a white stroke (outline) to it.
Any other color seems to be working fine, except for white stroke.
Here is the result using different colors:
The code is:
define FNT_FILE "Marker Felt.ttf"
define FNT_SIZE 40
define SPACING FNT_SIZE * 1.5f
auto pos = FNT_SIZE / 2;
{
// Normal white label
Label* label = Label::createWithTTF("This is a normal white label", FNT_FILE, FNT_SIZE);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// Black stroke white label
Label* label = Label::createWithTTF("This is a black stroke white label", FNT_FILE, FNT_SIZE);
label->enableOutline(Color4B::BLACK, 2);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// Red stroke white label
Label* label = Label::createWithTTF("This is a red stroke white label", FNT_FILE, FNT_SIZE);
label->enableOutline(Color4B::RED, 2);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// White stroke white label
Label* label = Label::createWithTTF("This is a white stroke white label", FNT_FILE, FNT_SIZE);
label->enableOutline(Color4B::WHITE, 2);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// Normal colored label
Label* label = Label::createWithTTF("This is a normal colored label", FNT_FILE, FNT_SIZE);
label->setColor(Color3B(255, 156, 0));
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// Black stroke colored label
Label* label = Label::createWithTTF("This is a black stroke colored label", FNT_FILE, FNT_SIZE);
label->setColor(Color3B(255, 156, 0));
label->enableOutline(Color4B::BLACK, 2);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// Red stroke colored label
Label* label = Label::createWithTTF("This is a red stroke colored label", FNT_FILE, FNT_SIZE);
label->setColor(Color3B(255, 156, 0));
label->enableOutline(Color4B::RED, 2);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
{
// White stroke colored label
Label* label = Label::createWithTTF("This is a white stroke colored label", FNT_FILE, FNT_SIZE);
label->setColor(Color3B(255, 156, 0));
label->enableOutline(Color4B::WHITE, 2);
label->setPosition(Vec2(visibleSize.width / 2, pos));
addChild(label);
pos += SPACING;
}
So my question is:
Is it a bug, or is it impossible to create a white stroke (at least like that)??
Thanks,
Chris