Skip to content

Compatibility problems #54

@lidongsevenlee

Description

@lidongsevenlee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions