I am drawing a canvas that needs to be on full available screen (100% width and height). I set the width and height of canvas using javascript like this
va
Try this.
FIDDLE DEMO
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var x = canvas.width / 2;
var y = canvas.height / 2 - 10;
var text = 'I M @ CENTER!';
context.font = '10pt Calibri'; //try changing values 10,15,20
context.textAlign = 'center';
context.fillStyle = 'red';
context.fillText(text, x, y);
You can provide your conditions depending on the window size.Create a simple function like following:
function Manipulate_FONT(window.widht, window.height) {
if (window.widht == something && window.height == something) {
font_size = xyz //put this in ---> context.font = '10pt Calibri'
}
}