The purpose of the size parameter in createFont()

Good day

I’m tying to figure out what the purpose is of the size parameter in the createFont() function? Is this just the default size that is used when drawing a text? Or is there more to it?

Asking because I also can influence the size of the text with the textSize() function as well. Or maybe asked in another way, is there a difference between

PFont  fontMonospace = createFont("Source Code Pro", 32);
textFont(fontMonospace);
textAlign(LEFT, TOP);
text("Hello power", 0, 0);

and

PFont  fontMonospace = createFont("Source Code Pro", 200);
textFont(fontMonospace);
textAlign(LEFT, TOP);
textSize(32);
text("Hello power", 0, 0);

Visually I have not noticed a difference.

Thanks in advance

Hi @sterretje,

For this you need to look how java Fonts work…

The first loading and creating a “Source Code Pro” font object of size 32pt, which is used then by setting it as textFont.

The second initially loading and creating a “Source Code Pro” font object of size 200pt and afterwards (by textSize(32)) it derives a new “Source Code Pro” font object of size 32 and use it.

Cheers
— mnse

2 Likes

Reading these may provide some clarity:

:)

1 Like

Thanks people. So there is not much difference.

I think that your replies made one thing clear and that is that textSize() actually creates (temporarily), a new object.

@glv, I knew the first two references. I had not found the second two yet (or maybe ignored them).