I am unable to load fonts to use in canvas. I have font file OpenSans-Regular.ttf
in same folder as html.
<style>
@font-face {
font-family: 'OpenSans';
src: url(OpenSans-Regular.ttf) format("truetype");
}
</style>
<canvas id="c" width="1000" height="1400"></canvas>
<script>
var c = document.getElementById("c").getContext('2d');
c.font = '100px OpenSans';
c.fillText('Loading...', 110, 110);
</script>
This does load the font (in Debugger/Network), but isnt used on canvas. If I replace src: url(OpenSans-Regular.ttf)
with local('OpenSans-Regular.ttf')
it doesnt even load in Debugger/Network. I tried adding/removing the quotes in both ways, tried removing and adding the .ttf. But nothing worked.
NOTE: I some of these tries I was sure the font is properly loaded, and can use it in other element.
Thank you