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