Article introduction of Wulin.com (www.vevb.com): HTML5 Canvas text settings font and size.
HTML5 Canvas text settings fonts and sizes, we can use the properties of the fonts within the scope of the canvas.
Let’s give you a simple example to explain the basic syntax:
HTML5 Canvas Text Font & Size Example
<!DOCTYPE HTML>
<html>
<head>
<title>html5_canvas_text_size</title>
<style>
body {margin: 0px;padding: 0px;}
#myCanvas {border: 1px solid #9C9898; margin:0 auto;margin-top:200px; margin-left:100px;}
</style>
<script>
window.onload = function(){
var canvas = document.getElementById(myCanvas);
var context = canvas.getContext(2d);
var x = 150;
var y = 100;
context.font = 40pt Calibri;
context.fillText(Hello VeVb!, x, y);
};
</script>
</head>
<body>
<canvas id=myCanvas width=578 height=200>
</canvas>
</body>
</html>