Search processing.org:

Reference for Processing version 1.0+. 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

### textFont()

Examples

    PFont metaBold;
    // The font "Meta-Bold.vlw" must be located in the
    // current sketch's "data" directory to load successfully
    metaBold = loadFont("Meta-Bold.vlw");
    textFont(metaBold, 44);
    text("word", 15, 50);

Description

Sets the current font. The font must be loaded with loadFont() before it can be used. This font will be used in all subsequent calls to the text() function. If no size parameter is input, the font will appear at its original size (the size it was created at with the "Create Font..." tool) until it is changed with textSize().
Because fonts are usually bitmaped, you should create fonts at the sizes that will be used most commonly. Using textFont() without the size parameter will result in the cleanest-looking text.
With the JAVA2D and PDF renderers, it's also possible to enable the use of native fonts via the command hint(ENABLE_NATIVE_FONTS). This will produce vector text in JAVA2D sketches and PDF output in cases where the vector data is available: when the font is still installed, or the font is created via the createFont() function (rather than the Tool).

Syntax

    textFont(font)
    textFont(font, size)

Parameters

font | PFont: any variable of the type PFont
size | int or float: the size of the letters in units of pixels

Returns | None
Usage | Web & Application
Related | createFont() loadFont() PFont text()

Updated on November 22, 2008 08:39:26pm PST