Created
January 11, 2016 23:11
-
-
Save brett-miller/f5dc8cf16750f4fe541c to your computer and use it in GitHub Desktop.
Create an base64 image from a font awesome icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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