From 1ede106ab45888b94f478a862fe1e3c7d9626c6a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 Jul 2022 12:05:20 -0700 Subject: [PATCH] Fix powerlines not clipped when bg changes --- addons/xterm-addon-webgl/src/GlyphRenderer.ts | 7 ++++--- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/addons/xterm-addon-webgl/src/GlyphRenderer.ts b/addons/xterm-addon-webgl/src/GlyphRenderer.ts index 6eff4ced..6817cb21 100644 --- a/addons/xterm-addon-webgl/src/GlyphRenderer.ts +++ b/addons/xterm-addon-webgl/src/GlyphRenderer.ts @@ -203,10 +203,11 @@ export class GlyphRenderer extends Disposable { return; } - if (bg !== lastBg && rasterizedGlyph.offset.x > 0) { - const clippedPixels = rasterizedGlyph.offset.x; + const leftCellPadding = Math.floor((this._dimensions.scaledCellWidth - this._dimensions.scaledCharWidth) / 2); + if (bg !== lastBg && rasterizedGlyph.offset.x > leftCellPadding) { + const clippedPixels = rasterizedGlyph.offset.x - leftCellPadding; // a_origin - array[i ] = this._dimensions.scaledCharLeft; + array[i ] = -(rasterizedGlyph.offset.x - clippedPixels) + this._dimensions.scaledCharLeft; array[i + 1] = -rasterizedGlyph.offset.y + this._dimensions.scaledCharTop; // a_size array[i + 2] = (rasterizedGlyph.size.x - clippedPixels) / this._dimensions.scaledCanvasWidth; diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 8e05e0cd..b10fd6ec 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -604,9 +604,6 @@ export class WebglCharAtlas implements IDisposable { } const rasterizedGlyph = this._findGlyphBoundingBox(imageData, this._workBoundingBox, allowedWidth, powerlineGlyph, customGlyph, padding); - if (powerlineGlyph) { - console.log(`powerline glyph ${chars}`, rasterizedGlyph, this._workBoundingBox); - } const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); // Find the best atlas row to use @@ -758,7 +755,7 @@ export class WebglCharAtlas implements IDisposable { y: (boundingBox.bottom - boundingBox.top + 1) / TEXTURE_HEIGHT }, offset: { - x: -boundingBox.left + padding + ((restrictedGlyph || customGlyph) ? Math.round((this._config.scaledCellWidth - this._config.scaledCharWidth) / 2) : 0), + x: -boundingBox.left + padding + ((restrictedGlyph || customGlyph) ? Math.floor((this._config.scaledCellWidth - this._config.scaledCharWidth) / 2) : 0), y: -boundingBox.top + padding + ((restrictedGlyph || customGlyph) ? this._config.lineHeight === 1 ? 0 : Math.round((this._config.scaledCellHeight - this._config.scaledCharHeight) / 2) : 0) } };