I've been trying for the past hour to add font to my image unsuccessfully. Unfortunately while this may seem like a really easy thing to do I cant get it to work.
const Canvas = require('canvas');
var Font = Canvas.Font;
var BerlinSansFBRegular = Font ? new Font('BerlinSansFBRegular', path.join(__dirname,'./BerlinSansFBRegular.ttf')) : null;
//..
let canvas = new Canvas(GIF_WIDTH, height);
let context = canvas.getContext('2d');
context.addFont(BerlinSansFBRegular);
context.font = `13px BerlinSansFBRegular`;
Directory in windows C:\Users\...\project\fonts\BerlinSansFBRegular.ttf
, it probably has something to with the way I am giving my path cause it throws an unhandled promise rejection: Error: Not Found.
Inside the project folder is where my .js
file and bat is in.