centering text with html canvas code example
Example 1: canvas text align
ctx.textAlign = "left";
Example 2: how to place text at custom position on canvas in javascript
<!doctype html>
<html>
<head>
<body>
<canvas></canvas>
<script>
var canvas=document.querySelector('canvas');
var context=canvas.getContext(2d);
context.textAlign = 'center';
context.fillStyle = 'blue';
context.fillText('Helllo Word!', 10, 50);
</script>
</body>
</head>
</html>