Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: canvas crash when draw broken image (#4388)

siam09fd43220cd7
diff --git a/packages/engine-render/src/components/sheets/extensions/font.ts b/packages/engine-render/src/components/sheets/extensions/font.ts
index 7e32caa517..22f9eeb28a 100644
--- a/packages/engine-render/src/components/sheets/extensions/font.ts
+++ b/packages/engine-render/src/components/sheets/extensions/font.ts
@@ -302,7 +302,11 @@ export class Font extends SheetExtension {
ctx.save();
ctx.translate(x + rotatedWidth / 2, y + rotatedHeight / 2);
ctx.rotate(angleRadians);
- ctx.drawImage(image, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
+ try {
+ ctx.drawImage(image, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
+ } catch (e) {
+ console.error(e);
+ }
ctx.restore();
}
}