mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
fix: Remove un-typesafe cast. (#9052)
This commit is contained in:
@@ -289,13 +289,13 @@ export function getFastTextWidthWithSizeString(
|
||||
// Initialize the HTML canvas context and set the font.
|
||||
// The context font must match blocklyText's fontsize and font-family
|
||||
// set in CSS.
|
||||
canvasContext = computeCanvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
canvasContext = computeCanvas.getContext('2d');
|
||||
}
|
||||
// Set the desired font size and family.
|
||||
canvasContext.font = fontWeight + ' ' + fontSize + ' ' + fontFamily;
|
||||
|
||||
// Measure the text width using the helper canvas context.
|
||||
if (text) {
|
||||
if (text && canvasContext) {
|
||||
// Set the desired font size and family.
|
||||
canvasContext.font = fontWeight + ' ' + fontSize + ' ' + fontFamily;
|
||||
width = canvasContext.measureText(text).width;
|
||||
} else {
|
||||
width = 0;
|
||||
|
||||
Reference in New Issue
Block a user