We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › textWidth() Different fonts same width
Page Index Toggle Pages: 1
textWidth() Different fonts same width? (Read 248 times)
textWidth() Different fonts same width?
Nov 23rd, 2008, 3:12pm
 
Hi. I'm writing a simple sketch that displays all the fonts installed on my computer and places the font's name on the x-axis according to the width of a sample-string.

The problem is, that different font-weights of a font get the same x-position for example Garamond regular and Garamond semibold and so on.

Code:
 
PFont font;
[...]
textFont(font,30);
text(testString,x,y);
float myWidth = textWidth(testString);
[...]
text(fontname,myWidth,20);
[...]
Page Index Toggle Pages: 1