Reference for Processing version 1.2. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

loadFont()

Examples
example pic
PFont font;
// The font must be located in the sketch's 
// "data" directory to load successfully
font = loadFont("FFScala-32.vlw"); 
textFont(font, 32); 
text("word", 15, 50);
Description Loads a font into a variable of type PFont. To load correctly, fonts must be located in the data directory of the current sketch. To create a font to use with Processing, select "Create Font..." from the Tools menu. This will create a font in the format Processing requires and also adds it to the current sketch's data directory.

Like loadImage() and other methods that load data, the loadFont() command should not be used inside draw(), because it will slow down the sketch considerably, as the font will be re-loaded from the disk (or network) on each frame.

For most renderers, Processing displays fonts using the .vlw font format, which uses images for each letter, rather than defining them through vector data. When hint(ENABLE_NATIVE_FONTS) is used with the JAVA2D renderer, the native version of a font will be used if it is installed on the user's machine.

Using createFont() (instead of loadFont) enables vector data to be used with the JAVA2D (default) renderer setting. This can be helpful when many font sizes are needed, or when using any renderer based on JAVA2D, such as the PDF library.
Syntax
loadFont(fontname)
Parameters
fontname string: name of the font to load
Returns PFont
Usage Web & Application
Related PFont
textFont()
text()
createFont()
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License