You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a while ago we had this issue that the text shifts when using maxWidth. See #577.
It got fixed in #603 and works well so far.
But when I'm trying to use right alignment of text, the issue appears again:
Code used for above image
const{ promises }=require('fs')const{ join }=require('path')const{ createCanvas }=require('@napi-rs/canvas')constcanvas=createCanvas(500,100)constctx=canvas.getContext('2d')constpadding=50constmaxWidth=canvas.width-padding*2// The backgroundctx.fillRect(0,0,canvas.width,canvas.height)ctx.fillStyle='blue'ctx.fillRect(padding,0,maxWidth,canvas.height)ctx.font='16px Arial'ctx.textAlign='right'ctx.fillStyle='white'ctx.textBaseline='top'/** Short text */ctx.fillText('Short text',canvas.width-padding,10,maxWidth)/** Very long text (10 repetitions) */ctx.fillText(`Very ${'long '.repeat(10)} text`,canvas.width-padding,30,maxWidth,)/** Very long text (20 repetitions) */ctx.fillText(`Very ${'long '.repeat(20)} text`,canvas.width-padding,50,maxWidth,)asyncfunctionmain(){constpngData=awaitcanvas.encode('png')awaitpromises.writeFile(join(__dirname,'simple.png'),pngData)}main()
The text was updated successfully, but these errors were encountered:
Hey hey,
a while ago we had this issue that the text shifts when using maxWidth. See #577.
It got fixed in #603 and works well so far.
But when I'm trying to use right alignment of text, the issue appears again:
Code used for above image
The text was updated successfully, but these errors were encountered: