Debian Codegraph @

testing/web-platform/mozilla/tests/html/canvas/mozPrintCallback-text-002-print.html

raw
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1908969">
4 <link rel="match" href="mozPrintCallback-text-002-print-ref.html">
5 <link rel="stylesheet" href="/fonts/ahem.css">
6 <style>
7 canvas {
8 background: yellow;
9 transform: scale(4);
10 transform-origin: 0 0;
11 }
12 </style>
13 <canvas id="myCanvas" width="80" height="80"></canvas>
14 <script>
15 myCanvas.mozPrintCallback = function (obj) {
16 let ctx = obj.context;
17 ctx.font = "60px Ahem";
18 // Draw the glyph using 'actualBoundingBoxAscent' as the y-position so that
19 // its top-edge is flush with the top of the canvas. (This makes it easier
20 // to position the glyph consistently between this testcase and the
21 // reference case.)
22 let yPos = ctx.measureText("X").actualBoundingBoxAscent;
23 ctx.fillText("X", 0, yPos);
24 obj.done();
25 }
26 </script>