2d.text.draw.fontface.notinpage.html (1563B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <title>Canvas test: 2d.text.draw.fontface.notinpage</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/html/canvas/resources/canvas-tests.js"></script> 8 <link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> 9 <style> 10 @font-face { 11 font-family: CanvasTest; 12 src: url("/fonts/CanvasTest.ttf"); 13 } 14 </style> 15 <body class="show_output"> 16 17 <h1>2d.text.draw.fontface.notinpage</h1> 18 <p class="desc">@font-face fonts should work even if they are not used in the page</p> 19 20 21 <p class="output">Actual output:</p> 22 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> 23 <p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> 24 <ul id="d"></ul> 25 <script> 26 promise_test(async t => { 27 28 var canvas = document.getElementById('c'); 29 var ctx = canvas.getContext('2d'); 30 31 await document.fonts.ready; 32 ctx.font = '67px CanvasTest'; 33 ctx.fillStyle = '#f00'; 34 ctx.fillRect(0, 0, 100, 50); 35 ctx.fillStyle = '#0f0'; 36 ctx.fillText('AA', 0, 50); 37 _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2); 38 _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2); 39 _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); 40 _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); 41 42 }, "@font-face fonts should work even if they are not used in the page"); 43 </script>