@@ -84,6 +84,7 @@ const CELL_POSITION_INDICES = 2;
8484
8585// Work variables to avoid garbage collection
8686let $i = 0 ;
87+ let $j = 0 ;
8788let $glyph : IRasterizedGlyph | undefined = undefined ;
8889let $glyphs : IRasterizedGlyph [ ] | undefined = undefined ;
8990let $leftCellPadding = 0 ;
@@ -241,40 +242,44 @@ export class GlyphRenderer extends Disposable {
241242 } else {
242243 $glyphs = this . _atlas . getRasterizedGlyph ( code , bg , fg , ext ) ;
243244 }
244- $glyph = $glyphs [ 0 ] ;
245-
246- $leftCellPadding = Math . floor ( ( this . _dimensions . device . cell . width - this . _dimensions . device . char . width ) / 2 ) ;
247- if ( bg !== lastBg && $glyph . offset . x > $leftCellPadding ) {
248- $clippedPixels = $glyph . offset . x - $leftCellPadding ;
249- // a_origin
250- array [ $i ] = - ( $glyph . offset . x - $clippedPixels ) + this . _dimensions . device . char . left ;
251- array [ $i + 1 ] = - $glyph . offset . y + this . _dimensions . device . char . top ;
252- // a_size
253- array [ $i + 2 ] = ( $glyph . size . x - $clippedPixels ) / this . _dimensions . device . canvas . width ;
254- array [ $i + 3 ] = $glyph . size . y / this . _dimensions . device . canvas . height ;
255- // a_texpage
256- array [ $i + 4 ] = $glyph . texturePage ;
257- // a_texcoord
258- array [ $i + 5 ] = $glyph . texturePositionClipSpace . x + $clippedPixels / this . _atlas . pages [ $glyph . texturePage ] . canvas . width ;
259- array [ $i + 6 ] = $glyph . texturePositionClipSpace . y ;
260- // a_texsize
261- array [ $i + 7 ] = $glyph . sizeClipSpace . x - $clippedPixels / this . _atlas . pages [ $glyph . texturePage ] . canvas . width ;
262- array [ $i + 8 ] = $glyph . sizeClipSpace . y ;
263- } else {
264- // a_origin
265- array [ $i ] = - $glyph . offset . x + this . _dimensions . device . char . left ;
266- array [ $i + 1 ] = - $glyph . offset . y + this . _dimensions . device . char . top ;
267- // a_size
268- array [ $i + 2 ] = $glyph . size . x / this . _dimensions . device . canvas . width ;
269- array [ $i + 3 ] = $glyph . size . y / this . _dimensions . device . canvas . height ;
270- // a_texpage
271- array [ $i + 4 ] = $glyph . texturePage ;
272- // a_texcoord
273- array [ $i + 5 ] = $glyph . texturePositionClipSpace . x ;
274- array [ $i + 6 ] = $glyph . texturePositionClipSpace . y ;
275- // a_texsize
276- array [ $i + 7 ] = $glyph . sizeClipSpace . x ;
277- array [ $i + 8 ] = $glyph . sizeClipSpace . y ;
245+
246+ for ( $j = 0 ; $j < $glyphs . length ; $j ++ ) {
247+ $i = ( y * this . _terminal . cols + x + $j ) * INDICES_PER_CELL ;
248+ $glyph = $glyphs [ $j ] ;
249+
250+ $leftCellPadding = Math . floor ( ( this . _dimensions . device . cell . width - this . _dimensions . device . char . width ) / 2 ) ;
251+ if ( bg !== lastBg && $glyph . offset . x > $leftCellPadding ) {
252+ $clippedPixels = $glyph . offset . x - $leftCellPadding ;
253+ // a_origin
254+ array [ $i ] = - ( $glyph . offset . x - $clippedPixels ) + this . _dimensions . device . char . left ;
255+ array [ $i + 1 ] = - $glyph . offset . y + this . _dimensions . device . char . top ;
256+ // a_size
257+ array [ $i + 2 ] = ( $glyph . size . x - $clippedPixels ) / this . _dimensions . device . canvas . width ;
258+ array [ $i + 3 ] = $glyph . size . y / this . _dimensions . device . canvas . height ;
259+ // a_texpage
260+ array [ $i + 4 ] = $glyph . texturePage ;
261+ // a_texcoord
262+ array [ $i + 5 ] = $glyph . texturePositionClipSpace . x + $clippedPixels / this . _atlas . pages [ $glyph . texturePage ] . canvas . width ;
263+ array [ $i + 6 ] = $glyph . texturePositionClipSpace . y ;
264+ // a_texsize
265+ array [ $i + 7 ] = $glyph . sizeClipSpace . x - $clippedPixels / this . _atlas . pages [ $glyph . texturePage ] . canvas . width ;
266+ array [ $i + 8 ] = $glyph . sizeClipSpace . y ;
267+ } else {
268+ // a_origin
269+ array [ $i ] = - $glyph . offset . x + this . _dimensions . device . char . left ;
270+ array [ $i + 1 ] = - $glyph . offset . y + this . _dimensions . device . char . top ;
271+ // a_size
272+ array [ $i + 2 ] = $glyph . size . x / this . _dimensions . device . canvas . width ;
273+ array [ $i + 3 ] = $glyph . size . y / this . _dimensions . device . canvas . height ;
274+ // a_texpage
275+ array [ $i + 4 ] = $glyph . texturePage ;
276+ // a_texcoord
277+ array [ $i + 5 ] = $glyph . texturePositionClipSpace . x ;
278+ array [ $i + 6 ] = $glyph . texturePositionClipSpace . y ;
279+ // a_texsize
280+ array [ $i + 7 ] = $glyph . sizeClipSpace . x ;
281+ array [ $i + 8 ] = $glyph . sizeClipSpace . y ;
282+ }
278283 }
279284 // a_cellpos only changes on resize
280285 }
0 commit comments