
Metryka tekstu
Na razie możemy mierzyć tylko szerokość tekstu.
var cv = document.getElementById("canvas");
var ctx = cv.getContext("2d");
var tekst = 'Smok';
ctx.font = '50px arial';
ctx.fillStyle = 'blue';
ctx.fillText(tekst, 10, 50);
var metryka = ctx.measureText(tekst);
var width = metryka.width;
ctx.font = '20px arial';
ctx.fillStyle = "black";
ctx.fillText("szerokość napisu "+ width + " px", 10, 90);
