I'm working on a Firebase function for drawing text on image.
(我正在使用Firebase函数在图像上绘制文本。)
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.(首先,我从Cloud Storage本地下载图像,然后使用graphics magick在其上绘制文本,最后将此新图像上传到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 ?
(是否可以在Firebase函数中将资产文件作为字体文件(Roboto-BoldItalic.ttf)处理?)
Thx(谢谢)
ask by Julien Robidet translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…