@@ -88,14 +88,21 @@ class NeovimRenderer {
8888 }
8989
9090 setupCanvas ( ) {
91- this . canvas . width = this . cols * this . cellWidth ;
92- this . canvas . height = this . rows * this . cellHeight ;
91+ const dpr = window . devicePixelRatio || 1 ;
92+
93+ this . canvas . width = this . cols * this . cellWidth * dpr ;
94+ this . canvas . height = this . rows * this . cellHeight * dpr ;
95+
96+ this . canvas . style . width = this . cols * this . cellWidth + "px" ;
97+ this . canvas . style . height = this . rows * this . cellHeight + "px" ;
98+
99+ this . ctx . scale ( dpr , dpr ) ;
93100 this . ctx . font = `${ this . fontSize } px ${ this . fontFamily } ` ;
94101 this . ctx . textBaseline = "top" ;
95102
96- // Add performance optimizations
97- this . ctx . imageSmoothingEnabled = false ; // Disable antialiasing for text
98- this . ctx . textRenderingOptimization = "optimizeSpeed" ;
103+ this . ctx . imageSmoothingEnabled = false ;
104+ this . ctx . textRenderingOptimization = "optimizeQuality" ;
105+ this . ctx . fillStyle = this . colors . fg ;
99106
100107 this . clear ( ) ;
101108 }
@@ -685,18 +692,23 @@ class NeovimRenderer {
685692 }
686693
687694 resize ( width , height ) {
695+ const dpr = window . devicePixelRatio || 1 ;
696+
688697 this . canvas . style . width = width + "px" ;
689698 this . canvas . style . height = height + "px" ;
690- this . canvas . width = width ;
691- this . canvas . height = height ;
699+ this . canvas . width = width * dpr ;
700+ this . canvas . height = height * dpr ;
692701
693702 this . cols = Math . floor ( width / this . cellWidth ) ;
694703 this . rows = Math . floor ( height / this . cellHeight ) ;
695704
696705 this . initGrid ( ) ;
697706
707+ this . ctx . scale ( dpr , dpr ) ;
698708 this . ctx . font = `${ this . fontSize } px ${ this . fontFamily } ` ;
699709 this . ctx . textBaseline = "top" ;
710+ this . ctx . imageSmoothingEnabled = false ;
711+ this . ctx . textRenderingOptimization = "optimizeQuality" ;
700712
701713 this . redraw ( ) ;
702714 return { width : this . cols , height : this . rows } ;
0 commit comments