OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 <body onload="runTest();"> |
| 4 <div> |
| 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> |
| 7 </div> |
| 8 <script type="text/javascript"> |
| 9 if (window.testRunner) |
| 10 testRunner.dumpAsText(); |
| 11 |
| 12 function drawCanvasText(id, text) |
| 13 { |
| 14 var canvasElement = document.getElementById(id); |
| 15 var context = canvasElement.getContext('2d'); |
| 16 canvasElement.style.fontSize = '64px'; |
| 17 context.font = '1em Calibri'; |
| 18 context.fillText(text, 0, 100); |
| 19 return context.font; |
| 20 } |
| 21 |
| 22 function runTest() |
| 23 { |
| 24 var fontSize = drawCanvasText('canvasTest', 'Some Text'); |
| 25 var resultElement = document.getElementById('result'); |
| 26 resultElement.textContent = fontSize; |
| 27 } |
| 28 </script> |
| 29 </body> |
| 30 </html> |
OLD | NEW |