I'm trying to import a font to use in the html5 canvas. I have the file on my computer, but everything I've tried so far hasn't worked. The canvas just displays a default font. I must be doing something wrong or missing a step.
I have loaded them in with CSS like this:
@font-face {
font-family: 'RifficFree-Bold';
src: local('RifficFree-Bold'), url(./fonts/RifficFree-Bold.ttf), format('truetype');
}
and then calling them in JS like so:
function drawText(myText, ctx) {
ctx.font = "40px RifficFree-Bold";
ctx.fillStyle = "rgb(0, 0, 0, " + myText.fill + ")";
ctx.fillText(myText.text, myText.x, myText.y);
}
I know that the program is getting this far, as whenever I change 40px to another value, the size of the font changes as it should. I think I must be loading the actual font file incorrectly. Any ideas?