簡體   English   中英

如何使用節點畫布在圖像上覆蓋 unicode 字符?

[英]How to overlay unicode characters on image with node-canvas?

我試圖在圖像上覆蓋 unicode 字符,但字符沒有顯示。

   var img = new Image()
   img.src = fs.readFileSync(path.join(__dirname, 'images', 'snow.jpg'))
   ctx.drawImage(img, 0, 0, 500, 500)

   img = new Image()
   //img.src = canvas.toBuffer()
   ctx.font = "40pt Calibri";
   ctx.lineWidth = 1
   ctx.strokeStyle = '#ddd'

   ctx.fillStyle = '#000'
   ctx.fillText('Wahoo', 49, 99)
   ctx.rotate(0.5)
   ctx.translate(20, -40)
   ctx.fillText("Testing", 100, 180)
   ctx.rotate(0)
   ctx.translate(20, -60)
   // Unicode here
   ctx.fillText('\u5929\u6c23', 160, 100)

   canvas.createPNGStream().pipe(res);`

也許更換
ctx.strokeText = "#ddd"

ctx.fillText = "#ddd"

它可能會更好地工作並正確顯示......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM