@@ -8,7 +8,7 @@ import { CellColorResolver } from 'browser/renderer/shared/CellColorResolver';
88import { acquireTextureAtlas } from 'browser/renderer/shared/CharAtlasCache' ;
99import { TEXT_BASELINE } from 'browser/renderer/shared/Constants' ;
1010import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs' ;
11- import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils' ;
11+ import { isEmoji , throwIfFalsy } from 'browser/renderer/shared/RendererUtils' ;
1212import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel' ;
1313import { IRasterizedGlyph , IRenderDimensions , ISelectionRenderModel , ITextureAtlas } from 'browser/renderer/shared/Types' ;
1414import { ICoreBrowserService , IThemeService } from 'browser/services/Services' ;
@@ -365,6 +365,8 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
365365 */
366366 protected _drawChars ( cell : ICellData , x : number , y : number ) : void {
367367 const chars = cell . getChars ( ) ;
368+ const code = cell . getCode ( ) ;
369+ const width = cell . getWidth ( ) ;
368370 this . _cellColorResolver . resolve ( cell , x , this . _bufferService . buffer . ydisp + y , this . _deviceCellWidth ) ;
369371
370372 if ( ! this . _charAtlas ) {
@@ -400,6 +402,23 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
400402 this . _bitmapGenerator [ glyph . texturePage ] ! . refresh ( ) ;
401403 this . _bitmapGenerator [ glyph . texturePage ] ! . version = this . _charAtlas . pages [ glyph . texturePage ] . version ;
402404 }
405+
406+ // Reduce scale horizontally for wide glyphs printed in cells that would overlap with the
407+ // following cell (ie. the width is not 2).
408+ let renderWidth = glyph . size . x ;
409+ if ( this . _optionsService . rawOptions . rescaleOverlappingGlyphs ) {
410+ if (
411+ // Is single cell width
412+ width === 1 &&
413+ // Glyph exceeds cell bounds, + 1 to avoid hurting readability
414+ glyph . size . x > this . _deviceCellWidth + 1 &&
415+ // Never rescale emoji
416+ code && ! isEmoji ( code )
417+ ) {
418+ renderWidth = this . _deviceCellWidth - 1 ; // - 1 to improve readability
419+ }
420+ }
421+
403422 this . _ctx . drawImage (
404423 this . _bitmapGenerator [ glyph . texturePage ] ?. bitmap || this . _charAtlas ! . pages [ glyph . texturePage ] . canvas ,
405424 glyph . texturePosition . x ,
@@ -408,7 +427,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
408427 glyph . size . y ,
409428 x * this . _deviceCellWidth + this . _deviceCharLeft - glyph . offset . x ,
410429 y * this . _deviceCellHeight + this . _deviceCharTop - glyph . offset . y ,
411- glyph . size . x ,
430+ renderWidth ,
412431 glyph . size . y
413432 ) ;
414433 this . _ctx . restore ( ) ;
0 commit comments