@nasser-sw/fabric 7.0.1-beta7 → 7.0.1-beta9

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.
Files changed (148) hide show
  1. package/debug/konva-master/CHANGELOG.md +1475 -0
  2. package/debug/konva-master/LICENSE +22 -0
  3. package/debug/konva-master/README.md +209 -0
  4. package/debug/konva-master/gulpfile.mjs +110 -0
  5. package/debug/konva-master/package.json +139 -0
  6. package/debug/konva-master/release.sh +62 -0
  7. package/debug/konva-master/resources/doc-includes/ContainerParams.txt +6 -0
  8. package/debug/konva-master/resources/doc-includes/NodeParams.txt +20 -0
  9. package/debug/konva-master/resources/doc-includes/ShapeParams.txt +53 -0
  10. package/debug/konva-master/resources/jsdoc.conf.json +28 -0
  11. package/debug/konva-master/rollup.config.mjs +32 -0
  12. package/debug/konva-master/src/Animation.ts +237 -0
  13. package/debug/konva-master/src/BezierFunctions.ts +826 -0
  14. package/debug/konva-master/src/Canvas.ts +230 -0
  15. package/debug/konva-master/src/Container.ts +649 -0
  16. package/debug/konva-master/src/Context.ts +1017 -0
  17. package/debug/konva-master/src/Core.ts +5 -0
  18. package/debug/konva-master/src/DragAndDrop.ts +173 -0
  19. package/debug/konva-master/src/Factory.ts +246 -0
  20. package/debug/konva-master/src/FastLayer.ts +29 -0
  21. package/debug/konva-master/src/Global.ts +210 -0
  22. package/debug/konva-master/src/Group.ts +31 -0
  23. package/debug/konva-master/src/Layer.ts +546 -0
  24. package/debug/konva-master/src/Node.ts +3477 -0
  25. package/debug/konva-master/src/PointerEvents.ts +67 -0
  26. package/debug/konva-master/src/Shape.ts +2081 -0
  27. package/debug/konva-master/src/Stage.ts +1000 -0
  28. package/debug/konva-master/src/Tween.ts +811 -0
  29. package/debug/konva-master/src/Util.ts +1123 -0
  30. package/debug/konva-master/src/Validators.ts +210 -0
  31. package/debug/konva-master/src/_CoreInternals.ts +85 -0
  32. package/debug/konva-master/src/_FullInternals.ts +171 -0
  33. package/debug/konva-master/src/canvas-backend.ts +36 -0
  34. package/debug/konva-master/src/filters/Blur.ts +388 -0
  35. package/debug/konva-master/src/filters/Brighten.ts +48 -0
  36. package/debug/konva-master/src/filters/Brightness.ts +30 -0
  37. package/debug/konva-master/src/filters/Contrast.ts +75 -0
  38. package/debug/konva-master/src/filters/Emboss.ts +207 -0
  39. package/debug/konva-master/src/filters/Enhance.ts +154 -0
  40. package/debug/konva-master/src/filters/Grayscale.ts +25 -0
  41. package/debug/konva-master/src/filters/HSL.ts +108 -0
  42. package/debug/konva-master/src/filters/HSV.ts +106 -0
  43. package/debug/konva-master/src/filters/Invert.ts +23 -0
  44. package/debug/konva-master/src/filters/Kaleidoscope.ts +274 -0
  45. package/debug/konva-master/src/filters/Mask.ts +220 -0
  46. package/debug/konva-master/src/filters/Noise.ts +44 -0
  47. package/debug/konva-master/src/filters/Pixelate.ts +107 -0
  48. package/debug/konva-master/src/filters/Posterize.ts +46 -0
  49. package/debug/konva-master/src/filters/RGB.ts +82 -0
  50. package/debug/konva-master/src/filters/RGBA.ts +103 -0
  51. package/debug/konva-master/src/filters/Sepia.ts +27 -0
  52. package/debug/konva-master/src/filters/Solarize.ts +29 -0
  53. package/debug/konva-master/src/filters/Threshold.ts +44 -0
  54. package/debug/konva-master/src/index.ts +3 -0
  55. package/debug/konva-master/src/shapes/Arc.ts +176 -0
  56. package/debug/konva-master/src/shapes/Arrow.ts +231 -0
  57. package/debug/konva-master/src/shapes/Circle.ts +76 -0
  58. package/debug/konva-master/src/shapes/Ellipse.ts +121 -0
  59. package/debug/konva-master/src/shapes/Image.ts +319 -0
  60. package/debug/konva-master/src/shapes/Label.ts +386 -0
  61. package/debug/konva-master/src/shapes/Line.ts +364 -0
  62. package/debug/konva-master/src/shapes/Path.ts +1013 -0
  63. package/debug/konva-master/src/shapes/Rect.ts +79 -0
  64. package/debug/konva-master/src/shapes/RegularPolygon.ts +167 -0
  65. package/debug/konva-master/src/shapes/Ring.ts +94 -0
  66. package/debug/konva-master/src/shapes/Sprite.ts +370 -0
  67. package/debug/konva-master/src/shapes/Star.ts +125 -0
  68. package/debug/konva-master/src/shapes/Text.ts +1065 -0
  69. package/debug/konva-master/src/shapes/TextPath.ts +583 -0
  70. package/debug/konva-master/src/shapes/Transformer.ts +1889 -0
  71. package/debug/konva-master/src/shapes/Wedge.ts +129 -0
  72. package/debug/konva-master/src/skia-backend.ts +35 -0
  73. package/debug/konva-master/src/types.ts +84 -0
  74. package/debug/konva-master/tsconfig.json +31 -0
  75. package/debug/konva-master/tsconfig.test.json +7 -0
  76. package/dist/index.js +977 -29
  77. package/dist/index.js.map +1 -1
  78. package/dist/index.min.js +1 -1
  79. package/dist/index.min.js.map +1 -1
  80. package/dist/index.min.mjs +1 -1
  81. package/dist/index.min.mjs.map +1 -1
  82. package/dist/index.mjs +977 -29
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/index.node.cjs +977 -29
  85. package/dist/index.node.cjs.map +1 -1
  86. package/dist/index.node.mjs +977 -29
  87. package/dist/index.node.mjs.map +1 -1
  88. package/dist/package.json.min.mjs +1 -1
  89. package/dist/package.json.mjs +1 -1
  90. package/dist/src/shapes/Line.d.ts +1 -0
  91. package/dist/src/shapes/Line.d.ts.map +1 -1
  92. package/dist/src/shapes/Line.min.mjs +1 -1
  93. package/dist/src/shapes/Line.min.mjs.map +1 -1
  94. package/dist/src/shapes/Line.mjs +63 -6
  95. package/dist/src/shapes/Line.mjs.map +1 -1
  96. package/dist/src/shapes/Text/Text.d.ts +19 -0
  97. package/dist/src/shapes/Text/Text.d.ts.map +1 -1
  98. package/dist/src/shapes/Text/Text.min.mjs +1 -1
  99. package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
  100. package/dist/src/shapes/Text/Text.mjs +238 -4
  101. package/dist/src/shapes/Text/Text.mjs.map +1 -1
  102. package/dist/src/shapes/Textbox.d.ts +38 -1
  103. package/dist/src/shapes/Textbox.d.ts.map +1 -1
  104. package/dist/src/shapes/Textbox.min.mjs +1 -1
  105. package/dist/src/shapes/Textbox.min.mjs.map +1 -1
  106. package/dist/src/shapes/Textbox.mjs +497 -15
  107. package/dist/src/shapes/Textbox.mjs.map +1 -1
  108. package/dist/src/text/examples/arabicTextExample.d.ts +60 -0
  109. package/dist/src/text/examples/arabicTextExample.d.ts.map +1 -0
  110. package/dist/src/text/measure.d.ts +9 -0
  111. package/dist/src/text/measure.d.ts.map +1 -1
  112. package/dist/src/text/measure.min.mjs +1 -1
  113. package/dist/src/text/measure.min.mjs.map +1 -1
  114. package/dist/src/text/measure.mjs +175 -4
  115. package/dist/src/text/measure.mjs.map +1 -1
  116. package/dist/src/text/overlayEditor.d.ts.map +1 -1
  117. package/dist/src/text/overlayEditor.min.mjs +1 -1
  118. package/dist/src/text/overlayEditor.min.mjs.map +1 -1
  119. package/dist/src/text/overlayEditor.mjs +7 -0
  120. package/dist/src/text/overlayEditor.mjs.map +1 -1
  121. package/dist/src/text/scriptUtils.d.ts +142 -0
  122. package/dist/src/text/scriptUtils.d.ts.map +1 -0
  123. package/dist/src/text/scriptUtils.min.mjs +2 -0
  124. package/dist/src/text/scriptUtils.min.mjs.map +1 -0
  125. package/dist/src/text/scriptUtils.mjs +212 -0
  126. package/dist/src/text/scriptUtils.mjs.map +1 -0
  127. package/dist-extensions/src/shapes/Line.d.ts +1 -0
  128. package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
  129. package/dist-extensions/src/shapes/Text/Text.d.ts +19 -0
  130. package/dist-extensions/src/shapes/Text/Text.d.ts.map +1 -1
  131. package/dist-extensions/src/shapes/Textbox.d.ts +38 -1
  132. package/dist-extensions/src/shapes/Textbox.d.ts.map +1 -1
  133. package/dist-extensions/src/text/measure.d.ts +9 -0
  134. package/dist-extensions/src/text/measure.d.ts.map +1 -1
  135. package/dist-extensions/src/text/overlayEditor.d.ts.map +1 -1
  136. package/dist-extensions/src/text/scriptUtils.d.ts +142 -0
  137. package/dist-extensions/src/text/scriptUtils.d.ts.map +1 -0
  138. package/fabric-test-editor.html +2401 -46
  139. package/fabric-test2.html +43 -0
  140. package/fonts/STV Bold.ttf +0 -0
  141. package/fonts/STV Light.ttf +0 -0
  142. package/fonts/STV Regular.ttf +0 -0
  143. package/package.json +1 -1
  144. package/src/shapes/Line.ts +132 -46
  145. package/src/shapes/Text/Text.ts +238 -5
  146. package/src/shapes/Textbox.ts +521 -11
  147. package/src/text/measure.ts +200 -50
  148. package/src/text/overlayEditor.ts +7 -0
