所以我做的很明显......
var font;
function preload() {
font = loadFont('assets/text/riffic.ttf');
}
function setup() {
createCanvas(600, 600);
}
然后调用它我用...
function draw() {
textFont(font);
text("Hello", 100, 100);
}
当我尝试使用这种字体时,控制台告诉我这个......
Uncaught TypeError: Cannot read property 'length' of undefined
at Substitution.getDefaultScriptName (p5.js:31993)
at Font.stringToGlyphs (p5.js:27954)
at Font.forEachGlyph (p5.js:28069)
at Font.getAdvanceWidth (p5.js:28144)
at p5.Font._textWidth (p5.js:63498)
at p5.Font._handleAlignment (p5.js:63523)
at p5.Font._getPath (p5.js:63339)
at p5.Font._renderPath (p5.js:63458)
at p5.Renderer2D._renderText (p5.js:48828)
at p5.Renderer2D.text (p5.js:48788)
但无论我从哪里得到它的字体样式“Riffic free-bold对我来说都不适用于p5.js!这有什么理由吗?riffic free-bold与其他字体有什么不同?如果那么,怎么样?(我要求riffic free-bold,所以我不能只使用另一种字体。)