My HTML document is:
<!DOCTYPE html>
<HTML>
<HEAD>
<meta charset="utf-8">
<style>
@font-face {
font-family: "canvas";
font-style: normal;
font-weight: normal;
src: local('JesterRegular.woff'), url('JesterRegular.woff') format('woff');
}
</style>
<title>Interactive</title>
</HEAD>
<BODY>
<div style="font-family: canvas">test</div>
<canvas id="simulator">
<h1>Your browser doesn't support this element.</h1>
</canvas>
<script type="text/javascript" src="elements.js"></script>
<script type="text/javascript" src="backgroundgen.js"></script>
<script type="text/javascript" src="tileengine.js"></script>
<script type="text/javascript" src="simulator.js"></script>
</BODY>
</HTML>
The applicable portion of my javascript from backgroundgen.js
is:
drawTitle: function() {
BackgroundGen.context.fillStyle = BackgroundGen.titleBGColor;
BackgroundGen.context.fillRect(0,0,BackgroundGen.canvas.width,30);
textXpos = BackgroundGen.canvas.width/2;
BackgroundGen.context.textAlign = "center";
BackgroundGen.context.font = '20px "canvas"';
BackgroundGen.context.fillStyle = "rgb(0,0,0)";
BackgroundGen.context.fillText(BackgroundGen.titleText, textXpos, 15);
}
When using the custom "canvas" font, no text is displayed at all. If I replace canvas with a typical font, say arial for example, it displays fine. I've adapted the technique of loading the font before displaying it in my canvas with the <div>
tag in the HTML, still no joy. The contents of the <div>
tag display fine, proper canvas font, just nothing in the canvas. For the record, I am running Chromium v12 and Firefox v6 on Ubuntu.
To clarify, Chromium's javascript console doesn't report any errors, and Firefox's error console doesn't report anything either.