How to use asset fonts in p5

hi,
yes, I just want to use the system fonts.

I tried an example and it gave an error message that it could’nt find the asset\FontName…

I forget the exact error…—

I found it—cut and paste this into a new editor

=================error

p5.js says: It looks like there was a problem loading your font. Try checking if the file path [assets/inconsolata.otf] is correct, hosting the font online, or running a local server.[https://github.com/processing/p5.js/wiki/Local-server]

============= example code=======

let inconsolata;
function preload() {
inconsolata = loadFont(‘assets/inconsolata.otf’);
}
function setup() {
createCanvas(100, 100, WEBGL);
textFont(inconsolata);
textSize(width / 3);
textAlign(CENTER, CENTER);
}
function draw() {
background(0);
let time = millis();
rotateX(time / 1000);
rotateZ(time / 1234);
text(‘p5.js’, 0, 0);
}

1 Like