Fix powerlines not clipped when bg changes

This commit is contained in:
Daniel Imms
2022-07-31 12:05:20 -07:00
parent e7e71dbd3c
commit 1ede106ab4
2 changed files with 5 additions and 7 deletions
@@ -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;
@@ -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)
}
};