3 <body onload=
"runTest();">
5 <span>Tests that setting font of Canvas
2d context always uses up-to-date style and has font value:
<span id=
"result"></span></span><br>
6 <canvas id=
"canvasTest"></canvas>
8 <script type=
"text/javascript">
10 testRunner
.dumpAsText();
12 function drawCanvasText(id
, text
)
14 var canvasElement
= document
.getElementById(id
);
15 var context
= canvasElement
.getContext('2d');
17 // Pre-draw pass to add the font to the font cache. This way, the test also
18 // verifies that the style change correctly invalidates the font resolution cache.
19 context
.font
= '1em Calibri';
20 context
.fillText(text
, 0, 100);
22 canvasElement
.style
.fontSize
= '64px';
23 context
.font
= '1em Calibri';
24 context
.fillText(text
, 0, 100);
30 var fontSize
= drawCanvasText('canvasTest', 'Some Text');
31 var resultElement
= document
.getElementById('result');
32 resultElement
.textContent
= fontSize
;