Name

textFont()

Examples
# The font "LetterGothicStd-32.vlw" must be located in the 
# current sketch's "data" directory to load successfully
f = loadFont("LetterGothicStd-32.vlw")
background(0)
textFont(f)
text("word", 12, 60)
Description Sets the current font that will be drawn with the text() function. Fonts must be created for Processing with createFont() or loaded with loadFont() before they can be used. The font set through textFont() 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 in which it was created with the "Create Font..." tool) until it is changed with textSize().

Because fonts are usually bitmapped, you should create fonts at the sizes that will be used most commonly. Using textFont() without the size parameter will result in the cleanest type.

With the default 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 both on-screen sketches and PDF output when the vector data is available, such as when the font is still installed, or the font is created dynamically via the createFont() function (rather than with the "Create Font..." tool).
Related createFont()
loadFont()
PFont
text()

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.