Automattic / Automattic/node-canvas

fillText not rendering correctly on Azure Windows deployed api app

Open
#2,272 1 comment 0 reactions 0 assignees View on GitHub
Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

Experiencing an issue with fillText when deployed to Azure Windows api app container.

When testing locally I get this:
![image](https://github.com/Automattic/node-canvas/assets/100289710/f23b4f3d-6033-4b99-b013-0a506924ff26)

When deployed to Azure api app I get this
![image](https://github.com/Automattic/node-canvas/assets/100289710/a014f028-8564-4684-b7a6-8b85d215c593)

```
registerFont(join(__dirname, '../assets/fonts/Helvetica.ttf'), { family: 'Helvetica' })

const canvas = createCanvas(280, 80)
const context = canvas.getContext("2d")
context.clearRect(0, 0, canvas.width, canvas.height)

// draw button
context.beginPath()
context.roundRect(10, 10, 260, 60, [5])
context.fillStyle = "#dd2111"
context.fill();

const fontSize = process.env.CANVAS_FONT_SIZE || '20';
context.font = `${fontSize}px "Helvetica"`
context.textAlign = "center"
context.textBaseline = "middle";
context.fillStyle = "#fff"
context.fillText(askAmountText, canvas.width/2, canvas.height/2)

const imageBuffer = await canvas.toBuffer("image/png")
return imageBuffer
```

The characters appears to be stacked on top of each other. I tried setting with a lower font size and the attached image is the result. Hope there is a solution and I don't have to move to a VM or redeploy to a Linux container.

Azure Environment
node version v16.16.0
C:\home\site\wwwroot
`-- canvas@2.10.2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.