Skip to content

Instantly share code, notes, and snippets.

@possan
Created September 27, 2012 15:54
Show Gist options
  • Save possan/3794772 to your computer and use it in GitHub Desktop.
Save possan/3794772 to your computer and use it in GitHub Desktop.
Using Cufon fonts inside a <canvas> in Spotify
<html>
<head>
<script src="cufon-yui.js" type="text/javascript"></script>
<script src="Raleway_Dots_400.font.js"></script>
</head>
<body>
<h1 id="h1">HELLO CUFON CANVAS!</h1>
<canvas id="a" width="200" height="200" style="background-color:#ccc;"></canvas>
<script type="text/javascript">
Cufon.set('engine', 'canvas');
Cufon.replace('h1');
var h1 = document.getElementById('h1');
console.log(h1);
var a = document.getElementById('a');
var b = a.getContext('2d');
b.lineColor = '#000';
b.beginPath();
b.moveTo(0,0);
b.lineTo(200,200);
b.stroke();
setTimeout(function() {
var ic = document.querySelector('canvas');
console.log(ic);
b.drawImage(ic, 0, 0);
},100);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment