Skip to content

Instantly share code, notes, and snippets.

@brett-miller
Created January 11, 2016 23:11
Show Gist options
  • Save brett-miller/f5dc8cf16750f4fe541c to your computer and use it in GitHub Desktop.
Save brett-miller/f5dc8cf16750f4fe541c to your computer and use it in GitHub Desktop.
Create an base64 image from a font awesome icon
function getFontAwesomeIcon(unicodeString,color){
var canvas=document.createElement("canvas");
canvas.height=16;
canvas.width=16;
var context= canvas.getContext("2d");
context.font="15px FontAwesome";
context.fillStyle = color;
context.fillText(String.fromCharCode(parseInt(unicodeString, 16)), 0, 16);
return canvas.toDataURL("image/png", 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment