From the course: Processing: Interactive Data Visualization

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Specifying fonts

Specifying fonts - Processing Tutorial

From the course: Processing: Interactive Data Visualization

Start my 1-month free trial

Specifying fonts

Up to this point I've shown you how to include shapes and colors into your sketches in Processing. On the other hand, there may be times that you'll actually want to include text. To this point we most have been showing text in the console beneath, but I want to show you how to actually include it in the sketch window itself. I'll start by just putting a little comment here at the top. And what I'm going to do is create a window, 600 x 200; I'm going to give it a black background; then I'm going to type in a string for the text that I want to include. I put string with a capital S, because it is actually an object. Then I give the String variable a name. I'm going to call it wordText. It could be anything you want. And equals and then I put it in double quotes. Strings go in double quotes, char variables go in single quotes. I'll put here "A word is worth 1/1000th of a picture." So that's my text, and I finish with a semicolon. And then all I need to do is position the text, and I use…

Contents