書式
コンテキスト.textBaseline = ベースラインを示す文字
説明
文字のベースラインを設定します。"top", "hanging", "middle", "alphabetic", "ideographic", "bottom"のいずれかを指定できます。初期値は"alphabetic"になっています。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sample</title>
<script>
window.onload = function(){
var canvasObj = document.getElementById("imgCanvas");
var context = canvasObj.getContext("2d");
context.fillStyle = "rgba(255,0,0,1)";
context.font = "14pt 'Tahoma'";
context.textBaseline = "top";
context.fillText("Good job!", 20,50);
context.fillStyle = "blue";
context.textBaseline = "bottom";
context.fillText("Good job!", 20,50);
}
</script>
</head>
<body>
<h1>Sample</h1>
<canvas id="imgCanvas" width="320" height="240" style="border:1px black solid"></canvas>
</body>
</html>