Open alterebro opened 3 months ago
I fixed this issue in q5.js v2, check it out! https://q5js.org
$.loadFont = (url, cb) => {
p._preloadCount++;
let sp = url.split('/');
let name = sp.at(-1).split('.')[0].replace(' ', '');
let f = new FontFace(name, 'url(' + url + ')');
document.fonts.add(f);
f.load().then(() => {
p._preloadCount--;
if (cb) cb(name);
});
return name;
};
loadFont()
and itscallback
argument don't seem to work. Loaded font is only available once the browser has cached the file, which normally happens when you open the sketch for the second time. This behaviour is even present whenloadFont()
is called within thepreload()
function. Also thecallback
argument is not implemented.