size(100, 100)
# Uncomment the following two lines to see the available fonts 
#fontList = PFont.list()
myFont = createFont("Georgia", 16)
text("!@#$%", width/2, height/2)
Description Dynamically converts a font to the format used by Processing from a .ttf or .otf file inside the sketch's "data" folder or a font that's installed elsewhere on the computer. If you want to use a font installed on your computer, use the PFont.list() method to first determine the names for the fonts recognized by the computer and are compatible with this function. 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. The charset parameter is an array of chars that specifies the characters to generate.

This function allows Processing to work with the font natively in the default renderer, so the letters are defined by vector geometry and are rendered quickly. In the P2D and P3D renderers, the function sets the project to render the font as a series of small textures. For instance, when using the default renderer, the actual native version of the font will be employed by the sketch, improving drawing quality and performance. With the P2D and P3D renderers, the bitmapped version will be used to improve speed and appearance, but the results are poor when exporting if the sketch does not include the .otf or .ttf file, and the requested font is not available on the machine running the sketch.
createFont(name, size)
createFont(name, size, smooth)
createFont(name, size, smooth, charset)
nameString: name of the font to load
sizefloat: point size of the font
smoothboolean: true for an antialiased font, false for aliased
charsetchar: list containing characters to be generated
Related PFont

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

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