Sets the current font that will be drawn with the text() function.
1 2 3 4 5 6 7
def setup(): # the font "andalemo.ttf" must be located in the # current sketch's "data" directory to load successfully mono = py5.create_font("andalemo.ttf", 32) py5.background(0) py5.text_font(mono) py5.text("word", 12, 60)
Sets the current font that will be drawn with the text() function. Fonts must be created for py5 with create_font() or loaded with load_font() before they can be used. The font set through
text_font() will be used in all subsequent calls to the text() function. If no
size parameter is specified, the font size defaults to the original size (the size in which it was created with create_font_file()) overriding any previous calls to
text_font() or text_size().
When fonts are rendered as an image texture (as is the case with the
P3D renderers as well as with load_font() and vlw files), you should create fonts at the sizes that will be used most commonly. Using
text_font() without the size parameter will result in the cleanest type.
Underlying Java method: textFont
text_font(which: Py5Font, /) -> None text_font(which: Py5Font, size: float, /) -> None
size: float - the size of the letters in units of pixels
which: Py5Font - any variable of the type Py5Font
Updated on September 11, 2021 16:51:34pm UTC