How to disable label's anti aliasing

I want to get a label with a clear outline.
Mobile devices also display labels with blurred edges, like on windwos.

I tried several methods, but either they weren’t valid anymore or there were only ways to turn off texture anti-aliasing.

https://discuss.cocos2d-x.org/t/label-is-blurry/29202/9
As in this post, calling setAliasTexParameters() of Label’s FontAtlas also gives blurry results.

https://discuss.cocos2d-x.org/t/labels-and-anti-aliasing-in-3-2/17846/6?u=mingminge
This method also doesn’t work.

If the edges of the label are not clear, the game will look messy overall. Is there any solution?
Thank you for reading!! :heart_eyes:

I’m not sure I could help, but I’ll try to. :smiley:




I didn’t find any “how to disable label’s anti aliasing”, but there are a few tricks.

You can increase the font size and decrease the scale of the font. The following 2 links explains how to do it.

TL;DR this is the code snippet

// we multiply the font size by 2.0f
// and we divide the scale by 2.0f
auto yourLabel = Label::createWithTTF("example text", "fonts/arial.ttf", 36 * 2.0f);
yourLabel->setScale(1 / 2.0f); // you can modify the 1 to increase or decrease the scale of the font, (it doesn't affect the font size though)
this->addChild(yourLabel, 0); // addChild

But a post says that increasing the font size may take a lot of memory and eventually crash the device. I don’t know if this will happen to you, but if I increase the font size over ~48, my app crashes. Here is the topic I posted earlier.

Also, if you are using TTF, you can use BMFont. I’m not sure if it will help with the label though.

The label in my app is also blurry, so please reply when you find a solution for this. :smiley:

Oh my, sorry. My response was too late.
.
Thanks for sharing a good way.
I just tested it and it’s definitely sharper than without this method, but the borders are still blurry.
.
I don’t know if it’s just my font, but when the font size is a multiple of 32, I get a completely clear label.
.
If you find another good way, I’ll share it. Thank you!!

1 Like