Javascript examples for Canvas:Text
Drawing text with an outer stroke with HTML5's canvas
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w . j a v a2 s.c o m var can = document.getElementById('canvas1'); var ctx = can.getContext('2d'); ctx.fillStyle = 'gray'; ctx.fillRect(0,0,500,500); function drawStroked(text, x, y) { ctx.font = "80px Sans-serif" ctx.strokeStyle = 'black'; ctx.lineWidth = 8; ctx.lineJoin="miter"; ctx.miterLimit=2; ctx.strokeText(text, x, y); ctx.fillStyle = 'white'; ctx.fillText(text, x, y); } drawStroked("MVW", 50, 150); }); </script> </head> <body> <canvas id="canvas1" width="500" height="500"></canvas> </body> </html>