processing / processing-docs

[Deprecated] Processing reference, examples, tutorials, and website
https://processing.org
371 stars 179 forks source link

Fixing textFont Reference sample code #800

Closed tcoppex closed 4 years ago

tcoppex commented 4 years ago

Issue description

The example use loadFont (lign 3) with a size parameter and a font of type ttf, which should be specified by textFont (lign 6) instead.

Alternatively use createFont instead, which seems to have been the original intent.

(Similars previous issues like #291 has been closed with no fixes so I reopened one)

URL(s) of affected page(s)

https://processing.org/reference/textFont_.html

Proposed fix

Either change the sample to use the right arguments or use createFont instead of loadFont :

PFont mono;
// The font "andalemo.vlw" must be located in the 
// current sketch's "data" directory to load successfully
mono = loadFont("andalemo.vlw");
background(0);
textFont(mono, 32);
text("word", 12, 60);

or

PFont mono;
// The font "andalemo.ttf" must be located in the 
// current sketch's "data" directory to load successfully
mono = createFont("andalemo.ttf", 32);
background(0);
textFont(mono);
text("word", 12, 60);

The second option seems more elegant :)

REAS commented 4 years ago

Thank you for finding this and the good suggestion. It will be online with the next update.