ofTrueTypeFont remove background

Hi, I want to draw a simple string:

// In setup
openSans.load("OpenSans/OpenSans-Regular.ttf", 15);

// In draw
ofSetColor(255, 0, 0);
openSans.drawString(ofToString(value), x + 20, y + 70);

But I don’t know how to remove this background:

image

Any ideas?

Thank you

Hi,

Make sure you have ofEnableAlphaBlending(); before ofSetColor(255, 0, 0);
If Alpha Blending is disabled it won’t render correctly.

Hope that helps!
Theo

1 Like

Thank you, but that doesn’t work for me.

// In draw
ofEnableAlphaBlending();
ofSetColor(255, 0, 0);
openSans.drawString(ofToString(value), x + 20, y + 70);

I still see the background

In the setup I’m using

ofEnableDepthTest();

It could have any relation?

yes depth test can mess up transparency – do you need depth test enabled for the type? you image looks 2d (usually for 2d we turn of depth testing since it can have weird side effects if things are on the same z value)

if you do need depth testing, I recommend you load the type with shape data and draw as shapes, I think IIRC

openSans.load("OpenSans/OpenSans-Regular.ttf", 15, false, false, true);
....
openSans.drawStringAsShapes(ofToString(value), x + 20, y + 70);

this will work with depth testing.

1 Like

This solved my problem. Thank you so much! :grinning: