@mlightcad/mtext-renderer 0.3.2 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { FontInfo, FontLoader } from './fontLoader';
1
+ import { FontInfo, FontLoader, FontLoadStatus } from './fontLoader';
2
2
 
3
3
  /**
4
4
  * Default implementation of the FontLoader interface.
@@ -25,10 +25,11 @@ export declare class DefaultFontLoader implements FontLoader {
25
25
  */
26
26
  getAvaiableFonts(): Promise<FontInfo[]>;
27
27
  /**
28
- * Loads the specified fonts into the system.
29
- * If no font names are provided, loads all available fonts.
28
+ * Loads the specified fonts into the system. If one font is already loaded,
29
+ * the font will not be loaded again. If no font names are provided, just loads
30
+ * all available fonts information (not fonts).
30
31
  * @param fontNames - Array of font names to load
31
32
  * @returns Promise that resolves to an array of FontLoadStatus objects
32
33
  */
33
- load(fontNames: string[]): Promise<import('./fontLoader').FontLoadStatus[]>;
34
+ load(fontNames: string[]): Promise<FontLoadStatus[]>;
34
35
  }
@@ -102,6 +102,12 @@ export declare class FontManager {
102
102
  * @returns The shape for the not found indicator, or undefined if not available
103
103
  */
104
104
  getNotFoundTextShape(size: number): BaseTextShape | undefined;
105
+ /**
106
+ * Checks if a font is already loaded in the system
107
+ * @param fontName - The name of the font to check
108
+ * @returns True if the font is loaded, false otherwise
109
+ */
110
+ isFontLoaded(fontName: string): boolean;
105
111
  /**
106
112
  * Records a font that was requested but not found
107
113
  * @param fontName - The name of the font that was not found
package/dist/index.js CHANGED
@@ -79,7 +79,7 @@ function Sa(t) {
79
79
  const a = () => {
80
80
  t.removeEventListener("success", s), t.removeEventListener("error", i);
81
81
  }, s = () => {
82
- r(Ue(t.result)), a();
82
+ r(Le(t.result)), a();
83
83
  }, i = () => {
84
84
  n(t.error), a();
85
85
  };
@@ -110,7 +110,7 @@ let _t = {
110
110
  if (e === "store")
111
111
  return r.objectStoreNames[1] ? void 0 : r.objectStore(r.objectStoreNames[0]);
112
112
  }
113
- return Ue(t[e]);
113
+ return Le(t[e]);
114
114
  },
115
115
  set(t, e, r) {
116
116
  return t[e] = r, !0;
@@ -124,15 +124,15 @@ function mn(t) {
124
124
  }
125
125
  function Ta(t) {
126
126
  return ba().includes(t) ? function(...e) {
127
- return t.apply(Ht(this), e), Ue(this.request);
127
+ return t.apply(Ht(this), e), Le(this.request);
128
128
  } : function(...e) {
129
- return Ue(t.apply(Ht(this), e));
129
+ return Le(t.apply(Ht(this), e));
130
130
  };
131
131
  }
132
132
  function Fa(t) {
133
133
  return typeof t == "function" ? Ta(t) : (t instanceof IDBTransaction && ka(t), Gt(t, xa()) ? new Proxy(t, _t) : t);
134
134
  }
135
- function Ue(t) {
135
+ function Le(t) {
136
136
  if (t instanceof IDBRequest)
137
137
  return Sa(t);
138
138
  if (St.has(t))
@@ -142,9 +142,9 @@ function Ue(t) {
142
142
  }
143
143
  const Ht = (t) => vt.get(t);
144
144
  function Ca(t, e, { blocked: r, upgrade: n, blocking: a, terminated: s } = {}) {
145
- const i = indexedDB.open(t, e), u = Ue(i);
145
+ const i = indexedDB.open(t, e), u = Le(i);
146
146
  return n && i.addEventListener("upgradeneeded", (o) => {
147
- n(Ue(i.result), o.oldVersion, o.newVersion, Ue(i.transaction), o);
147
+ n(Le(i.result), o.oldVersion, o.newVersion, Le(i.transaction), o);
148
148
  }), r && i.addEventListener("blocked", (o) => r(
149
149
  // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
150
150
  o.oldVersion,
@@ -213,14 +213,14 @@ mn((t) => ({
213
213
  return mr(e, r) || t.has(e, r);
214
214
  }
215
215
  }));
216
- const Ae = {
216
+ const De = {
217
217
  fonts: "fonts"
218
218
  }, Tt = [
219
219
  {
220
220
  version: 1,
221
221
  stores: [
222
222
  {
223
- name: Ae.fonts,
223
+ name: De.fonts,
224
224
  keyPath: "name"
225
225
  }
226
226
  ]
@@ -243,7 +243,7 @@ const Ae = {
243
243
  * @param fontData The font data to store
244
244
  */
245
245
  async set(e, r) {
246
- await (await this.getDatabase()).put(Ae.fonts, { ...r, name: e });
246
+ await (await this.getDatabase()).put(De.fonts, { ...r, name: e });
247
247
  }
248
248
  /**
249
249
  * Gets a font from the cache
@@ -251,27 +251,27 @@ const Ae = {
251
251
  * @returns The font data if found, undefined otherwise
252
252
  */
253
253
  async get(e) {
254
- return await (await this.getDatabase()).get(Ae.fonts, e);
254
+ return await (await this.getDatabase()).get(De.fonts, e);
255
255
  }
256
256
  /**
257
257
  * Deletes a font from the cache
258
258
  * @param fileName The font file name (key)
259
259
  */
260
260
  async delete(e) {
261
- await (await this.getDatabase()).delete(Ae.fonts, e);
261
+ await (await this.getDatabase()).delete(De.fonts, e);
262
262
  }
263
263
  /**
264
264
  * Gets all fonts from the cache
265
265
  * @returns An array of all font data in the cache
266
266
  */
267
267
  async getAll() {
268
- return await (await this.getDatabase()).getAll(Ae.fonts);
268
+ return await (await this.getDatabase()).getAll(De.fonts);
269
269
  }
270
270
  /**
271
271
  * Clears all fonts from the cache
272
272
  */
273
273
  async clear() {
274
- await (await this.getDatabase()).clear(Ae.fonts);
274
+ await (await this.getDatabase()).clear(De.fonts);
275
275
  }
276
276
  /**
277
277
  * Checks if a font exists in the cache
@@ -903,7 +903,7 @@ wn(Fn, Cn, 2, 1);
903
903
  $t[28] = 0;
904
904
  er[28] = 258;
905
905
  var qa = Va;
906
- function Re(t, e, r, n, a) {
906
+ function Ae(t, e, r, n, a) {
907
907
  return Math.pow(1 - a, 3) * t + 3 * Math.pow(1 - a, 2) * a * e + 3 * (1 - a) * Math.pow(a, 2) * r + Math.pow(a, 3) * n;
908
908
  }
909
909
  function Fe() {
@@ -930,15 +930,15 @@ Fe.prototype.addBezier = function(t, e, r, n, a, s, i, u) {
930
930
  if (p === 0)
931
931
  continue;
932
932
  var y = -g / p;
933
- 0 < y && y < 1 && (h === 0 && this.addX(Re(o[h], l[h], c[h], f[h], y)), h === 1 && this.addY(Re(o[h], l[h], c[h], f[h], y)));
933
+ 0 < y && y < 1 && (h === 0 && this.addX(Ae(o[h], l[h], c[h], f[h], y)), h === 1 && this.addY(Ae(o[h], l[h], c[h], f[h], y)));
934
934
  continue;
935
935
  }
936
936
  var m = Math.pow(p, 2) - 4 * g * d;
937
937
  if (!(m < 0)) {
938
938
  var S = (-p + Math.sqrt(m)) / (2 * d);
939
- 0 < S && S < 1 && (h === 0 && this.addX(Re(o[h], l[h], c[h], f[h], S)), h === 1 && this.addY(Re(o[h], l[h], c[h], f[h], S)));
939
+ 0 < S && S < 1 && (h === 0 && this.addX(Ae(o[h], l[h], c[h], f[h], S)), h === 1 && this.addY(Ae(o[h], l[h], c[h], f[h], S)));
940
940
  var x = (-p - Math.sqrt(m)) / (2 * d);
941
- 0 < x && x < 1 && (h === 0 && this.addX(Re(o[h], l[h], c[h], f[h], x)), h === 1 && this.addY(Re(o[h], l[h], c[h], f[h], x)));
941
+ 0 < x && x < 1 && (h === 0 && this.addX(Ae(o[h], l[h], c[h], f[h], x)), h === 1 && this.addY(Ae(o[h], l[h], c[h], f[h], x)));
942
942
  }
943
943
  }
944
944
  };
@@ -6296,7 +6296,7 @@ function bi(t, e, r, n) {
6296
6296
  function Si(t, e, r, n, a) {
6297
6297
  return a.lowMemory ? bi(t, e, r, n) : xi(t, e, r, n);
6298
6298
  }
6299
- var aa = { getPath: ra, parse: Si }, sa, Le, ia, Qt;
6299
+ var aa = { getPath: ra, parse: Si }, sa, Re, ia, Qt;
6300
6300
  function oa(t) {
6301
6301
  this.font = t, this.getCommands = function(e) {
6302
6302
  return aa.getPath(e).commands;
@@ -6522,7 +6522,7 @@ oa.prototype.exec = function(t, e) {
6522
6522
  if (!a) {
6523
6523
  be.prototype = Ei, a = this._fpgmState = new be("fpgm", r.tables.fpgm), a.funcs = [], a.font = r, exports.DEBUG && (console.log("---EXEC FPGM---"), a.step = -1);
6524
6524
  try {
6525
- Le(a);
6525
+ Re(a);
6526
6526
  } catch (l) {
6527
6527
  console.log("Hinting error in FPGM:" + l), this._errorState = 3;
6528
6528
  return;
@@ -6537,7 +6537,7 @@ oa.prototype.exec = function(t, e) {
6537
6537
  n.cvt = [];
6538
6538
  exports.DEBUG && (console.log("---EXEC PREP---"), n.step = -1);
6539
6539
  try {
6540
- Le(n);
6540
+ Re(n);
6541
6541
  } catch (l) {
6542
6542
  this._errorState < 2 && console.log("Hinting error in PREP:" + l), this._errorState = 2;
6543
6543
  }
@@ -6573,7 +6573,7 @@ ia = function(t, e) {
6573
6573
  t.instructions && !u.inhibitGridFit && (u = new be("glyf", t.instructions), u.gZone = u.z0 = u.z1 = u.z2 = i, u.contours = s, i.push(
6574
6574
  new ge(0, 0),
6575
6575
  new ge(Math.round(t.advanceWidth * r), 0)
6576
- ), exports.DEBUG && (console.log("---EXEC COMPOSITE---"), u.step = -1), Le(u), i.length -= 2);
6576
+ ), exports.DEBUG && (console.log("---EXEC COMPOSITE---"), u.step = -1), Re(u), i.length -= 2);
6577
6577
  }
6578
6578
  return i;
6579
6579
  };
@@ -6596,14 +6596,14 @@ Qt = function(t, e, r, n) {
6596
6596
  if (i.push(
6597
6597
  new ge(0, 0),
6598
6598
  new ge(Math.round(t.advanceWidth * r), 0)
6599
- ), Le(e), i.length -= 2, exports.DEBUG) {
6599
+ ), Re(e), i.length -= 2, exports.DEBUG) {
6600
6600
  console.log("FINISHED GLYPH", e.stack);
6601
6601
  for (var d = 0; d < s; d++)
6602
6602
  console.log(d, i[d].x, i[d].y);
6603
6603
  }
6604
6604
  }
6605
6605
  };
6606
- Le = function(t) {
6606
+ Re = function(t) {
6607
6607
  var e = t.prog;
6608
6608
  if (e) {
6609
6609
  var r = e.length, n;
@@ -6795,7 +6795,7 @@ function Ji(t) {
6795
6795
  var a = t.ip, s = t.prog;
6796
6796
  t.prog = t.funcs[r];
6797
6797
  for (var i = 0; i < n; i++)
6798
- Le(t), exports.DEBUG && console.log(
6798
+ Re(t), exports.DEBUG && console.log(
6799
6799
  ++t.step,
6800
6800
  i + 1 < n ? "next loopcall" : "done loopcall",
6801
6801
  i
@@ -6806,7 +6806,7 @@ function $i(t) {
6806
6806
  var e = t.stack.pop();
6807
6807
  exports.DEBUG && console.log(t.step, "CALL[]", e);
6808
6808
  var r = t.ip, n = t.prog;
6809
- t.prog = t.funcs[e], Le(t), t.ip = r, t.prog = n, exports.DEBUG && console.log(++t.step, "returning from", e);
6809
+ t.prog = t.funcs[e], Re(t), t.ip = r, t.prog = n, exports.DEBUG && console.log(++t.step, "returning from", e);
6810
6810
  }
6811
6811
  function eo(t) {
6812
6812
  var e = t.stack, r = e.pop();
@@ -10584,7 +10584,7 @@ class Se {
10584
10584
  throw new Error(`Unsupported font file type: ${n}`);
10585
10585
  }
10586
10586
  }
10587
- class Me {
10587
+ class Ue {
10588
10588
  constructor() {
10589
10589
  this.fontMapping = {}, this.fontMap = /* @__PURE__ */ new Map(), this.unsupportedChars = {}, this.missedFonts = {}, this.enableFontCache = !0, this.defaultFont = "simsun", this.events = {
10590
10590
  /** Event triggered when a font cannot be found */
@@ -10598,7 +10598,7 @@ class Me {
10598
10598
  * @returns The FontManager instance
10599
10599
  */
10600
10600
  static get instance() {
10601
- return Me._instance || (Me._instance = new Me()), Me._instance;
10601
+ return Ue._instance || (Ue._instance = new Ue()), Ue._instance;
10602
10602
  }
10603
10603
  /**
10604
10604
  * Sets the font mapping configuration
@@ -10696,6 +10696,14 @@ class Me {
10696
10696
  if (n) return n;
10697
10697
  }
10698
10698
  }
10699
+ /**
10700
+ * Checks if a font is already loaded in the system
10701
+ * @param fontName - The name of the font to check
10702
+ * @returns True if the font is loaded, false otherwise
10703
+ */
10704
+ isFontLoaded(e) {
10705
+ return this.fontMap.has(e.toLowerCase());
10706
+ }
10699
10707
  /**
10700
10708
  * Records a font that was requested but not found
10701
10709
  * @param fontName - The name of the font that was not found
@@ -10761,7 +10769,7 @@ class Me {
10761
10769
  this.fontMap.clear();
10762
10770
  }
10763
10771
  }
10764
- class bl {
10772
+ class Sl {
10765
10773
  /**
10766
10774
  * Creates a new instance of DefaultFontLoader
10767
10775
  */
@@ -10797,21 +10805,44 @@ class bl {
10797
10805
  return this._avaiableFonts;
10798
10806
  }
10799
10807
  /**
10800
- * Loads the specified fonts into the system.
10801
- * If no font names are provided, loads all available fonts.
10808
+ * Loads the specified fonts into the system. If one font is already loaded,
10809
+ * the font will not be loaded again. If no font names are provided, just loads
10810
+ * all available fonts information (not fonts).
10802
10811
  * @param fontNames - Array of font names to load
10803
10812
  * @returns Promise that resolves to an array of FontLoadStatus objects
10804
10813
  */
10805
10814
  async load(e) {
10806
- e.length == 0 && await this.getAvaiableFonts();
10807
- const r = [];
10808
- return e.forEach((n) => {
10809
- const a = n.toLowerCase(), s = this._avaiableFonts.find((i) => i.name.findIndex((u) => u.toLowerCase() === a) >= 0);
10810
- s && r.push(s.url);
10811
- }), await Me.instance.loadFonts(r);
10815
+ if (e.length == 0)
10816
+ return await this.getAvaiableFonts(), [];
10817
+ const r = [], n = [], a = {};
10818
+ this._avaiableFonts.forEach((u) => {
10819
+ u.name.forEach((o) => {
10820
+ a[o.toLowerCase()] = u.url;
10821
+ });
10822
+ }), e.forEach((u) => {
10823
+ const o = u.toLowerCase(), l = a[o];
10824
+ l && (Ue.instance.isFontLoaded(o) ? n.push({
10825
+ fontName: o,
10826
+ url: l,
10827
+ status: !0
10828
+ }) : r.push(l));
10829
+ });
10830
+ let s = [];
10831
+ r.length > 0 && (s = await Ue.instance.loadFonts(r));
10832
+ const i = {};
10833
+ return [...n, ...s].forEach((u) => {
10834
+ i[u.fontName] = u;
10835
+ }), e.map((u) => {
10836
+ const o = u.toLowerCase();
10837
+ return i[o] || {
10838
+ fontName: o,
10839
+ url: a[o] || "",
10840
+ status: !1
10841
+ };
10842
+ });
10812
10843
  }
10813
10844
  }
10814
- var je = /* @__PURE__ */ ((t) => (t[t.LEFT_TO_RIGHT = 1] = "LEFT_TO_RIGHT", t[t.RIGHT_TO_LEFT = 2] = "RIGHT_TO_LEFT", t[t.TOP_TO_BOTTOM = 3] = "TOP_TO_BOTTOM", t[t.BOTTOM_TO_TOP = 4] = "BOTTOM_TO_TOP", t[t.BY_STYLE = 5] = "BY_STYLE", t))(je || {}), cl = /* @__PURE__ */ ((t) => (t[t.TopLeft = 1] = "TopLeft", t[t.TopCenter = 2] = "TopCenter", t[t.TopRight = 3] = "TopRight", t[t.MiddleLeft = 4] = "MiddleLeft", t[t.MiddleCenter = 5] = "MiddleCenter", t[t.MiddleRight = 6] = "MiddleRight", t[t.BottomLeft = 7] = "BottomLeft", t[t.BottomCenter = 8] = "BottomCenter", t[t.BottomRight = 9] = "BottomRight", t))(cl || {}), De = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.WORD = 1] = "WORD", t[t.STACK = 2] = "STACK", t[t.SPACE = 3] = "SPACE", t[t.NBSP = 4] = "NBSP", t[t.TABULATOR = 5] = "TABULATOR", t[t.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", t[t.NEW_COLUMN = 7] = "NEW_COLUMN", t[t.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", t[t.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", t))(De || {}), _e = /* @__PURE__ */ ((t) => (t[t.BOTTOM = 0] = "BOTTOM", t[t.MIDDLE = 1] = "MIDDLE", t[t.TOP = 2] = "TOP", t))(_e || {}), se = /* @__PURE__ */ ((t) => (t[t.DEFAULT = 0] = "DEFAULT", t[t.LEFT = 1] = "LEFT", t[t.RIGHT = 2] = "RIGHT", t[t.CENTER = 3] = "CENTER", t[t.JUSTIFIED = 4] = "JUSTIFIED", t[t.DISTRIBUTED = 5] = "DISTRIBUTED", t))(se || {});
10845
+ var je = /* @__PURE__ */ ((t) => (t[t.LEFT_TO_RIGHT = 1] = "LEFT_TO_RIGHT", t[t.RIGHT_TO_LEFT = 2] = "RIGHT_TO_LEFT", t[t.TOP_TO_BOTTOM = 3] = "TOP_TO_BOTTOM", t[t.BOTTOM_TO_TOP = 4] = "BOTTOM_TO_TOP", t[t.BY_STYLE = 5] = "BY_STYLE", t))(je || {}), cl = /* @__PURE__ */ ((t) => (t[t.TopLeft = 1] = "TopLeft", t[t.TopCenter = 2] = "TopCenter", t[t.TopRight = 3] = "TopRight", t[t.MiddleLeft = 4] = "MiddleLeft", t[t.MiddleCenter = 5] = "MiddleCenter", t[t.MiddleRight = 6] = "MiddleRight", t[t.BottomLeft = 7] = "BottomLeft", t[t.BottomCenter = 8] = "BottomCenter", t[t.BottomRight = 9] = "BottomRight", t))(cl || {}), Me = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.WORD = 1] = "WORD", t[t.STACK = 2] = "STACK", t[t.SPACE = 3] = "SPACE", t[t.NBSP = 4] = "NBSP", t[t.TABULATOR = 5] = "TABULATOR", t[t.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", t[t.NEW_COLUMN = 7] = "NEW_COLUMN", t[t.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", t[t.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", t))(Me || {}), _e = /* @__PURE__ */ ((t) => (t[t.BOTTOM = 0] = "BOTTOM", t[t.MIDDLE = 1] = "MIDDLE", t[t.TOP = 2] = "TOP", t))(_e || {}), se = /* @__PURE__ */ ((t) => (t[t.DEFAULT = 0] = "DEFAULT", t[t.LEFT = 1] = "LEFT", t[t.RIGHT = 2] = "RIGHT", t[t.CENTER = 3] = "CENTER", t[t.JUSTIFIED = 4] = "JUSTIFIED", t[t.DISTRIBUTED = 5] = "DISTRIBUTED", t))(se || {});
10815
10846
  const hl = {
10816
10847
  c: "Ø",
10817
10848
  d: "°",
@@ -10824,7 +10855,14 @@ const hl = {
10824
10855
  d: 5
10825
10856
  /* DISTRIBUTED */
10826
10857
  };
10827
- class pl {
10858
+ function pl(t, e = !1) {
10859
+ const r = /* @__PURE__ */ new Set(), n = /\\[fF](.*?)[;|]/g;
10860
+ return [...t.matchAll(n)].forEach((a) => {
10861
+ let s = a[1].toLowerCase();
10862
+ e && (s = s.replace(/\.(ttf|otf|woff|shx)$/, "")), r.add(s);
10863
+ }), r;
10864
+ }
10865
+ class dl {
10828
10866
  /**
10829
10867
  * Creates a new MTextParser instance
10830
10868
  * @param content - The MText content to parse
@@ -11802,16 +11840,25 @@ function pn(t) {
11802
11840
  }
11803
11841
  return a !== void 0 && (u.gpuType = a), u;
11804
11842
  }
11805
- const dl = /* @__PURE__ */ new R.Vector3(), vl = 1.666666;
11843
+ const vl = /* @__PURE__ */ new R.Vector3(), gl = 1.666666;
11806
11844
  class hr {
11845
+ /**
11846
+ * Creates a new Context instance with optional initial values.
11847
+ * @param init - Partial object containing initial values for context properties
11848
+ */
11807
11849
  constructor(e) {
11808
11850
  this.font = "", this.fontScaleFactor = 1, this.fontSize = 1, this.fontSizeScaleFactor = 1, this.color = 16777215, this.underline = !1, this.overline = !1, this.strikeThrough = !1, this.obliqueAngle = 0, this.italic = !1, this.bold = !1, this.widthFactor = 1, this.wordSpace = 1, this.blankWidth = 0, this.horizontalAlignment = se.LEFT, Object.assign(this, e);
11809
11851
  }
11852
+ /**
11853
+ * Creates a deep copy of the current context.
11854
+ * This is useful for saving state before applying formatting changes.
11855
+ * @returns A new Context instance with identical property values
11856
+ */
11810
11857
  clone() {
11811
11858
  return new hr({ ...this });
11812
11859
  }
11813
11860
  }
11814
- class gl {
11861
+ class yl {
11815
11862
  /**
11816
11863
  * Construct one instance of this class and initialize some properties with default values.
11817
11864
  * @param style Input text style
@@ -11928,7 +11975,7 @@ class gl {
11928
11975
  * The height of current line of texts
11929
11976
  */
11930
11977
  get currentLineHeight() {
11931
- return this.defaultLineSpaceFactor * this.currentFontSize * vl + this.currentMaxFontSize;
11978
+ return this.defaultLineSpaceFactor * this.currentFontSize * gl + this.currentMaxFontSize;
11932
11979
  }
11933
11980
  /**
11934
11981
  * The maximum font size in current line. Characters in one line may have different font and font
@@ -11939,7 +11986,10 @@ class gl {
11939
11986
  return this._maxFontSize;
11940
11987
  }
11941
11988
  /**
11942
- * The current space setting between two characters
11989
+ * The current space setting between two characters. The meaning of this value is as follows.
11990
+ * - 1: no extra spacing (default tracking)
11991
+ * - 1.2: increases spacing by 20% of the text height
11992
+ * - 0.8: decreases spacing by 20% of the text height
11943
11993
  */
11944
11994
  get currentWordSpace() {
11945
11995
  return this._currentContext.wordSpace;
@@ -12009,7 +12059,7 @@ class gl {
12009
12059
  e.changes.capHeight && (e.changes.capHeight.isRelative ? this.changeFontSizeScaleFactor(e.changes.capHeight.value) : this.changeFontHeight(e.changes.capHeight.value));
12010
12060
  break;
12011
12061
  case "T":
12012
- e.changes.charTrackingFactor && (this._currentContext.wordSpace = e.changes.charTrackingFactor.value);
12062
+ e.changes.charTrackingFactor && (e.changes.charTrackingFactor.isRelative ? this._currentContext.wordSpace = e.changes.charTrackingFactor.value + 1 : this._currentContext.wordSpace = e.changes.charTrackingFactor.value);
12013
12063
  break;
12014
12064
  case "q":
12015
12065
  e.changes.paragraph && e.changes.paragraph.align && (this._currentContext.horizontalAlignment = e.changes.paragraph.align);
@@ -12044,17 +12094,17 @@ class gl {
12044
12094
  processText(e) {
12045
12095
  const r = [], n = [], a = new R.Group();
12046
12096
  for (const s of e)
12047
- if (s.type === De.NEW_PARAGRAPH)
12097
+ if (s.type === Me.NEW_PARAGRAPH)
12048
12098
  this.startNewLine(), this.processGeometries(r, n, a);
12049
- else if (s.type === De.WORD) {
12099
+ else if (s.type === Me.WORD) {
12050
12100
  const i = s.data;
12051
12101
  Array.isArray(i) ? i.forEach((u) => this.processWord(u, r, n)) : typeof i == "string" && i.length > 0 && this.processWord(i, r, n), this.processGeometries(r, n, a);
12052
- } else if (s.type === De.SPACE)
12102
+ } else if (s.type === Me.SPACE)
12053
12103
  this.processBlank();
12054
- else if (s.type === De.PROPERTIES_CHANGED) {
12104
+ else if (s.type === Me.PROPERTIES_CHANGED) {
12055
12105
  const i = s.data;
12056
- i.command === void 0 ? this._contextStack.length > 0 && (this._currentContext = this._contextStack.pop()) : (this._contextStack.push(this._currentContext.clone()), this.processFormat(i)), this.processGeometries(r, n, a);
12057
- } else s.type === De.STACK && (this.processStack(s.data, r, n), this.processGeometries(r, n, a));
12106
+ i.command === void 0 ? this._contextStack.length > 0 && (this._currentContext = this._contextStack.pop()) : (this._contextStack.length === 0 && this._contextStack.push(this._currentContext.clone()), this.processFormat(i)), this.processGeometries(r, n, a);
12107
+ } else s.type === Me.STACK && (this.processStack(s.data, r, n), this.processGeometries(r, n, a));
12058
12108
  return (r.length > 0 || n.length > 0) && this.processGeometries(r, n, a), a;
12059
12109
  }
12060
12110
  processGeometries(e, r, n) {
@@ -12221,7 +12271,7 @@ class gl {
12221
12271
  if (e.forEach((n, a) => {
12222
12272
  n.boundingBox || n.computeBoundingBox(), a === 0 ? r = n.boundingBox : r.union(n.boundingBox);
12223
12273
  }), r) {
12224
- const n = r.getSize(dl);
12274
+ const n = r.getSize(vl);
12225
12275
  switch (this.currentHorizontalAlignment) {
12226
12276
  case se.LEFT:
12227
12277
  break;
@@ -12283,7 +12333,25 @@ class gl {
12283
12333
  }
12284
12334
  }
12285
12335
  const Mt = /* @__PURE__ */ new R.Vector3(), we = /* @__PURE__ */ new R.Vector3(), Bt = /* @__PURE__ */ new R.Vector3(), Pt = /* @__PURE__ */ new R.Quaternion(), It = /* @__PURE__ */ new R.Matrix4(), dn = /* @__PURE__ */ new R.Matrix4(), vn = /* @__PURE__ */ new R.Vector3(1, 0, 0);
12286
- class Sl extends R.Object3D {
12336
+ class kl extends R.Object3D {
12337
+ /**
12338
+ * Extracts all unique font names used in an MText string.
12339
+ * This function searches for font commands in the format \f{fontname}| or \f{fontname}; and returns a set of unique font names.
12340
+ * Font names are converted to lowercase to ensure case-insensitive uniqueness.
12341
+ *
12342
+ * @param mtext - The MText string to analyze for font names
12343
+ * @param removeExtension - Whether to remove font file extensions (e.g., .ttf, .shx) from font names. Defaults to false.
12344
+ * @returns A Set containing all unique font names found in the MText string, converted to lowercase
12345
+ * @example
12346
+ * ```ts
12347
+ * const mtext = "\\fArial.ttf|Hello\\fTimes New Roman.otf|World";
12348
+ * const fonts = getFonts(mtext, true);
12349
+ * // Returns: Set(2) { "arial", "times new roman" }
12350
+ * ```
12351
+ */
12352
+ static getFonts(e, r = !1) {
12353
+ return pl(e, r);
12354
+ }
12287
12355
  /**
12288
12356
  * Creates a new instance of MText.
12289
12357
  * @param text - The MText data containing text content and properties
@@ -12410,7 +12478,7 @@ class Sl extends R.Object3D {
12410
12478
  removeFontExtension: !0
12411
12479
  }, c = new mt();
12412
12480
  c.fontFace.family = r.font, c.capHeight = { value: e.height || 1, isRelative: !0 }, c.widthFactor = { value: e.widthFactor ?? 1, isRelative: !0 }, c.align = s, c.paragraph.align = a;
12413
- const h = new pl(e.text, c, !0).parse(), p = new gl(
12481
+ const h = new dl(e.text, c, !0).parse(), p = new yl(
12414
12482
  r,
12415
12483
  this.styleManager,
12416
12484
  this.fontManager,
@@ -12480,7 +12548,7 @@ class Sl extends R.Object3D {
12480
12548
  this.getBoxes(n[a], r);
12481
12549
  }
12482
12550
  }
12483
- class kl {
12551
+ class Tl {
12484
12552
  constructor() {
12485
12553
  this.lineBasicMaterials = {}, this.meshBasicMaterials = {}, this.unsupportedTextStyles = {};
12486
12554
  }
@@ -12498,12 +12566,12 @@ class kl {
12498
12566
  export {
12499
12567
  gn as BaseFont,
12500
12568
  yn as BaseTextShape,
12501
- bl as DefaultFontLoader,
12569
+ Sl as DefaultFontLoader,
12502
12570
  pr as EventManager,
12503
12571
  Se as FontFactory,
12504
- Me as FontManager,
12505
- Sl as MText,
12572
+ Ue as FontManager,
12573
+ kl as MText,
12506
12574
  cl as MTextAttachmentPoint,
12507
12575
  je as MTextFlowDirection,
12508
- kl as StyleManager
12576
+ Tl as StyleManager
12509
12577
  };