Created
January 24, 2019 05:07
-
-
Save jhuckaby/a096d24343f48bef6b867e081c6b9868 to your computer and use it in GitHub Desktop.
Preload single regular Advent Pro style, then render it using node-canvas
This file contains 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
const { registerFont, createCanvas } = require('canvas'); | |
registerFont( 'AdventPro-Regular.ttf', { family: "AdventProRegular" } ); | |
var canvas = createCanvas( 600, 100 ); | |
var ctx = canvas.getContext( '2d' ); | |
ctx.fillStyle = '#ffffff'; | |
ctx.fillRect( 0, 0, canvas.width, canvas.height ); | |
ctx.font = "normal normal 30px AdventProRegular"; | |
ctx.fillStyle = '#000000'; | |
ctx.fillText( "Now is the time for all good men.", 10, 50 ); | |
require('fs').writeFileSync( "out.png", canvas.toBuffer('image/png') ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment