Typography¶
Loading and displaying¶
create_font()¶
-
p5.
create_font
(name, size=10)¶ Create the given font at the appropriate size.
Parameters: - name (str) – Filename of the font file (only pil, otf and ttf fonts are supported.)
- size (int | None) – Font size (only required when name refers to a truetype font; defaults to None)
text()¶
-
p5.
text
(text_string, x, y)
-
p5.
text
(text_string, x, y, z)
-
p5.
text
(text_string, position, wrap_at=None)¶ Draw the given text on the screen and save the image.
Parameters: - text_string (str) – text to display
- x (float) – x-coordinate of text
- y (float) – y-coordinate of text
- z (float) – z-coordinate of text
- position (tuple) – position of the text on the screen
- wrap_at (int) – specifies the text wrapping column (defaults to None)
Returns: actual text that was drawn to the image (when wrapping is not set, this is just the unmodified text_string)
Return type: str
Text Attributes¶
text_align()¶
-
p5.
text_align
(align_x, align_y=None)¶ Set the alignment of drawing text
Parameters: - align_x (string) – “RIGHT”, “CENTER” or “LEFT”.
- align_y (string) – “TOP”, “CENTER” or “BOTTOM”.
Metrics¶
text_ascent()¶
-
p5.
text_ascent
()¶ Returns ascent of the current font at its current size
Returns: ascent of the current font at its current size Return type: float