Automattic / Automattic/node-canvas

Font descriptor is case sensitive, mismatch with browser behavior

Open
#1,368 0 comments 0 reactions 0 assignees View on GitHub
Bug Text & Fonts
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:

![browser](https://user-images.githubusercontent.com/15200/52717928-00125980-2f81-11e9-922b-c5bee06c8c44.png)

Image generated by node-canvas:

![node-canvas](https://user-images.githubusercontent.com/15200/52717934-03a5e080-2f81-11e9-916a-a11193200c8c.jpg)

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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.