@pixldocs/canvas-renderer 0.5.29 → 0.5.31

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.js CHANGED
@@ -2750,30 +2750,17 @@ const clearFontCacheAndRerender = (canvas) => {
2750
2750
  if (beforeMetrics.length > 0) {
2751
2751
  logUnderlineDebug("before-rerender", beforeMetrics);
2752
2752
  }
2753
- const resetTextboxLayoutInternals = (obj) => {
2754
- var _a;
2755
- (_a = obj._clearCache) == null ? void 0 : _a.call(obj);
2756
- obj.__charBounds = [];
2757
- obj.__lineWidths = [];
2758
- obj.__lineHeights = [];
2759
- obj.__graphemeLines = [];
2760
- obj._textLines = [];
2761
- obj.textLines = [];
2762
- obj._styleMap = null;
2763
- obj.styleMap = null;
2764
- obj.dirty = true;
2765
- };
2766
2753
  const fixTextbox = (obj) => {
2767
2754
  var _a, _b, _c;
2768
2755
  if (obj instanceof fabric.Textbox) {
2769
2756
  const savedWidth = obj.width;
2770
2757
  const savedScaleX = obj.scaleX;
2771
2758
  const savedScaleY = obj.scaleY;
2772
- resetTextboxLayoutInternals(obj);
2759
+ obj._forceClearCache = true;
2773
2760
  obj.initDimensions();
2774
2761
  if (savedWidth != null) {
2775
2762
  obj.set({ width: savedWidth, scaleX: savedScaleX, scaleY: savedScaleY });
2776
- resetTextboxLayoutInternals(obj);
2763
+ obj._forceClearCache = true;
2777
2764
  obj.initDimensions();
2778
2765
  obj.set({ width: savedWidth, scaleX: savedScaleX, scaleY: savedScaleY, dirty: true });
2779
2766
  }
@@ -12542,6 +12529,8 @@ class PixldocsRenderer {
12542
12529
  const fabricInstance = this.getFabricCanvasFromContainer(container);
12543
12530
  const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
12544
12531
  await this.waitForCanvasImages(container, expectedImageCount);
12532
+ await this.waitForStableTextMetrics(container, config);
12533
+ await this.waitForCanvasScene(container, config, pageIndex);
12545
12534
  const fabricCanvas = container.querySelector("canvas.upper-canvas, canvas");
12546
12535
  const sourceCanvas = (fabricInstance == null ? void 0 : fabricInstance.lowerCanvasEl) || container.querySelector("canvas.lower-canvas") || fabricCanvas;
12547
12536
  if (!sourceCanvas) {
@@ -12580,7 +12569,7 @@ class PixldocsRenderer {
12580
12569
  pageIndex,
12581
12570
  zoom: pixelRatio,
12582
12571
  absoluteZoom: true,
12583
- skipFontReadyWait: true,
12572
+ skipFontReadyWait: false,
12584
12573
  onReady
12585
12574
  })
12586
12575
  );
@@ -12629,6 +12618,8 @@ class PixldocsRenderer {
12629
12618
  }
12630
12619
  const expectedImageCount = this.getExpectedImageCount(config, pageIndex);
12631
12620
  await this.waitForCanvasImages(container, expectedImageCount);
12621
+ await this.waitForStableTextMetrics(container, config);
12622
+ await this.waitForCanvasScene(container, config, pageIndex);
12632
12623
  const prevVPT = fabricInstance.viewportTransform ? [...fabricInstance.viewportTransform] : void 0;
12633
12624
  const prevSvgVPT = fabricInstance.svgViewportTransformation;
12634
12625
  const prevRetina = fabricInstance.enableRetinaScaling;
@@ -12679,7 +12670,7 @@ class PixldocsRenderer {
12679
12670
  zoom: 1,
12680
12671
  // 1:1 — no UI scaling for SVG capture
12681
12672
  absoluteZoom: true,
12682
- skipFontReadyWait: true,
12673
+ skipFontReadyWait: false,
12683
12674
  onReady
12684
12675
  })
12685
12676
  );