canvas.2d.lang.dynamic.html (1499B)
1 <!doctype HTML> 2 <html class="reftest-wait"> 3 <meta charset="utf-8"> 4 <title>HTML5 Canvas Test: The lang attribute dynamically updates</title> 5 <link rel="match" href="canvas.2d.lang.dynamic-ref.html"/> 6 <link rel="author" href="mailto:schenney@chromium.org"/> 7 <link rel="help" 8 href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/> 9 <meta name="assert" content="Verify that a text lang change is applied."/> 10 <script src="/common/reftest-wait.js"></script> 11 <style> 12 canvas { 13 position: absolute; 14 left: 0px; 15 top: 0px; 16 } 17 </style> 18 <script type="text/javascript"> 19 function runTest() { 20 let test_font = new FontFace( 21 // Lato-Medium is a font with language specific ligatures. 22 "Lato-Medium", 23 "url(/fonts/Lato-Medium.ttf)" 24 ); 25 26 test_font.load().then((font) => { 27 document.fonts.add(font); 28 var canvas = document.getElementById('canvas1'); 29 var ctx = canvas.getContext('2d'); 30 31 ctx.font = '25px Lato-Medium'; 32 ctx.fillText('fi', 60, 30); 33 34 canvas.setAttribute('lang', 'tr'); 35 ctx.fillText('fi', 60, 80); 36 37 ctx.lang = 'en'; 38 ctx.fillText('fi', 60, 130); 39 40 ctx.lang = 'inherit'; 41 ctx.fillText('fi', 60, 180); 42 takeScreenshot(); 43 }); 44 } 45 </script> 46 <body onload="runTest()"> 47 <canvas lang="en" id="canvas1" width="300" height="200"> 48 Browser does not support HTML5 Canvas. 49 </canvas> 50 </body> 51 </html>