I'm working on a Firebase function for drawing text on image. First i download locally the image from Cloud Storage and then i use graphics magick to draw text on it and finally upload this new image to Cloud Storage.
Here the Promise to draw text on image:
return new Promise((resolve, reject) => {
gm(tempFilePath)
.font(Roboto)
.drawText(10, 10, "My text here")
.write(newTempFilePath, (err, stdout) => {
if (err) {
console.error('Failed to blur image.', err);
reject(err);
} else {
console.log(stdout);
resolve(stdout);
}
});
});
The problem: How to use custom font here ?
.font(Roboto)
Is it possible to handle an asset file as a font file (Roboto-BoldItalic.ttf) in Firebase function ? Thx
Can you try the following:
fonts
folder and paste the Roboto-BoldItalic.ttf
file there. gm(tempFilePath)
.font("./fonts/Roboto-BoldItalic.ttf")
....