xxxxxxxxxx
37
// https://discourse.processing.org/t/how-to-use-asset-fonts-in-p5/17037/7
let inconsolata;
function preload() {
// inconsolata = loadFont(‘assets/inconsolata.otf’);
inconsolata = loadFont("assets/Inconsolata-Black.otf");
// 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]
// i see that error as you post, as long that file is missing.
// now i try to find that file on the internet
// https://github.com/googlefonts/Inconsolata/blob/master/fonts/otf/Inconsolata-Black.otf
// download PC
// upload to here /assets/Inconsolata-Black.otf
// change the name to "Inconsolata-Black.otf" and run
// for testing without file as GOOGLE FONT
// see https://editor.p5js.org/kll/sketches/yqvznlsOn
}
function setup() {
createCanvas(300, 300, WEBGL);
textFont(inconsolata);
textSize(width / 3);
textAlign(CENTER, CENTER);
}
function draw() {
background(200,200,0);
let time = millis();
rotateX(time / 1000);
rotateZ(time / 1234);
text("p5.js", 0, 0);
}