OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <head> |
| 3 <style> |
| 4 @font-face { |
| 5 font-family: Ahem; |
| 6 src: url('../../resources/Ahem.ttf'); |
| 7 } |
| 8 </style> |
| 9 </head> |
| 10 <body> |
| 11 <p>On success, the red text "Hello World" should be tightly contained inside the
two thin red lines.</p> |
| 12 <canvas id="canvas" width="300" height="50"></canvas> |
| 13 <script> |
| 14 if (window.testRunner) |
| 15 testRunner.dumpAsTextWithPixelResults(); |
| 16 |
| 17 var canvas = document.getElementById('canvas'); |
| 18 var ctx = canvas.getContext('2d'); |
| 19 var text = "Hello World"; |
| 20 ctx.font = "50px Ahem"; |
| 21 ctx.fillStyle = '#FF0000'; |
| 22 ctx.textBaseline = "top"; |
| 23 ctx.fillText(text, 1, 0); |
| 24 var textMetrics = ctx.measureText(text); |
| 25 ctx.fillRect(0, 0, 1, 50); |
| 26 ctx.fillRect(Math.ceil(textMetrics.width), 0, 1, 50); |
| 27 </script> |
| 28 </body> |
OLD | NEW |