Compatibility problems
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 673
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/mapbox/tiny-sdf/blob/5bd130204f341acfd974081a791be9397fb10c39/index.js#L58C27-L58C133
const {
width: glyphAdvance,
actualBoundingBoxAscent,
actualBoundingBoxDescent,
actualBoundingBoxLeft,
actualBoundingBoxRight
} = this.ctx.measureText(char);
const glyphWidth = Math.max(0, Math.min(this.size - this.buffer, Math.ceil(actualBoundingBoxRight - actualBoundingBoxLeft)));
const glyphHeight = Math.min(this.size - this.buffer, glyphTop + Math.ceil(actualBoundingBoxDescent));
const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight);
`actualBoundingBoxRight`, `actualBoundingBoxLeft`, `actualBoundingBoxDescent`
These values may be undefined in low-end machine environments, which will cause the glyphWidth and glyphHeight to be calculated as NaN, which will cause the `ctx.getImageData` method to throw a DOMException error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in index.js at the linked measureText call and inspect how actualBoundingBoxRight, actualBoundingBoxLeft, and actualBoundingBoxDescent feed glyphWidth and glyphHeight. Reproduce the issue in an environment where these values are undefined, then run the existing tests or browser checks. Done means getImageData no longer receives invalid dimensions while normal glyph generation still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100