@@ -417,23 +417,23 @@ export class WebglCharAtlas implements IDisposable {
417417 `${ fontStyle } ${ fontWeight } ${ this . _config . fontSize * this . _config . devicePixelRatio } px ${ this . _config . fontFamily } ` ;
418418 this . _tmpCtx . textBaseline = TEXT_BASELINE ;
419419
420- const powerLineGlyph = chars . length === 1 && isPowerlineGlyph ( chars . charCodeAt ( 0 ) ) ;
420+ const powerlineGlyph = chars . length === 1 && isPowerlineGlyph ( chars . charCodeAt ( 0 ) ) ;
421421 const foregroundColor = this . _getForegroundColor ( bg , bgColorMode , bgColor , fg , fgColorMode , fgColor , inverse , dim , bold , excludeFromContrastRatioDemands ( chars . charCodeAt ( 0 ) ) ) ;
422422 this . _tmpCtx . fillStyle = foregroundColor . css ;
423423
424424 // For powerline glyphs left/top padding is excluded (https://github.com/microsoft/vscode/issues/120129)
425- const padding = powerLineGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING * 2 ;
425+ const padding = powerlineGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING * 2 ;
426426
427427 // Draw custom characters if applicable
428- let drawSuccess = false ;
428+ let customGlyph = false ;
429429 if ( this . _config . customGlyphs !== false ) {
430- drawSuccess = tryDrawCustomChar ( this . _tmpCtx , chars , padding , padding , this . _config . scaledCellWidth , this . _config . scaledCellHeight ) ;
430+ customGlyph = tryDrawCustomChar ( this . _tmpCtx , chars , padding , padding , this . _config . scaledCellWidth , this . _config . scaledCellHeight ) ;
431431 }
432432
433433 // Whether to clear pixels based on a threshold difference between the glyph color and the
434434 // background color. This should be disabled when the glyph contains multiple colors such as
435435 // underline colors to prevent important colors could get cleared.
436- let enableClearThresholdCheck = true ;
436+ let enableClearThresholdCheck = ! powerlineGlyph ;
437437
438438 // Draw underline
439439 if ( underline ) {
@@ -529,7 +529,7 @@ export class WebglCharAtlas implements IDisposable {
529529
530530 // Draw stroke in the background color for non custom characters in order to give an outline
531531 // between the text and the underline
532- if ( ! drawSuccess ) {
532+ if ( ! customGlyph ) {
533533 // This only works when transparency is disabled because it's not clear how to clear stroked
534534 // text
535535 if ( ! this . _config . allowTransparency && chars !== ' ' ) {
@@ -550,7 +550,7 @@ export class WebglCharAtlas implements IDisposable {
550550 }
551551
552552 // Draw the character
553- if ( ! drawSuccess ) {
553+ if ( ! customGlyph ) {
554554 this . _tmpCtx . fillText ( chars , padding , padding + this . _config . scaledCharHeight ) ;
555555 }
556556
@@ -603,7 +603,7 @@ export class WebglCharAtlas implements IDisposable {
603603 return NULL_RASTERIZED_GLYPH ;
604604 }
605605
606- const rasterizedGlyph = this . _findGlyphBoundingBox ( imageData , this . _workBoundingBox , allowedWidth , powerLineGlyph , drawSuccess ) ;
606+ const rasterizedGlyph = this . _findGlyphBoundingBox ( imageData , this . _workBoundingBox , allowedWidth , powerlineGlyph , customGlyph , padding ) ;
607607 const clippedImageData = this . _clipImageData ( imageData , this . _workBoundingBox ) ;
608608
609609 // Find the best atlas row to use
@@ -680,10 +680,10 @@ export class WebglCharAtlas implements IDisposable {
680680 * @param imageData The image data to read.
681681 * @param boundingBox An IBoundingBox to put the clipped bounding box values.
682682 */
683- private _findGlyphBoundingBox ( imageData : ImageData , boundingBox : IBoundingBox , allowedWidth : number , restrictedGlyph : boolean , customGlyph : boolean ) : IRasterizedGlyph {
683+ private _findGlyphBoundingBox ( imageData : ImageData , boundingBox : IBoundingBox , allowedWidth : number , restrictedGlyph : boolean , customGlyph : boolean , padding : number ) : IRasterizedGlyph {
684684 boundingBox . top = 0 ;
685685 const height = restrictedGlyph ? this . _config . scaledCellHeight : this . _tmpCanvas . height ;
686- const width = restrictedGlyph ? this . _config . scaledCharWidth : allowedWidth ;
686+ const width = restrictedGlyph ? this . _config . scaledCellWidth : allowedWidth ;
687687 let found = false ;
688688 for ( let y = 0 ; y < height ; y ++ ) {
689689 for ( let x = 0 ; x < width ; x ++ ) {
@@ -755,8 +755,8 @@ export class WebglCharAtlas implements IDisposable {
755755 y : ( boundingBox . bottom - boundingBox . top + 1 ) / TEXTURE_HEIGHT
756756 } ,
757757 offset : {
758- x : - boundingBox . left + ( restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING ) + ( customGlyph ? Math . floor ( this . _config . letterSpacing / 2 ) : 0 ) ,
759- y : - boundingBox . top + ( restrictedGlyph ? 0 : TMP_CANVAS_GLYPH_PADDING ) + ( customGlyph ? this . _config . lineHeight === 1 ? 0 : Math . round ( ( this . _config . scaledCellHeight - this . _config . scaledCharHeight ) / 2 ) : 0 )
758+ x : - boundingBox . left + padding + ( ( restrictedGlyph || customGlyph ) ? Math . floor ( ( this . _config . scaledCellWidth - this . _config . scaledCharWidth ) / 2 ) : 0 ) ,
759+ y : - boundingBox . top + padding + ( ( restrictedGlyph || customGlyph ) ? this . _config . lineHeight === 1 ? 0 : Math . round ( ( this . _config . scaledCellHeight - this . _config . scaledCharHeight ) / 2 ) : 0 )
760760 }
761761 } ;
762762 }
@@ -833,8 +833,3 @@ function checkCompletelyTransparent(imageData: ImageData): boolean {
833833 }
834834 return true ;
835835}
836-
837- function toPaddedHex ( c : number ) : string {
838- const s = c . toString ( 16 ) ;
839- return s . length < 2 ? '0' + s : s ;
840- }
0 commit comments