Can I control the size of "drawString()"?

I know I setup the font and the size with

font.load(“verdana.ttf”, 200);

but can I change the size with variables? I’m trying to control the size with sin and cos that makes the letter big and small reapting.

If i put the load() insdie update() or draw() it keeps lagging. maybe it keeps loading the font and thats what makes it lagging. I tried ofScale() but it didn’t change anything.

How can I change the size with a variable that keeps changing its values?

when you load the font, it rasterizes it which means it’s very expensive to keep reloading it.

You can do ofScale() before you draw the font, so scale the drawing up and down

for example

ofPushMatrix();
ofTranslate(300,300);
ofScale(1.3, 1.3);
font.drawString(“hello”, 0,0);
ofPopMatrix();

and change the scale amount to change the size of the drawing

1 Like

Hi,
In fontsExample I changed line 54 - 58 to this:

    ofPushMatrix();
    ofTranslate(422, 92);
    ofScale((((ofGetFrameNum() % 60) / 60.)*2) + 1); // range 1.0 to 5.0
    verdana14A.drawString("verdana 14pt - ", 0, 0); // Draw @ (0,0) since the matrix is translated
    ofPopMatrix();

Which does scale up.
However, since the font size is quite small it looks bad when scaled up. So I think with a big font size, you can get some good results when you start by a downscaled view (ofScale from 0.25 to 1.0 for example).

Edit: double post :stuck_out_tongue:

1 Like

thank you!!

ofPushMatrix() and ofPopMatrix() was the solution!

This changes the size for all the text. If you want to change the size of words or chars you can try ofxFontStash and ofxFontStash2.