Automattic / Automattic/node-canvas
Segfault on Windows while drawing single-char strings
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
### Issue or Feature
Sometimes drawing strings of length 1 causes segfault on Windows.
### Steps to Reproduce
It's crashing on `measureText` call, but I can't investigate it at the moment.
```js
'use strict';
var s = 100;
var sh = s / 2;
var g = new (require('canvas').Canvas)(s, s).getContext('2d');
g.textBaseline = 'middle';
g.textAlign = 'center';
g.font = '32px sans-serif';
g.fillStyle = 'black';
var j = 0;
var w = 0;
for(var i = 0; i < 2 ** 16; i++){
var c = String.fromCharCode(i);
g.clearRect(0, 0, s, s);
g.fillText(c, sh, sh);
if(!g.getImageData(0, 0, s, s).data.some(a => a))
continue;
var w1 = g.measureText(c).width; // <------ Seems to crash here
if(w1 <= w)
continue;
w = w1;
j = i;
}
console.log(`\\u${j.toString(16).padStart(4, '0')}`);
```
### Your Environment
* Version of node-canvas: master
* Environment: node v10.1.0 windows 8.1
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.