pub static textFont: TextFontInternalTypeExpand description
Sets the current font that will be drawn with the text() function.
WEBGL: Only fonts loaded via loadFont() are supported.
Examples
fill(0);
textSize(12);
textFont('Georgia');
text('Georgia', 12, 30);
textFont('Helvetica');
text('Helvetica', 12, 60);let fontRegular, fontItalic, fontBold;
function preload() {
fontRegular = loadFont('assets/Regular.otf');
fontItalic = loadFont('assets/Italic.ttf');
fontBold = loadFont('assets/Bold.ttf');
}
function setup() {
background(210);
fill(0)
.strokeWeight(0)
.textSize(10);
textFont(fontRegular);
text('Font Style Normal', 10, 30);
textFont(fontItalic);
text('Font Style Italic', 10, 50);
textFont(fontBold);
text('Font Style Bold', 10, 70);
}Overloads
font a font loaded via loadFont(),
or a String representing a web safe font
(a font that is generally available across all systems)
size? the font size to use