当前位置: 代码迷 >> Web前端 >> canvas运用外部字体
  详细解决方案

canvas运用外部字体

热度:596   发布时间:2012-08-19 21:09:48.0
canvas使用外部字体

canvas使用外部字库

?

?

<style type="text/css">
		@font-face {
			font-family: "Inconsolata";
			src: local("Inconsolata") url("Inconsolata.ttf");
		}
</style>

?

canvas draw text

$(function(){
var canvas =document.getElementById('canvas');
var context = canvas.getContext('2d');
var text = "context.filltext(Text,0,0)";
var textWidth = context.measureText(text).width;
context.fillStyle = 'green';
context.font = '40px Inconsolata'
context.strokeStyle = 'black';
context.fillText(text,50,100);
context.stroke();
})

?

参考:http://www.devlounge.net/design/five-tips-for-using-font-face

?