HTML5 Game - Draw font outline

Description

Draw font outline

Demo

ResultView the demo in separate window

<!DOCTYPE html>

<html>
  <head>
    <title>Learning the basics of canvas</title>
    <meta charset="utf-8">
    //w  ww  .  j av a 2  s .c o  m
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    
    <script type="text/javascript">
      $(document).ready(function() {  
        let canvas = $("#myCanvas");
        let context = canvas.get(0).getContext("2d");
        
       let text = "Hello, World!";  
       context.font = "italic 60px serif";  
       context.strokeText(text, 40, 100);  
      });
    </script>
  </head>
  
  <body>
    <canvas id="myCanvas" width="500" height="500">
      <!-- Insert fallback content here -->
    </canvas>
  </body>
</html>

The strokeText method takes the same parameters as fillText.

It looks a bit weird at a small font size.

Related Topic