You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I understand, thank you for the reply, but you still need to avoid the situation where the glyphWidth and glyphHeight are calculated as NaN, because this will cause ctx.getImageData to throw an error and hinder subsequent logic.
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.The text was updated successfully, but these errors were encountered: