@pixldocs/canvas-renderer 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2577,13 +2577,23 @@ const clearFabricCharCache = () => {
2577
2577
  };
2578
2578
  const clearFontCacheAndRerender = (canvas) => {
2579
2579
  clearFabricCharCache();
2580
- canvas.getObjects().forEach((obj) => {
2580
+ const fixTextbox = (obj) => {
2581
+ var _a;
2581
2582
  if (obj instanceof fabric__namespace.Textbox) {
2583
+ const savedWidth = obj.width;
2582
2584
  obj.dirty = true;
2583
2585
  obj.initDimensions();
2586
+ if (savedWidth != null && Math.abs((obj.width ?? 0) - savedWidth) > 0.01) {
2587
+ obj.width = savedWidth;
2588
+ }
2589
+ obj.setCoords();
2590
+ } else if (obj instanceof fabric__namespace.Group) {
2591
+ (_a = obj._objects) == null ? void 0 : _a.forEach(fixTextbox);
2592
+ obj.dirty = true;
2584
2593
  obj.setCoords();
2585
2594
  }
2586
- });
2595
+ };
2596
+ canvas.getObjects().forEach(fixTextbox);
2587
2597
  canvas.requestRenderAll();
2588
2598
  };
2589
2599
  const ensureFontLoaded = async (fontFamily) => {