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
?