Working with fonts
In Chapter 2, Drawing Text, Curves, and Shapes in 2D, you've learned how to use fonts in your sketches. In JAVASCRIPT
mode, you can't use the .vlw
fonts you've made with the Create Font tool. To make fonts work on the web, we'll need a different technique. You'll learn everything you need to know in this recipe.
Getting ready
I've used the Chunk typeface for this example. Chunk is an open source font made by The League of Moveable Type. You can get it from their website, at http://www.theleagueofmoveabletype.com/chunk. Download the font, and add the Chunk.ttf
file to your sketch folder, by dragging it onto the Processing editor.
How to do it...
Once you've added the font to your sketch folder, you can type this code into your editor. The text will scroll from bottom to top, just like in the movies, while a yellow rectangle is animated in the background.
PFont font; float x; float y; void setup() { size( 640, 480 ); font = createFont( "Chunk.ttf", 60 ); ...