<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
WebFontConfig = {
google: {
families: [ 'Ewert', 'Fredericka the Great', 'Ubuntu' ]
},
active: function() {
paint();
},
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
<script type="text/javascript">
function paint() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = "rgba(255, 255, 255, 255)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
var fontName= document.defaultView.getComputedStyle(canvas, null).fontFamily;
ctx.fillStyle= "rgba(0,0,0,255)";
ctx.font = "32px 'Helvetica'";
ctx.fillText("Helvetica", 10, 50);
ctx.fillText("AGCDEFGHIJKLMN 12345+-", 350, 50);
ctx.font = "32px '"+fontName+"'";
ctx.fillText("Ewert", 10, 100);
ctx.fillText("AGCDEFGHIJKLMN 12345+-", 350, 100);
ctx.font = "32px 'Fredericka the Great'";
ctx.fillText("Fredericka the Great", 10, 150);
ctx.fillText("AGCDEFGHIJKLMN 12345+-", 350, 150);
ctx.font = "32px 'Ubuntu'";
ctx.fillText("Ubuntu", 10, 200);
ctx.fillText("AGCDEFGHIJKLMN 12345+-", 350, 200);
ctx.font = "32px 'Times'";
ctx.fillText("Times", 10, 250);
ctx.fillText("AGCDEFGHIJKLMN 12345+-", 350, 250);
}
</script>
</head>
<body>
<canvas id='canvas' style="border:solid 1px;font-family:Ewert;" width="850" height="300"></canvas>
</body>
</html>
0 件のコメント:
コメントを投稿