Automattic / Automattic/node-canvas
Font descriptor is case sensitive, mismatch with browser behavior
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
Specifying `"bold 30px monospace"` instead of `"Bold 30px Monospace"` in node-canvas gives different results. In browser they are the same.
node-canvas test:
```js
const fs = require('fs')
const { createCanvas, loadImage } = require('canvas')
const canvas = createCanvas(200, 200)
const ctx = canvas.getContext('2d')
ctx.fillStyle="white"
ctx.fillRect(0,0,200,200);
ctx.fillStyle="black"
ctx.font = "30px Arial";
ctx.fillText("node-canvas", 10, 40);
ctx.font = "Bold 30px Monospace";
ctx.fillText("Monospace", 10, 120);
ctx.font = "bold 30px monospace";
ctx.fillText("monospace", 10, 160);
fs.writeFileSync('test.jpg', canvas.toBuffer('image/jpeg'))
```
browser test:
```html
function draw() {
let ctx = document.getElementById("c").getContext("2d");
ctx.fillStyle="white"
ctx.fillRect(0,0,200,200);
ctx.fillStyle="black"
ctx.font = "30px Arial";
ctx.fillText("browser", 10, 40);
ctx.font = "Bold 30px Monospace";
ctx.fillText("Monospace", 10, 120);
ctx.font = "bold 30px monospace";
ctx.fillText("monospace", 10, 160);
}
```
Image generated by Browser:

Image generated by node-canvas:

node-canvas versions:
```
version: '2.3.1',
cairoVersion: '1.16.0',
jpegVersion: '6b',
gifVersion: '5.1.4',
freetypeVersion: '2.9.1'
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.