Skip to content

Commit 7194223

Browse files
authored
Merge pull request #4508 from Tyriar/4507_zalgo
Disallow glyphs to exceed atlas texture size
2 parents 075f330 + 8c9e44c commit 7194223

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/browser/renderer/shared/TextureAtlas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ export class TextureAtlas implements ITextureAtlas {
429429
// Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used
430430
// to draw the glyph to the canvas as well as to restrict the bounding box search to ensure
431431
// giant ligatures (eg. =====>) don't impact overall performance.
432-
const allowedWidth = this._config.deviceCellWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2;
432+
const allowedWidth = Math.min(this._config.deviceCellWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2, this._textureSize);
433433
if (this._tmpCanvas.width < allowedWidth) {
434434
this._tmpCanvas.width = allowedWidth;
435435
}
436436
// Include line height when drawing glyphs
437-
const allowedHeight = this._config.deviceCellHeight + TMP_CANVAS_GLYPH_PADDING * 4;
437+
const allowedHeight = Math.min(this._config.deviceCellHeight + TMP_CANVAS_GLYPH_PADDING * 4, this._textureSize);
438438
if (this._tmpCanvas.height < allowedHeight) {
439439
this._tmpCanvas.height = allowedHeight;
440440
}

0 commit comments

Comments
 (0)