How do I use custom fonts in processing.js inside a web2py server? More specifically, what's the path and why do I have to use directives?
1 Answers
Been looking for this answer for months so thought I'd put it out there just in case it gets a few google hits. It turns out that to enable fonts in processing.js instances in HTML 5 canvases in your web2py servers you have to, as is well known, declare the directive:
/* @pjs font="/nameOfYourApplication/nameOfYourFont.ttf"; */
This, as explained in the reference page of processing.org, is done to preload the font so that your browser doesn't spaz on load. And then next and final step is to go into your setup function and do this:
textFont(createFont("/nameOfYourApplication/nameOfYourFont",32));
That's it. Sounds dumb and for those who know how to do this it may be common sense but given that most help out there talks about the "data" folder, it tends to be frustrating and pointless.
I suggest putting your fonts in the static folder of your application but beyond that it's all up to you.

- 7,089
- 5
- 33
- 59