text-context-state-test.html (794B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>text to ensure text attributes are saved in the context state</title> 5 </head> 6 <body> 7 <canvas id="c" width="128" height="64" style="direction:ltr"></canvas> 8 <script type="text/javascript"> 9 var canvas = document.getElementById('c'); 10 var ctx = canvas.getContext('2d'); 11 12 ctx.textAlign = 'left'; 13 ctx.textBaseline = 'top'; 14 ctx.font = '16px sans-serif'; 15 16 ctx.save(); 17 18 ctx.textAlign = 'right'; 19 ctx.textBaseline = 'alphabetic'; 20 ctx.font = '24px serif'; 21 22 ctx.save(); 23 24 ctx.textAlign = 'center'; 25 ctx.textBaseline = 'bottom'; 26 ctx.font = '10px sans-serif'; 27 28 ctx.fillText('something', 80, 60); 29 30 ctx.restore(); 31 32 ctx.fillText('other thing', 128, 40); 33 34 ctx.restore(); 35 36 ctx.fillText('yet another thing', 0, 0); 37 38 </script> 39 </body> 40 </html>