Search processing.org:

Reference for Processing (BETA) version 0135+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name | ### createFont()
Examples |
    PFont myFont;

    void setup() {
      size(200, 200);
      // Uncomment the following two lines to see the available fonts
      //String[] fontList = PFont.list();
      //println(fontList);
      myFont = createFont("FFScala", 32);
      textFont(myFont);
      text("!@#$%", 10, 50);
    }
Description | Dynamically converts a font to the format used by Processing from either a font name that's installed on the computer, or from a .ttf or .otf file inside the sketches "data" folder. This function is an advanced feature for precise control. On most occasions you should create fonts through selecting "Create Font..." from the Tools menu. Use the PFont.list() method to first determine the names for the fonts recognized by the computer and are compatible with this function. Because of limitations in Java, not all fonts can be used and some might work with one operating system and not others. When sharing a sketch with other people or posting it on the web, you may need to include a .ttf or .otf version of your font in the data directory of the sketch because other people might not have the font installed on their computer. Only fonts that can legally be distributed should be included with a sketch. The size parameter states the font size you want to generate. The smooth parameter specifies if the font should be antialiased or not, and the charset parameter is an array of chars that specifies the characters to generate. There is a bug in Apple's Java 1.5 implementation on Mac OS X that prevents some fonts from being specified by their name, particularly those that have a style suffix (Bug 407).
Syntax |
    createFont(name, size)
    createFont(name, size, smooth)
    createFont(name, size, smooth, charset)
Parameters |
name | String: name of the font to load
size | float: point size of the font
charset | char[]: array containing characters to be generated
smooth | boolean: true for an antialiased font, false for aliased
Usage | Web & Application
Related | PFont textFont() text() loadFont()

Updated on October 22, 2007 10:10:06am PDT