Loading...
Logo
Processing Forum

Font size in pixels

in Programming Questions  •  11 months ago  
Hi support,
I have a doubt regarding the font size in units of pixels that is used when using loadfont, etc... In the example below I create a font of size 40 but when I used the method textWidth to determine its size, it says 31 instead of 40, What I am doing wrong?
Thanks and brgds,

PFont fuente;
fuente=loadFont("AlBayan-Bold-40.vlw");
textFont(fuente,40);
String cadena="H";
float pixeles; //pixels counter
pixeles=textWidth(cadena);
println(pixeles);
//check
text("O",30,30);
line(30,15,61,15);

Replies(2)

Re: Font size in pixels

11 months ago
The font size measures the height of the font, not its width.

Re: Font size in pixels

11 months ago
great, thanks a lot.