@@ -8,6 +8,7 @@ import { classRegistry } from '../../ClassRegistry.mjs';
8
8
  import { graphemeSplit } from '../../util/lang_string.mjs';
9
9
  import { createCanvasElementFor } from '../../util/misc/dom.mjs';
10
10
  import { layoutText } from '../../text/layout.mjs';
11
+ import { segmentGraphemes } from '../../text/unicode.mjs';
11
12
  import { hasStyleChanged, stylesToArray, stylesFromArray } from '../../util/misc/textStyles.mjs';
12
13
  import { getPathSegmentsInfo, getPointOnPath } from '../../util/path/index.mjs';
13
14
  import '../Object/FabricObject.mjs';
@@ -149,6 +150,15 @@ class FabricText extends StyledText {
149
150
  * Does not return dimensions.
150
151
  */
151
152
  initDimensions() {
153
+ // Check if font is ready for accurate measurements
154
+ // Only block initialization if it's a critical font loading situation
155
+ const fontReady = this._isFontReady();
156
+ if (!fontReady && !this.initialized) {
157
+ // Only schedule font loading on first initialization
158
+ this._scheduleInitAfterFontLoad();
159
+ // Continue with fallback measurements for now
160
+ }
161
+
152
162
  // Use advanced layout if enabled
153
163
  if (this.enableAdvancedLayout && !this.path) {
154
164
  return this.initDimensionsAdvanced();
@@ -165,7 +175,21 @@ class FabricText extends StyledText {
165
175
  }
166
176
  if (this.textAlign.includes(JUSTIFY)) {
167
177
  // once text is measured we need to make space fatter to make justified text.
168
- this.enlargeSpaces();
178
+ // Ensure __charBounds exists before calling enlargeSpaces
179
+ if (this.__charBounds && this.__charBounds.length > 0) {
180
+ this.enlargeSpaces();
181
+ } else {
182
+ console.warn('⚠️ __charBounds not ready for justify alignment, deferring enlargeSpaces');
183
+ // Defer the justify calculation until the next frame
184
+ setTimeout(() => {
185
+ if (this.__charBounds && this.__charBounds.length > 0 && this.enlargeSpaces) {
186
+ var _this$canvas;
187
+ console.log('🔧 Applying deferred justify alignment');
188
+ this.enlargeSpaces();
189
+ (_this$canvas = this.canvas) === null || _this$canvas === void 0 || _this$canvas.requestRenderAll();
190
+ }
191
+ }, 0);
192
+ }
169
193
  }
170
194
  }
171
195
 
@@ -176,7 +200,7 @@ class FabricText extends StyledText {
176
200
  let diffSpace, currentLineWidth, numberOfSpaces, accumulatedSpace, line, charBound, spaces;
177
201
  const isRtl = this.direction === 'rtl';
178
202
  for (let i = 0, len = this._textLines.length; i < len; i++) {
179
- if (this.textAlign !== JUSTIFY && (i === len - 1 || this.isEndOfWrapping(i))) {
203
+ if (!this.textAlign.includes('justify') && (i === len - 1 || this.isEndOfWrapping(i))) {
180
204
  continue;
181
205
  }
182
206
  accumulatedSpace = 0;
@@ -185,6 +209,9 @@ class FabricText extends StyledText {
185
209
  if (currentLineWidth < this.width && (spaces = this.textLines[i].match(this._reSpacesAndTabs))) {
186
210
  numberOfSpaces = spaces.length;
187
211
  diffSpace = (this.width - currentLineWidth) / numberOfSpaces;
212
+ console.log(`🔧 EnlargeSpaces Line ${i}:`);
213
+ console.log(` Current width: ${currentLineWidth}, Target: ${this.width}`);
214
+ console.log(` Spaces: ${numberOfSpaces}, diffSpace: ${diffSpace.toFixed(2)}`);
188
215
  if (isRtl) {
189
216
  for (let j = 0; j < line.length; j++) {
190
217
  if (this._reSpaceAndTab.test(line[j])) ;
@@ -300,6 +327,18 @@ class FabricText extends StyledText {
300
327
 
301
328
  // Convert layout to legacy format for compatibility
302
329
  this._convertLayoutToLegacyFormat(layout);
330
+
331
+ // Ensure justify alignment is properly applied for compatibility with legacy rendering
332
+ if (this.textAlign.includes(JUSTIFY)) {
333
+ // Force enlarge spaces after advanced layout calculation
334
+ setTimeout(() => {
335
+ if (this.enlargeSpaces) {
336
+ var _this$canvas2;
337
+ this.enlargeSpaces();
338
+ (_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 || _this$canvas2.renderAll();
339
+ }
340
+ }, 0);
341
+ }
303
342
  this.dirty = true;
304
343
  }
305
344
 
@@ -1311,7 +1350,19 @@ class FabricText extends StyledText {
1311
1350
  fontSize = this.fontSize
1312
1351
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1313
1352
  let forMeasuring = arguments.length > 1 ? arguments[1] : undefined;
1314
- const parsedFontFamily = fontFamily.includes("'") || fontFamily.includes('"') || fontFamily.includes(',') || FabricText.genericFonts.includes(fontFamily.toLowerCase()) ? fontFamily : `"${fontFamily}"`;
1353
+ let parsedFontFamily = fontFamily.includes("'") || fontFamily.includes('"') || fontFamily.includes(',') || FabricText.genericFonts.includes(fontFamily.toLowerCase()) ? fontFamily : `"${fontFamily}"`;
1354
+
1355
+ // For fonts like STV that don't support English/Latin characters,
1356
+ // add fallback fonts for consistent rendering of unsupported characters
1357
+ // Only add fallbacks during actual rendering, not for measurements
1358
+ if (!forMeasuring &&
1359
+ // Only during rendering, not measuring
1360
+ !fontFamily.includes(',') && (
1361
+ // Don't add fallbacks if already has them
1362
+ fontFamily.toLowerCase().includes('stv') || fontFamily.toLowerCase().includes('arabic') || fontFamily.toLowerCase().includes('naskh') || fontFamily.toLowerCase().includes('kufi'))) {
1363
+ // Add fallback fonts for unsupported characters (spaces, punctuation, etc.)
1364
+ parsedFontFamily = `${parsedFontFamily}, "Arial Unicode MS", Arial, sans-serif`;
1365
+ }
1315
1366
  return [fontStyle, fontWeight, `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`, parsedFontFamily].join(' ');
1316
1367
  }
1317
1368
 
@@ -1355,7 +1406,13 @@ class FabricText extends StyledText {
1355
1406
  newLine = ['\n'];
1356
1407
  let newText = [];
1357
1408
  for (let i = 0; i < lines.length; i++) {
1358
- newLines[i] = this.graphemeSplit(lines[i]);
1409
+ // Use BiDi-aware grapheme splitting for RTL text
1410
+ if (this.direction === 'rtl' || this._containsArabicText(lines[i])) {
1411
+ newLines[i] = segmentGraphemes(lines[i]);
1412
+ console.log(`🔤 BiDi-aware split line ${i}: "${lines[i]}" -> [${newLines[i].join(', ')}]`);
1413
+ } else {
1414
+ newLines[i] = this.graphemeSplit(lines[i]);
1415
+ }
1359
1416
  newText = newText.concat(newLines[i], newLine);
1360
1417
  }
1361
1418
  newText.pop();
@@ -1367,6 +1424,14 @@ class FabricText extends StyledText {
1367
1424
  };
1368
1425
  }
1369
1426
 
1427
+ /**
1428
+ * Check if text contains Arabic characters
1429
+ * @private
1430
+ */
1431
+ _containsArabicText(text) {
1432
+ return /[\u0600-\u06FF\u0750-\u077F\uFB50-\uFDFF\uFE70-\uFEFF]/.test(text);
1433
+ }
1434
+
1370
1435
  /**
1371
1436
  * Returns object representation of an instance
1372
1437
  * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
@@ -1489,6 +1554,88 @@ class FabricText extends StyledText {
1489
1554
 
1490
1555
  /* _FROM_SVG_END_ */
1491
1556
 
1557
+ /**
1558
+ * Check if the font is ready for accurate measurements
1559
+ * @private
1560
+ */
1561
+ _isFontReady() {
1562
+ if (typeof document === 'undefined' || !('fonts' in document)) {
1563
+ return true; // Assume ready in non-browser environments
1564
+ }
1565
+ try {
1566
+ return document.fonts.check(`${this.fontSize}px ${this.fontFamily}`);
1567
+ } catch (e) {
1568
+ return true; // Fallback to assuming ready if check fails
1569
+ }
1570
+ }
1571
+
1572
+ /**
1573
+ * Schedule re-initialization after font loads
1574
+ * @private
1575
+ */
1576
+ _scheduleInitAfterFontLoad() {
1577
+ if (typeof document === 'undefined' || !('fonts' in document)) {
1578
+ return;
1579
+ }
1580
+
1581
+ // Only schedule if not already waiting
1582
+ if (this._fontLoadScheduled) {
1583
+ return;
1584
+ }
1585
+ this._fontLoadScheduled = true;
1586
+ const fontSpec = `${this.fontSize}px ${this.fontFamily}`;
1587
+ document.fonts.load(fontSpec).then(() => {
1588
+ this._fontLoadScheduled = false;
1589
+ // Re-initialize dimensions with proper font metrics
1590
+ this.initDimensions();
1591
+
1592
+ // Extra step for justify alignment after font loading
1593
+ if (this.textAlign && this.textAlign.includes(JUSTIFY)) {
1594
+ setTimeout(() => {
1595
+ var _this$canvas3;
1596
+ if (this.enlargeSpaces) {
1597
+ this.enlargeSpaces();
1598
+ }
1599
+ (_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 || _this$canvas3.requestRenderAll();
1600
+ }, 10);
1601
+ } else {
1602
+ var _this$canvas4;
1603
+ (_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 || _this$canvas4.requestRenderAll();
1604
+ }
1605
+ }).catch(() => {
1606
+ this._fontLoadScheduled = false;
1607
+ });
1608
+ }
1609
+
1610
+ /**
1611
+ * Force complete text re-initialization (useful after JSON loading)
1612
+ */
1613
+ forceTextReinitialization() {
1614
+ console.log('🔄 Force reinitializing text object');
1615
+
1616
+ // Clear all caches
1617
+ this._clearCache();
1618
+ this.dirty = true;
1619
+
1620
+ // Force text splitting to rebuild internal structures
1621
+ this._splitText();
1622
+
1623
+ // Re-initialize dimensions
1624
+ this.initDimensions();
1625
+
1626
+ // Special handling for justify alignment
1627
+ if (this.textAlign && this.textAlign.includes(JUSTIFY)) {
1628
+ // Ensure justify is applied after dimensions are set
1629
+ setTimeout(() => {
1630
+ if (this.__charBounds && this.__charBounds.length > 0 && this.enlargeSpaces) {
1631
+ var _this$canvas5;
1632
+ this.enlargeSpaces();
1633
+ (_this$canvas5 = this.canvas) === null || _this$canvas5 === void 0 || _this$canvas5.requestRenderAll();
1634
+ }
1635
+ }, 10);
1636
+ }
1637
+ }
1638
+
1492
1639
  /**
1493
1640
  * Returns FabricText instance from an object representation
1494
1641
  * @param {Object} object plain js Object to create an instance from
@@ -1500,6 +1647,93 @@ class FabricText extends StyledText {
1500
1647
  styles: stylesFromArray(object.styles || {}, object.text)
1501
1648
  }, {
1502
1649
  extraParam: 'text'
1650
+ }).then(textObject => {
1651
+ // Ensure text object is properly initialized after JSON deserialization
1652
+ // This is critical for justify alignment and other text layout features
1653
+ textObject.initialized = true;
1654
+
1655
+ // Force reinitialization to ensure proper layout
1656
+ if (textObject._clearCache) {
1657
+ textObject._clearCache();
1658
+ }
1659
+ textObject.dirty = true;
1660
+
1661
+ // Check if we need to wait for font loading (especially for custom fonts like STV)
1662
+ const fontSpec = `${textObject.fontSize}px ${textObject.fontFamily}`;
1663
+
1664
+ // For custom fonts, ensure they're loaded before initializing dimensions
1665
+ if (typeof document !== 'undefined' && 'fonts' in document && textObject.fontFamily !== 'Arial' && textObject.fontFamily !== 'Times New Roman') {
1666
+ return document.fonts.load(fontSpec).then(() => {
1667
+ var _textObject$fontFamil;
1668
+ console.log(`🔤 Font loaded for JSON object: ${fontSpec}`);
1669
+ // Ensure initialized flag is set again (in case constructor reset it)
1670
+ textObject.initialized = true;
1671
+
1672
+ // Special handling for STV fonts which have measurement issues
1673
+ const isStvFont = (_textObject$fontFamil = textObject.fontFamily) === null || _textObject$fontFamil === void 0 ? void 0 : _textObject$fontFamil.toLowerCase().includes('stv');
1674
+ if (isStvFont) {
1675
+ console.log(`🔤 STV font detected, using enhanced reinitialization`);
1676
+
1677
+ // Clear all cached state that might interfere with browser wrapping
1678
+ textObject._browserWrapCache = null;
1679
+ textObject._lastDimensionState = null;
1680
+ textObject._browserWrapInitialized = false;
1681
+ console.log(`🔤 STV font: Cleared all cached states for fresh initialization`);
1682
+
1683
+ // Force browser wrapping flag for STV fonts
1684
+ textObject._usingBrowserWrapping = true;
1685
+ console.log(`🔤 STV font: Forcing browser wrapping flag during JSON load`);
1686
+
1687
+ // Multiple initialization attempts for STV fonts
1688
+ const reinitWithDelay = attempt => {
1689
+ if (textObject.forceTextReinitialization) {
1690
+ textObject.forceTextReinitialization();
1691
+ } else {
1692
+ textObject.initDimensions();
1693
+ }
1694
+
1695
+ // Check if width is still problematic after initialization
1696
+ if (textObject.width < 50 && attempt < 3) {
1697
+ console.log(`🔤 STV font width still ${textObject.width}px, retrying in ${100 * attempt}ms (attempt ${attempt + 1}/3)`);
1698
+ setTimeout(() => reinitWithDelay(attempt + 1), 100 * attempt);
1699
+ }
1700
+ };
1701
+ reinitWithDelay(0);
1702
+ } else {
1703
+ // Use specialized reinitialization for Textbox objects
1704
+ if (textObject.forceTextReinitialization) {
1705
+ console.log(`🔤 Using Textbox specialized reinitialization`);
1706
+ textObject.forceTextReinitialization();
1707
+ } else {
1708
+ // Reinitialize dimensions with proper font metrics
1709
+ textObject.initDimensions();
1710
+ }
1711
+ }
1712
+ return textObject;
1713
+ }).catch(() => {
1714
+ console.warn(`⚠️ Font loading failed for ${fontSpec}, proceeding with fallback`);
1715
+ // Ensure initialized flag is set again
1716
+ textObject.initialized = true;
1717
+
1718
+ // Still initialize dimensions even if font loading fails
1719
+ if (textObject.forceTextReinitialization) {
1720
+ textObject.forceTextReinitialization();
1721
+ } else {
1722
+ textObject.initDimensions();
1723
+ }
1724
+ return textObject;
1725
+ });
1726
+ } else {
1727
+ // Standard fonts - ensure initialized and use appropriate method
1728
+ textObject.initialized = true;
1729
+ if (textObject.forceTextReinitialization) {
1730
+ console.log(`🔤 Using Textbox specialized reinitialization for standard font`);
1731
+ textObject.forceTextReinitialization();
1732
+ } else {
1733
+ textObject.initDimensions();
1734
+ }
1735
+ return textObject;
1736
+ }
1503
1737
  });
1504
1738
  }
1505
1739
  }