File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -134,9 +134,14 @@ export class WidthCache implements IDisposable {
134134 public get ( c : string , bold : boolean | number , italic : boolean | number ) : number {
135135 let cp = 0 ;
136136 if ( ! bold && ! italic && c . length === 1 && ( cp = c . charCodeAt ( 0 ) ) < WidthCacheSettings . FLAT_SIZE ) {
137- return this . _flat [ cp ] !== WidthCacheSettings . FLAT_UNSET
138- ? this . _flat [ cp ]
139- : ( this . _flat [ cp ] = this . _measure ( c , 0 ) ) ;
137+ if ( this . _flat [ cp ] !== WidthCacheSettings . FLAT_UNSET ) {
138+ return this . _flat [ cp ] ;
139+ }
140+ const width = this . _measure ( c , 0 ) ;
141+ if ( width > 0 ) {
142+ this . _flat [ cp ] = width ;
143+ }
144+ return width ;
140145 }
141146 let key = c ;
142147 if ( bold ) key += 'B' ;
@@ -147,7 +152,9 @@ export class WidthCache implements IDisposable {
147152 if ( bold ) variant |= FontVariant . BOLD ;
148153 if ( italic ) variant |= FontVariant . ITALIC ;
149154 width = this . _measure ( c , variant ) ;
150- this . _holey ! . set ( key , width ) ;
155+ if ( width > 0 ) {
156+ this . _holey ! . set ( key , width ) ;
157+ }
151158 }
152159 return width ;
153160 }
You can’t perform that action at this time.
0 commit comments