File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -289,13 +289,13 @@ export function getFastTextWidthWithSizeString(
289289 // Initialize the HTML canvas context and set the font.
290290 // The context font must match blocklyText's fontsize and font-family
291291 // set in CSS.
292- canvasContext = computeCanvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
292+ canvasContext = computeCanvas . getContext ( '2d' ) ;
293293 }
294- // Set the desired font size and family.
295- canvasContext . font = fontWeight + ' ' + fontSize + ' ' + fontFamily ;
296294
297295 // Measure the text width using the helper canvas context.
298- if ( text ) {
296+ if ( text && canvasContext ) {
297+ // Set the desired font size and family.
298+ canvasContext . font = fontWeight + ' ' + fontSize + ' ' + fontFamily ;
299299 width = canvasContext . measureText ( text ) . width ;
300300 } else {
301301 width = 0 ;
You can’t perform that action at this time.
0 commit comments