Skip to content

Fixing textFont Reference sample code #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tcoppex opened this issue Mar 5, 2020 · 1 comment
Closed

Fixing textFont Reference sample code #800

tcoppex opened this issue Mar 5, 2020 · 1 comment

Comments

@tcoppex
Copy link

tcoppex commented Mar 5, 2020

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
Copy link
Member

REAS commented Jun 2, 2020

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

@REAS REAS closed this as completed Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants