@mlightcad/mtext-renderer 0.12.2 → 0.12.3

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.
@@ -3103,7 +3103,7 @@ class mt {
3103
3103
  }
3104
3104
  lookAt(t, e, s) {
3105
3105
  const i = this.elements;
3106
- return Vt.subVectors(t, e), Vt.lengthSq() === 0 && (Vt.z = 1), Vt.normalize(), Ne.crossVectors(s, Vt), Ne.lengthSq() === 0 && (Math.abs(s.z) === 1 ? Vt.x += 1e-4 : Vt.z += 1e-4, Vt.normalize(), Ne.crossVectors(s, Vt)), Ne.normalize(), Us.crossVectors(Vt, Ne), i[0] = Ne.x, i[4] = Us.x, i[8] = Vt.x, i[1] = Ne.y, i[5] = Us.y, i[9] = Vt.y, i[2] = Ne.z, i[6] = Us.z, i[10] = Vt.z, this;
3106
+ return Wt.subVectors(t, e), Wt.lengthSq() === 0 && (Wt.z = 1), Wt.normalize(), Ne.crossVectors(s, Wt), Ne.lengthSq() === 0 && (Math.abs(s.z) === 1 ? Wt.x += 1e-4 : Wt.z += 1e-4, Wt.normalize(), Ne.crossVectors(s, Wt)), Ne.normalize(), Us.crossVectors(Wt, Ne), i[0] = Ne.x, i[4] = Us.x, i[8] = Wt.x, i[1] = Ne.y, i[5] = Us.y, i[9] = Wt.y, i[2] = Ne.z, i[6] = Us.z, i[10] = Wt.z, this;
3107
3107
  }
3108
3108
  multiply(t) {
3109
3109
  return this.multiplyMatrices(this, t);
@@ -3357,7 +3357,7 @@ class mt {
3357
3357
  return t[e] = s[0], t[e + 1] = s[1], t[e + 2] = s[2], t[e + 3] = s[3], t[e + 4] = s[4], t[e + 5] = s[5], t[e + 6] = s[6], t[e + 7] = s[7], t[e + 8] = s[8], t[e + 9] = s[9], t[e + 10] = s[10], t[e + 11] = s[11], t[e + 12] = s[12], t[e + 13] = s[13], t[e + 14] = s[14], t[e + 15] = s[15], t;
3358
3358
  }
3359
3359
  }
3360
- const Tn = /* @__PURE__ */ new E(), se = /* @__PURE__ */ new mt(), bu = /* @__PURE__ */ new E(0, 0, 0), vu = /* @__PURE__ */ new E(1, 1, 1), Ne = /* @__PURE__ */ new E(), Us = /* @__PURE__ */ new E(), Vt = /* @__PURE__ */ new E(), no = /* @__PURE__ */ new mt(), so = /* @__PURE__ */ new gn();
3360
+ const Tn = /* @__PURE__ */ new E(), se = /* @__PURE__ */ new mt(), bu = /* @__PURE__ */ new E(0, 0, 0), vu = /* @__PURE__ */ new E(1, 1, 1), Ne = /* @__PURE__ */ new E(), Us = /* @__PURE__ */ new E(), Wt = /* @__PURE__ */ new E(), no = /* @__PURE__ */ new mt(), so = /* @__PURE__ */ new gn();
3361
3361
  class ws {
3362
3362
  constructor(t = 0, e = 0, s = 0, i = ws.DEFAULT_ORDER) {
3363
3363
  this.isEuler = !0, this._x = t, this._y = e, this._z = s, this._order = i;
@@ -3480,9 +3480,9 @@ class Su {
3480
3480
  }
3481
3481
  let wu = 0;
3482
3482
  const io = /* @__PURE__ */ new E(), Fn = /* @__PURE__ */ new gn(), Ae = /* @__PURE__ */ new mt(), Ps = /* @__PURE__ */ new E(), ts = /* @__PURE__ */ new E(), Cu = /* @__PURE__ */ new E(), Tu = /* @__PURE__ */ new gn(), ro = /* @__PURE__ */ new E(1, 0, 0), ao = /* @__PURE__ */ new E(0, 1, 0), oo = /* @__PURE__ */ new E(0, 0, 1), co = { type: "added" }, Fu = { type: "removed" }, An = { type: "childadded", child: null }, er = { type: "childremoved", child: null };
3483
- class jt extends Ii {
3483
+ class Xt extends Ii {
3484
3484
  constructor() {
3485
- super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: wu++ }), this.uuid = Yn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = jt.DEFAULT_UP.clone();
3485
+ super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: wu++ }), this.uuid = Yn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Xt.DEFAULT_UP.clone();
3486
3486
  const t = new E(), e = new ws(), s = new gn(), i = new E(1, 1, 1);
3487
3487
  function r() {
3488
3488
  s.setFromEuler(e, !1);
@@ -3517,7 +3517,7 @@ class jt extends Ii {
3517
3517
  normalMatrix: {
3518
3518
  value: new tn()
3519
3519
  }
3520
- }), this.matrix = new mt(), this.matrixWorld = new mt(), this.matrixAutoUpdate = jt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new Su(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
3520
+ }), this.matrix = new mt(), this.matrixWorld = new mt(), this.matrixAutoUpdate = Xt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new Su(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
3521
3521
  }
3522
3522
  onBeforeShadow() {
3523
3523
  }
@@ -3777,9 +3777,9 @@ class jt extends Ii {
3777
3777
  return this;
3778
3778
  }
3779
3779
  }
3780
- jt.DEFAULT_UP = /* @__PURE__ */ new E(0, 1, 0);
3781
- jt.DEFAULT_MATRIX_AUTO_UPDATE = !0;
3782
- jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
3780
+ Xt.DEFAULT_UP = /* @__PURE__ */ new E(0, 1, 0);
3781
+ Xt.DEFAULT_MATRIX_AUTO_UPDATE = !0;
3782
+ Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
3783
3783
  const ie = /* @__PURE__ */ new E(), ke = /* @__PURE__ */ new E(), nr = /* @__PURE__ */ new E(), Ee = /* @__PURE__ */ new E(), kn = /* @__PURE__ */ new E(), En = /* @__PURE__ */ new E(), ho = /* @__PURE__ */ new E(), sr = /* @__PURE__ */ new E(), ir = /* @__PURE__ */ new E(), rr = /* @__PURE__ */ new E(), ar = /* @__PURE__ */ new Ss(), or = /* @__PURE__ */ new Ss(), cr = /* @__PURE__ */ new Ss();
3784
3784
  class ce {
3785
3785
  constructor(t = new E(), e = new E(), s = new E()) {
@@ -4475,7 +4475,7 @@ class un extends le {
4475
4475
  }
4476
4476
  }
4477
4477
  let Mu = 0;
4478
- const $t = /* @__PURE__ */ new mt(), lr = /* @__PURE__ */ new jt(), Mn = /* @__PURE__ */ new E(), Wt = /* @__PURE__ */ new Ft(), es = /* @__PURE__ */ new Ft(), wt = /* @__PURE__ */ new E();
4478
+ const Zt = /* @__PURE__ */ new mt(), lr = /* @__PURE__ */ new Xt(), Mn = /* @__PURE__ */ new E(), qt = /* @__PURE__ */ new Ft(), es = /* @__PURE__ */ new Ft(), wt = /* @__PURE__ */ new E();
4479
4479
  class Rt extends Ii {
4480
4480
  constructor() {
4481
4481
  super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: Mu++ }), this.uuid = Yn(), this.name = "", this.type = "BufferGeometry", this.index = null, this.indirect = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {};
@@ -4529,22 +4529,22 @@ class Rt extends Ii {
4529
4529
  return i !== void 0 && (i.transformDirection(t), i.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
4530
4530
  }
4531
4531
  applyQuaternion(t) {
4532
- return $t.makeRotationFromQuaternion(t), this.applyMatrix4($t), this;
4532
+ return Zt.makeRotationFromQuaternion(t), this.applyMatrix4(Zt), this;
4533
4533
  }
4534
4534
  rotateX(t) {
4535
- return $t.makeRotationX(t), this.applyMatrix4($t), this;
4535
+ return Zt.makeRotationX(t), this.applyMatrix4(Zt), this;
4536
4536
  }
4537
4537
  rotateY(t) {
4538
- return $t.makeRotationY(t), this.applyMatrix4($t), this;
4538
+ return Zt.makeRotationY(t), this.applyMatrix4(Zt), this;
4539
4539
  }
4540
4540
  rotateZ(t) {
4541
- return $t.makeRotationZ(t), this.applyMatrix4($t), this;
4541
+ return Zt.makeRotationZ(t), this.applyMatrix4(Zt), this;
4542
4542
  }
4543
4543
  translate(t, e, s) {
4544
- return $t.makeTranslation(t, e, s), this.applyMatrix4($t), this;
4544
+ return Zt.makeTranslation(t, e, s), this.applyMatrix4(Zt), this;
4545
4545
  }
4546
4546
  scale(t, e, s) {
4547
- return $t.makeScale(t, e, s), this.applyMatrix4($t), this;
4547
+ return Zt.makeScale(t, e, s), this.applyMatrix4(Zt), this;
4548
4548
  }
4549
4549
  lookAt(t) {
4550
4550
  return lr.lookAt(t), lr.updateMatrix(), this.applyMatrix4(lr.matrix), this;
@@ -4585,7 +4585,7 @@ class Rt extends Ii {
4585
4585
  if (this.boundingBox.setFromBufferAttribute(t), e)
4586
4586
  for (let s = 0, i = e.length; s < i; s++) {
4587
4587
  const r = e[s];
4588
- Wt.setFromBufferAttribute(r), this.morphTargetsRelative ? (wt.addVectors(this.boundingBox.min, Wt.min), this.boundingBox.expandByPoint(wt), wt.addVectors(this.boundingBox.max, Wt.max), this.boundingBox.expandByPoint(wt)) : (this.boundingBox.expandByPoint(Wt.min), this.boundingBox.expandByPoint(Wt.max));
4588
+ qt.setFromBufferAttribute(r), this.morphTargetsRelative ? (wt.addVectors(this.boundingBox.min, qt.min), this.boundingBox.expandByPoint(wt), wt.addVectors(this.boundingBox.max, qt.max), this.boundingBox.expandByPoint(wt)) : (this.boundingBox.expandByPoint(qt.min), this.boundingBox.expandByPoint(qt.max));
4589
4589
  }
4590
4590
  } else
4591
4591
  this.boundingBox.makeEmpty();
@@ -4600,12 +4600,12 @@ class Rt extends Ii {
4600
4600
  }
4601
4601
  if (t) {
4602
4602
  const s = this.boundingSphere.center;
4603
- if (Wt.setFromBufferAttribute(t), e)
4603
+ if (qt.setFromBufferAttribute(t), e)
4604
4604
  for (let r = 0, a = e.length; r < a; r++) {
4605
4605
  const o = e[r];
4606
- es.setFromBufferAttribute(o), this.morphTargetsRelative ? (wt.addVectors(Wt.min, es.min), Wt.expandByPoint(wt), wt.addVectors(Wt.max, es.max), Wt.expandByPoint(wt)) : (Wt.expandByPoint(es.min), Wt.expandByPoint(es.max));
4606
+ es.setFromBufferAttribute(o), this.morphTargetsRelative ? (wt.addVectors(qt.min, es.min), qt.expandByPoint(wt), wt.addVectors(qt.max, es.max), qt.expandByPoint(wt)) : (qt.expandByPoint(es.min), qt.expandByPoint(es.max));
4607
4607
  }
4608
- Wt.getCenter(s);
4608
+ qt.getCenter(s);
4609
4609
  let i = 0;
4610
4610
  for (let r = 0, a = t.count; r < a; r++)
4611
4611
  wt.fromBufferAttribute(t, r), i = Math.max(i, s.distanceToSquared(wt));
@@ -4805,7 +4805,7 @@ class Rt extends Ii {
4805
4805
  }
4806
4806
  }
4807
4807
  const lo = /* @__PURE__ */ new mt(), rn = /* @__PURE__ */ new fh(), Hs = /* @__PURE__ */ new fa(), uo = /* @__PURE__ */ new E(), Gs = /* @__PURE__ */ new E(), Vs = /* @__PURE__ */ new E(), Ws = /* @__PURE__ */ new E(), ur = /* @__PURE__ */ new E(), qs = /* @__PURE__ */ new E(), fo = /* @__PURE__ */ new E(), js = /* @__PURE__ */ new E();
4808
- class us extends jt {
4808
+ class us extends Xt {
4809
4809
  constructor(t = new Rt(), e = new gh()) {
4810
4810
  super(), this.isMesh = !0, this.type = "Mesh", this.geometry = t, this.material = e, this.updateMorphTargets();
4811
4811
  }
@@ -4917,7 +4917,7 @@ class mh extends dh {
4917
4917
  }
4918
4918
  }
4919
4919
  const gi = /* @__PURE__ */ new E(), mi = /* @__PURE__ */ new E(), po = /* @__PURE__ */ new mt(), ns = /* @__PURE__ */ new fh(), Ys = /* @__PURE__ */ new fa(), fr = /* @__PURE__ */ new E(), go = /* @__PURE__ */ new E();
4920
- class Wr extends jt {
4920
+ class Wr extends Xt {
4921
4921
  constructor(t = new Rt(), e = new mh()) {
4922
4922
  super(), this.isLine = !0, this.type = "Line", this.geometry = t, this.material = e, this.updateMorphTargets();
4923
4923
  }
@@ -5011,7 +5011,7 @@ class yh extends Wr {
5011
5011
  return this;
5012
5012
  }
5013
5013
  }
5014
- class xo extends jt {
5014
+ class xo extends Xt {
5015
5015
  constructor() {
5016
5016
  super(), this.isGroup = !0, this.type = "Group";
5017
5017
  }
@@ -7018,7 +7018,7 @@ const on = {
7018
7018
  }
7019
7019
  ]
7020
7020
  }
7021
- ], qt = class qt {
7021
+ ], jt = class jt {
7022
7022
  constructor() {
7023
7023
  this.isClosing = !1, typeof window < "u" && window.addEventListener("unload", () => {
7024
7024
  this.close();
@@ -7028,7 +7028,7 @@ const on = {
7028
7028
  * Returns the singleton instance of the FontCacheManager
7029
7029
  */
7030
7030
  static get instance() {
7031
- return qt._instance || (qt._instance = new qt()), qt._instance;
7031
+ return jt._instance || (jt._instance = new jt()), jt._instance;
7032
7032
  }
7033
7033
  /**
7034
7034
  * Sets a font in the cache
@@ -7126,15 +7126,15 @@ const on = {
7126
7126
  * Use with caution as this operation cannot be undone.
7127
7127
  */
7128
7128
  async destroy() {
7129
- this.close(), await indexedDB.deleteDatabase(qt.DATABASE_NAME), qt._instance = void 0;
7129
+ this.close(), await indexedDB.deleteDatabase(jt.DATABASE_NAME), jt._instance = void 0;
7130
7130
  }
7131
7131
  // Private methods for database management
7132
7132
  async getDatabase() {
7133
7133
  if (this.isClosing)
7134
7134
  throw new Error("Cannot perform operation while database is closing");
7135
7135
  return this.db ? this.db : (this.db = await Ff(
7136
- qt.DATABASE_NAME,
7137
- qt.DATABASE_VERSION,
7136
+ jt.DATABASE_NAME,
7137
+ jt.DATABASE_VERSION,
7138
7138
  {
7139
7139
  upgrade: (t, e, s) => this.handleUpgrade(t, e, s),
7140
7140
  blocked() {
@@ -7143,7 +7143,7 @@ const on = {
7143
7143
  );
7144
7144
  },
7145
7145
  blocking() {
7146
- console.warn("Database blocking newer version - closing connection"), qt.instance.close();
7146
+ console.warn("Database blocking newer version - closing connection"), jt.instance.close();
7147
7147
  }
7148
7148
  }
7149
7149
  ), this.db);
@@ -7171,8 +7171,8 @@ const on = {
7171
7171
  t.objectStoreNames.contains(s.name) || t.createObjectStore(s.name, { keyPath: s.keyPath });
7172
7172
  }
7173
7173
  };
7174
- qt.DATABASE_NAME = "mlightcad", qt.DATABASE_VERSION = xr[xr.length - 1].version;
7175
- let qe = qt;
7174
+ jt.DATABASE_NAME = "mlightcad", jt.DATABASE_VERSION = xr[xr.length - 1].version;
7175
+ let qe = jt;
7176
7176
  const Lf = 512;
7177
7177
  function _f(n, t) {
7178
7178
  return (n + t) * Lf;
@@ -12557,10 +12557,10 @@ function ra(n, t, e, s, i) {
12557
12557
  var Q = l.pop(), kt = O ? O.length : F.itemVariationSubtables[w].regionIndexes.length, Pt = Q * kt, Nt = l.length - Pt, zt = Nt - Q;
12558
12558
  if (O)
12559
12559
  for (let Ce = 0; Ce < Q; Ce++) {
12560
- var Gt = l[zt + Ce];
12560
+ var Vt = l[zt + Ce];
12561
12561
  for (let C = 0; C < kt; C++)
12562
- Gt += O[C] * l[Nt++];
12563
- l[zt + Ce] = Gt;
12562
+ Vt += O[C] * l[Nt++];
12563
+ l[zt + Ce] = Vt;
12564
12564
  }
12565
12565
  for (; Pt--; )
12566
12566
  l.pop();
@@ -14715,7 +14715,7 @@ function c0(n) {
14715
14715
  dy: n.dy
14716
14716
  };
14717
14717
  }
14718
- function Xt(n) {
14718
+ function Yt(n) {
14719
14719
  Ui.call(this, n, "gsub");
14720
14720
  }
14721
14721
  function Aa(n, t, e) {
@@ -14728,8 +14728,8 @@ function Aa(n, t, e) {
14728
14728
  if (e)
14729
14729
  return s.push(e), e;
14730
14730
  }
14731
- Xt.prototype = Ui.prototype;
14732
- Xt.prototype.createDefaultTable = function() {
14731
+ Yt.prototype = Ui.prototype;
14732
+ Yt.prototype.createDefaultTable = function() {
14733
14733
  return {
14734
14734
  version: 1,
14735
14735
  scripts: [{
@@ -14743,7 +14743,7 @@ Xt.prototype.createDefaultTable = function() {
14743
14743
  lookups: []
14744
14744
  };
14745
14745
  };
14746
- Xt.prototype.getSingle = function(n, t, e) {
14746
+ Yt.prototype.getSingle = function(n, t, e) {
14747
14747
  const s = [], i = this.getLookupTables(t, e, n, 1);
14748
14748
  for (let r = 0; r < i.length; r++) {
14749
14749
  const a = i[r].subtables;
@@ -14765,7 +14765,7 @@ Xt.prototype.getSingle = function(n, t, e) {
14765
14765
  }
14766
14766
  return s;
14767
14767
  };
14768
- Xt.prototype.getMultiple = function(n, t, e) {
14768
+ Yt.prototype.getMultiple = function(n, t, e) {
14769
14769
  const s = [], i = this.getLookupTables(t, e, n, 2);
14770
14770
  for (let r = 0; r < i.length; r++) {
14771
14771
  const a = i[r].subtables;
@@ -14780,7 +14780,7 @@ Xt.prototype.getMultiple = function(n, t, e) {
14780
14780
  }
14781
14781
  return s;
14782
14782
  };
14783
- Xt.prototype.getAlternates = function(n, t, e) {
14783
+ Yt.prototype.getAlternates = function(n, t, e) {
14784
14784
  const s = [], i = this.getLookupTables(t, e, n, 3);
14785
14785
  for (let r = 0; r < i.length; r++) {
14786
14786
  const a = i[r].subtables;
@@ -14792,7 +14792,7 @@ Xt.prototype.getAlternates = function(n, t, e) {
14792
14792
  }
14793
14793
  return s;
14794
14794
  };
14795
- Xt.prototype.getLigatures = function(n, t, e) {
14795
+ Yt.prototype.getLigatures = function(n, t, e) {
14796
14796
  const s = [], i = this.getLookupTables(t, e, n, 4);
14797
14797
  for (let r = 0; r < i.length; r++) {
14798
14798
  const a = i[r].subtables;
@@ -14812,7 +14812,7 @@ Xt.prototype.getLigatures = function(n, t, e) {
14812
14812
  }
14813
14813
  return s;
14814
14814
  };
14815
- Xt.prototype.addSingle = function(n, t, e, s) {
14815
+ Yt.prototype.addSingle = function(n, t, e, s) {
14816
14816
  const i = this.getLookupTables(e, s, n, 1, !0)[0], r = Aa(i, 2, {
14817
14817
  // lookup type 1 subtable, format 2, coverage format 1
14818
14818
  substFormat: 2,
@@ -14824,7 +14824,7 @@ Xt.prototype.addSingle = function(n, t, e, s) {
14824
14824
  let o = this.binSearch(r.coverage.glyphs, a);
14825
14825
  o < 0 && (o = -1 - o, r.coverage.glyphs.splice(o, 0, a), r.substitute.splice(o, 0, 0)), r.substitute[o] = t.by;
14826
14826
  };
14827
- Xt.prototype.addMultiple = function(n, t, e, s) {
14827
+ Yt.prototype.addMultiple = function(n, t, e, s) {
14828
14828
  V.assert(t.by instanceof Array && t.by.length > 1, 'Multiple: "by" must be an array of two or more ids');
14829
14829
  const i = this.getLookupTables(e, s, n, 2, !0)[0], r = Aa(i, 1, {
14830
14830
  // lookup type 2 subtable, format 1, coverage format 1
@@ -14837,7 +14837,7 @@ Xt.prototype.addMultiple = function(n, t, e, s) {
14837
14837
  let o = this.binSearch(r.coverage.glyphs, a);
14838
14838
  o < 0 && (o = -1 - o, r.coverage.glyphs.splice(o, 0, a), r.sequences.splice(o, 0, 0)), r.sequences[o] = t.by;
14839
14839
  };
14840
- Xt.prototype.addAlternate = function(n, t, e, s) {
14840
+ Yt.prototype.addAlternate = function(n, t, e, s) {
14841
14841
  const i = this.getLookupTables(e, s, n, 3, !0)[0], r = Aa(i, 1, {
14842
14842
  // lookup type 3 subtable, format 1, coverage format 1
14843
14843
  substFormat: 1,
@@ -14849,7 +14849,7 @@ Xt.prototype.addAlternate = function(n, t, e, s) {
14849
14849
  let o = this.binSearch(r.coverage.glyphs, a);
14850
14850
  o < 0 && (o = -1 - o, r.coverage.glyphs.splice(o, 0, a), r.alternateSets.splice(o, 0, 0)), r.alternateSets[o] = t.by;
14851
14851
  };
14852
- Xt.prototype.addLigature = function(n, t, e, s) {
14852
+ Yt.prototype.addLigature = function(n, t, e, s) {
14853
14853
  const i = this.getLookupTables(e, s, n, 4, !0)[0];
14854
14854
  let r = i.subtables[0];
14855
14855
  r || (r = {
@@ -14872,7 +14872,7 @@ Xt.prototype.addLigature = function(n, t, e, s) {
14872
14872
  } else
14873
14873
  h = -1 - h, r.coverage.glyphs.splice(h, 0, a), r.ligatureSets.splice(h, 0, [c]);
14874
14874
  };
14875
- Xt.prototype.getFeature = function(n, t, e) {
14875
+ Yt.prototype.getFeature = function(n, t, e) {
14876
14876
  if (/ss\d\d/.test(n))
14877
14877
  return this.getSingle(n, t, e);
14878
14878
  switch (n) {
@@ -14889,7 +14889,7 @@ Xt.prototype.getFeature = function(n, t, e) {
14889
14889
  return this.getMultiple(n, t, e);
14890
14890
  }
14891
14891
  };
14892
- Xt.prototype.add = function(n, t, e, s) {
14892
+ Yt.prototype.add = function(n, t, e, s) {
14893
14893
  if (/ss\d\d/.test(n))
14894
14894
  return this.addSingle(n, t, e, s);
14895
14895
  switch (n) {
@@ -14904,7 +14904,7 @@ Xt.prototype.add = function(n, t, e, s) {
14904
14904
  return t.by instanceof Array ? this.addMultiple(n, t, e, s) : this.addLigature(n, t, e, s);
14905
14905
  }
14906
14906
  };
14907
- var h0 = Xt, El = class {
14907
+ var h0 = Yt, El = class {
14908
14908
  // private properties don't work with reify
14909
14909
  // @TODO: refactor once we migrated to ES6 modules, see https://github.com/opentypejs/opentype.js/pull/579
14910
14910
  // #font = null;
@@ -17669,7 +17669,7 @@ function ui(n) {
17669
17669
  function ig(n) {
17670
17670
  return /\s/.test(n);
17671
17671
  }
17672
- function Yt(n) {
17672
+ function $t(n) {
17673
17673
  this.font = n, this.features = {};
17674
17674
  }
17675
17675
  function je(n) {
@@ -17832,7 +17832,7 @@ function ug(n, t) {
17832
17832
  let e = Qe(n, t.coverage);
17833
17833
  return e === -1 ? null : t.sequences[e];
17834
17834
  }
17835
- Yt.prototype.getDefaultScriptFeaturesIndexes = function() {
17835
+ $t.prototype.getDefaultScriptFeaturesIndexes = function() {
17836
17836
  const n = this.font.tables.gsub.scripts;
17837
17837
  for (let t = 0; t < n.length; t++) {
17838
17838
  const e = n[t];
@@ -17840,7 +17840,7 @@ Yt.prototype.getDefaultScriptFeaturesIndexes = function() {
17840
17840
  }
17841
17841
  return [];
17842
17842
  };
17843
- Yt.prototype.getScriptFeaturesIndexes = function(n) {
17843
+ $t.prototype.getScriptFeaturesIndexes = function(n) {
17844
17844
  if (!this.font.tables.gsub) return [];
17845
17845
  if (!n) return this.getDefaultScriptFeaturesIndexes();
17846
17846
  const e = this.font.tables.gsub.scripts;
@@ -17860,7 +17860,7 @@ Yt.prototype.getScriptFeaturesIndexes = function(n) {
17860
17860
  }
17861
17861
  return this.getDefaultScriptFeaturesIndexes();
17862
17862
  };
17863
- Yt.prototype.mapTagsToFeatures = function(n, t) {
17863
+ $t.prototype.mapTagsToFeatures = function(n, t) {
17864
17864
  let e = {};
17865
17865
  for (let s = 0; s < n.length; s++) {
17866
17866
  const i = n[s].tag, r = n[s].feature;
@@ -17868,7 +17868,7 @@ Yt.prototype.mapTagsToFeatures = function(n, t) {
17868
17868
  }
17869
17869
  this.features[t].tags = e;
17870
17870
  };
17871
- Yt.prototype.getScriptFeatures = function(n) {
17871
+ $t.prototype.getScriptFeatures = function(n) {
17872
17872
  let t = this.features[n];
17873
17873
  if (Object.prototype.hasOwnProperty.call(this.features, n)) return t;
17874
17874
  const e = this.getScriptFeaturesIndexes(n);
@@ -17876,11 +17876,11 @@ Yt.prototype.getScriptFeatures = function(n) {
17876
17876
  const s = this.font.tables.gsub;
17877
17877
  return t = e.map((i) => s.features[i]), this.features[n] = t, this.mapTagsToFeatures(t, n), t;
17878
17878
  };
17879
- Yt.prototype.getSubstitutionType = function(n, t) {
17879
+ $t.prototype.getSubstitutionType = function(n, t) {
17880
17880
  const e = n.lookupType.toString(), s = t.substFormat.toString();
17881
17881
  return e + s;
17882
17882
  };
17883
- Yt.prototype.getLookupMethod = function(n, t) {
17883
+ $t.prototype.getLookupMethod = function(n, t) {
17884
17884
  let e = this.getSubstitutionType(n, t);
17885
17885
  switch (e) {
17886
17886
  case "11":
@@ -17924,7 +17924,7 @@ Yt.prototype.getLookupMethod = function(n, t) {
17924
17924
  );
17925
17925
  }
17926
17926
  };
17927
- Yt.prototype.lookupFeature = function(n) {
17927
+ $t.prototype.lookupFeature = function(n) {
17928
17928
  let t = n.contextParams, e = t.index;
17929
17929
  const s = this.getFeature({
17930
17930
  tag: n.tag,
@@ -17990,7 +17990,7 @@ Yt.prototype.lookupFeature = function(n) {
17990
17990
  }
17991
17991
  return r.length ? r : null;
17992
17992
  };
17993
- Yt.prototype.supports = function(n) {
17993
+ $t.prototype.supports = function(n) {
17994
17994
  if (!n.script) return !1;
17995
17995
  this.getScriptFeatures(n.script);
17996
17996
  const t = Object.prototype.hasOwnProperty.call(this.features, n.script);
@@ -17998,22 +17998,22 @@ Yt.prototype.supports = function(n) {
17998
17998
  const e = this.features[n.script].some((s) => s.tag === n.tag);
17999
17999
  return t && e;
18000
18000
  };
18001
- Yt.prototype.getLookupSubtables = function(n) {
18001
+ $t.prototype.getLookupSubtables = function(n) {
18002
18002
  return n.subtables || null;
18003
18003
  };
18004
- Yt.prototype.getLookupByIndex = function(n) {
18004
+ $t.prototype.getLookupByIndex = function(n) {
18005
18005
  return this.font.tables.gsub.lookups[n] || null;
18006
18006
  };
18007
- Yt.prototype.getFeatureLookups = function(n) {
18007
+ $t.prototype.getFeatureLookups = function(n) {
18008
18008
  return n.lookupListIndexes.map(this.getLookupByIndex.bind(this));
18009
18009
  };
18010
- Yt.prototype.getFeature = function(t) {
18010
+ $t.prototype.getFeature = function(t) {
18011
18011
  if (!this.font) return { FAIL: "No font was found" };
18012
18012
  Object.prototype.hasOwnProperty.call(this.features, t.script) || this.getScriptFeatures(t.script);
18013
18013
  const e = this.features[t.script];
18014
18014
  return e ? e.tags[t.tag] ? this.features[t.script].tags[t.tag] : null : { FAIL: `No feature for script ${t.script}` };
18015
18015
  };
18016
- var fg = Yt;
18016
+ var fg = $t;
18017
18017
  function pg(n) {
18018
18018
  const t = n.current, e = n.get(-1);
18019
18019
  return (
@@ -21795,7 +21795,7 @@ Oa.write = function(n, t, e, s, i, r) {
21795
21795
  throw new TypeError(
21796
21796
  "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof C
21797
21797
  );
21798
- if (Gt(C, ArrayBuffer) || C && Gt(C.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (Gt(C, SharedArrayBuffer) || C && Gt(C.buffer, SharedArrayBuffer)))
21798
+ if (Vt(C, ArrayBuffer) || C && Vt(C.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (Vt(C, SharedArrayBuffer) || C && Vt(C.buffer, SharedArrayBuffer)))
21799
21799
  return g(C, m, y);
21800
21800
  if (typeof C == "number")
21801
21801
  throw new TypeError(
@@ -21851,7 +21851,7 @@ Oa.write = function(n, t, e, s, i, r) {
21851
21851
  return y;
21852
21852
  }
21853
21853
  function d(C) {
21854
- if (Gt(C, Uint8Array)) {
21854
+ if (Vt(C, Uint8Array)) {
21855
21855
  var m = new Uint8Array(C);
21856
21856
  return g(m.buffer, m.byteOffset, m.byteLength);
21857
21857
  }
@@ -21886,7 +21886,7 @@ Oa.write = function(n, t, e, s, i, r) {
21886
21886
  o.isBuffer = function(m) {
21887
21887
  return m != null && m._isBuffer === !0 && m !== o.prototype;
21888
21888
  }, o.compare = function(m, y) {
21889
- if (Gt(m, Uint8Array) && (m = o.from(m, m.offset, m.byteLength)), Gt(y, Uint8Array) && (y = o.from(y, y.offset, y.byteLength)), !o.isBuffer(m) || !o.isBuffer(y))
21889
+ if (Vt(m, Uint8Array) && (m = o.from(m, m.offset, m.byteLength)), Vt(y, Uint8Array) && (y = o.from(y, y.offset, y.byteLength)), !o.isBuffer(m) || !o.isBuffer(y))
21890
21890
  throw new TypeError(
21891
21891
  'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
21892
21892
  );
@@ -21926,7 +21926,7 @@ Oa.write = function(n, t, e, s, i, r) {
21926
21926
  var k = o.allocUnsafe(y), L = 0;
21927
21927
  for (T = 0; T < m.length; ++T) {
21928
21928
  var B = m[T];
21929
- if (Gt(B, Uint8Array))
21929
+ if (Vt(B, Uint8Array))
21930
21930
  L + B.length > k.length ? o.from(B).copy(k, L) : Uint8Array.prototype.set.call(
21931
21931
  k,
21932
21932
  B,
@@ -21943,7 +21943,7 @@ Oa.write = function(n, t, e, s, i, r) {
21943
21943
  function v(C, m) {
21944
21944
  if (o.isBuffer(C))
21945
21945
  return C.length;
21946
- if (ArrayBuffer.isView(C) || Gt(C, ArrayBuffer))
21946
+ if (ArrayBuffer.isView(C) || Vt(C, ArrayBuffer))
21947
21947
  return C.byteLength;
21948
21948
  if (typeof C != "string")
21949
21949
  throw new TypeError(
@@ -22040,7 +22040,7 @@ Oa.write = function(n, t, e, s, i, r) {
22040
22040
  var m = "", y = n.INSPECT_MAX_BYTES;
22041
22041
  return m = this.toString("hex", 0, y).replace(/(.{2})/g, "$1 ").trim(), this.length > y && (m += " ... "), "<Buffer " + m + ">";
22042
22042
  }, s && (o.prototype[s] = o.prototype.inspect), o.prototype.compare = function(m, y, T, k, L) {
22043
- if (Gt(m, Uint8Array) && (m = o.from(m, m.offset, m.byteLength)), !o.isBuffer(m))
22043
+ if (Vt(m, Uint8Array) && (m = o.from(m, m.offset, m.byteLength)), !o.isBuffer(m))
22044
22044
  throw new TypeError(
22045
22045
  'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof m
22046
22046
  );
@@ -22505,7 +22505,7 @@ Oa.write = function(n, t, e, s, i, r) {
22505
22505
  m[k + y] = C[k];
22506
22506
  return k;
22507
22507
  }
22508
- function Gt(C, m) {
22508
+ function Vt(C, m) {
22509
22509
  return C instanceof m || C != null && C.constructor != null && C.constructor.name != null && C.constructor.name === m.name;
22510
22510
  }
22511
22511
  function Et(C) {
@@ -33015,7 +33015,7 @@ class xe {
33015
33015
  }
33016
33016
  class he {
33017
33017
  constructor() {
33018
- this.fontMapping = {}, this.loadedFontMap = /* @__PURE__ */ new Map(), this.unsupportedChars = {}, this.missedFonts = {}, this.enableFontCache = !0, this.lazyFontLoading = !0, this.defaultFonts = /* @__PURE__ */ new Set(["simsun"]), this.symbolFonts = /* @__PURE__ */ new Set(["simplex", "amgdt"]), this.events = {
33018
+ this.fontMapping = {}, this.loadedFontMap = /* @__PURE__ */ new Map(), this.unsupportedChars = {}, this.missedFonts = {}, this.enableFontCache = !0, this.lazyFontLoading = !0, this.awaitFontsBeforeDraw = !1, this.defaultFonts = /* @__PURE__ */ new Set(["simsun"]), this.symbolFonts = /* @__PURE__ */ new Set(["simplex", "amgdt"]), this.events = {
33019
33019
  /** Event triggered when a font cannot be found */
33020
33020
  fontNotFound: new Fo(),
33021
33021
  /** Event triggered when a font is successfully loaded */
@@ -33175,11 +33175,14 @@ class he {
33175
33175
  return this.fontRequestInFlight.set(e, r), r;
33176
33176
  }
33177
33177
  /**
33178
- * Fire-and-forget {@link requestFont} for each name (deduped per name).
33178
+ * Requests each font name via {@link requestFont} (deduped per name).
33179
+ * Callers may ignore the returned promise for fire-and-forget loads, or
33180
+ * await it when they need fonts before drawing.
33179
33181
  */
33180
33182
  requestFonts(t) {
33181
- for (const e of t)
33182
- this.requestFont(e);
33183
+ return Promise.all(t.map((e) => this.requestFont(e))).then(
33184
+ (e) => e.flat()
33185
+ );
33183
33186
  }
33184
33187
  normalizeFontName(t) {
33185
33188
  if (t == null)
@@ -34703,7 +34706,7 @@ class sh {
34703
34706
  );
34704
34707
  r.add(c), this._currentLineObjects.push(c), t.length = 0, e.length = 0, this._lineBatchEntries = [], s.length = 0, i.length = 0, this._processedCharCount += o;
34705
34708
  } else if (s.length > 0 || i.length > 0) {
34706
- const c = new jt();
34709
+ const c = new Xt();
34707
34710
  c.userData.bboxIntersectionCheck = !0, c.userData.charBoxType = a, c.userData.layout = {
34708
34711
  chars: [...s, ...i]
34709
34712
  }, r.add(c), this._currentLineObjects.push(c), s.length = 0, i.length = 0, this._processedCharCount += o;
@@ -35441,7 +35444,7 @@ function yx(n) {
35441
35444
  });
35442
35445
  }
35443
35446
  const as = /* @__PURE__ */ new E(), Le = /* @__PURE__ */ new E(), _e = /* @__PURE__ */ new E(), ih = /* @__PURE__ */ new E(1, 0, 0);
35444
- class Da extends jt {
35447
+ class Da extends Xt {
35445
35448
  /**
35446
35449
  * Extracts all unique font names used in an MText string.
35447
35450
  * This function searches for font commands in the format \f{fontname}| or \f{fontname}; and returns a set of unique font names.
@@ -35491,29 +35494,35 @@ class Da extends jt {
35491
35494
  this.disposeThreeObject(this);
35492
35495
  }
35493
35496
  /**
35494
- * Draw the MText object. Schedules required fonts for background load and
35495
- * builds the object graph immediately with current fallbacks.
35497
+ * Draw the MText object.
35496
35498
  *
35497
- * Does not await downloads callers that need glyphs from newly loaded fonts
35498
- * should redraw after {@link FontManager.events.fontLoaded}.
35499
- */
35500
- async asyncDraw() {
35501
- const t = Array.from(Da.getFonts(this._mtextData.text || "", !0));
35499
+ * With {@link FontManager.lazyFontLoading} and without awaiting fonts, this
35500
+ * schedules downloads in the background and builds geometry immediately with
35501
+ * current fallbacks — redraw after {@link FontManager.events.fontLoaded} if
35502
+ * you need the final faces. Pass `{ awaitFonts: true }` or set
35503
+ * {@link FontManager.awaitFontsBeforeDraw} to wait for referenced fonts first.
35504
+ */
35505
+ async asyncDraw(t) {
35506
+ const e = Array.from(Da.getFonts(this._mtextData.text || "", !0));
35502
35507
  if (!this._fontsInStyleLoaded) {
35503
35508
  if (this._style.font) {
35504
- const e = this.getFontName(this._style.font);
35505
- e && t.push(e);
35509
+ const s = this.getFontName(this._style.font);
35510
+ s && e.push(s);
35506
35511
  }
35507
35512
  if (this._style.bigFont) {
35508
- const e = this.getFontName(this._style.bigFont);
35509
- e && t.push(e);
35513
+ const s = this.getFontName(this._style.bigFont);
35514
+ s && e.push(s);
35510
35515
  }
35511
35516
  if (this._style.extendedFont) {
35512
- const e = this.getFontName(this._style.extendedFont);
35513
- e && t.push(e);
35517
+ const s = this.getFontName(this._style.extendedFont);
35518
+ s && e.push(s);
35514
35519
  }
35515
35520
  }
35516
- t.length > 0 && (this._fontManager.lazyFontLoading ? this._fontManager.requestFonts(t) : await this._fontManager.loadFontsByNames(t), this._fontsInStyleLoaded = !0), this.syncDraw();
35521
+ if (e.length > 0) {
35522
+ const s = (t == null ? void 0 : t.awaitFonts) ?? (!this._fontManager.lazyFontLoading || this._fontManager.awaitFontsBeforeDraw);
35523
+ this._fontManager.lazyFontLoading ? s ? await this._fontManager.requestFonts(e) : this._fontManager.requestFonts(e) : await this._fontManager.loadFontsByNames(e), this._fontsInStyleLoaded = !0;
35524
+ }
35525
+ this.syncDraw();
35517
35526
  }
35518
35527
  /**
35519
35528
  * Draw the MText object. This method assumes that fonts needed are loaded. If font needed
@@ -36051,8 +36060,8 @@ class Da extends jt {
36051
36060
  }
36052
36061
  }
36053
36062
  }
36054
- const Zt = he.instance, rh = new sx();
36055
- Zt.events.fontLoaded.addEventListener((n) => {
36063
+ const Gt = he.instance, rh = new sx();
36064
+ Gt.events.fontLoaded.addEventListener((n) => {
36056
36065
  self.postMessage({
36057
36066
  type: "fontLoaded",
36058
36067
  id: "",
@@ -36071,7 +36080,7 @@ self.addEventListener("message", async (n) => {
36071
36080
  i,
36072
36081
  r,
36073
36082
  rh,
36074
- Zt,
36083
+ Gt,
36075
36084
  o
36076
36085
  );
36077
36086
  await c.asyncDraw(), c.updateMatrixWorld(!0);
@@ -36090,8 +36099,8 @@ self.addEventListener("message", async (n) => {
36090
36099
  case "loadFonts": {
36091
36100
  if (!s) throw new Error("Missing data for loadFonts message");
36092
36101
  const { fonts: i } = s;
36093
- await Zt.loadFontsByNames(i);
36094
- const r = i.filter((a) => Zt.isFontLoaded(a));
36102
+ await Gt.loadFontsByNames(i);
36103
+ const r = i.filter((a) => Gt.isFontLoaded(a));
36095
36104
  self.postMessage({
36096
36105
  type: "loadFonts",
36097
36106
  id: e,
@@ -36103,13 +36112,13 @@ self.addEventListener("message", async (n) => {
36103
36112
  case "setDefaultFonts": {
36104
36113
  if (!s) throw new Error("Missing data for setDefaultFonts message");
36105
36114
  const { fonts: i, symbolFonts: r } = s;
36106
- Zt.setDefaultFonts(i), Zt.setSymbolFonts(r), self.postMessage({
36115
+ Gt.setDefaultFonts(i), Gt.setSymbolFonts(r), self.postMessage({
36107
36116
  type: "setDefaultFonts",
36108
36117
  id: e,
36109
36118
  success: !0,
36110
36119
  data: {
36111
- fonts: [...Zt.defaultFonts],
36112
- symbolFonts: [...Zt.symbolFonts]
36120
+ fonts: [...Gt.defaultFonts],
36121
+ symbolFonts: [...Gt.symbolFonts]
36113
36122
  }
36114
36123
  });
36115
36124
  break;
@@ -36117,18 +36126,30 @@ self.addEventListener("message", async (n) => {
36117
36126
  case "setLazyFontLoading": {
36118
36127
  if (!s) throw new Error("Missing data for setLazyFontLoading message");
36119
36128
  const { enabled: i } = s;
36120
- Zt.lazyFontLoading = i, self.postMessage({
36129
+ Gt.lazyFontLoading = i, self.postMessage({
36121
36130
  type: "setLazyFontLoading",
36122
36131
  id: e,
36123
36132
  success: !0,
36124
- data: { enabled: Zt.lazyFontLoading }
36133
+ data: { enabled: Gt.lazyFontLoading }
36134
+ });
36135
+ break;
36136
+ }
36137
+ case "setAwaitFontsBeforeDraw": {
36138
+ if (!s)
36139
+ throw new Error("Missing data for setAwaitFontsBeforeDraw message");
36140
+ const { enabled: i } = s;
36141
+ Gt.awaitFontsBeforeDraw = i, self.postMessage({
36142
+ type: "setAwaitFontsBeforeDraw",
36143
+ id: e,
36144
+ success: !0,
36145
+ data: { enabled: Gt.awaitFontsBeforeDraw }
36125
36146
  });
36126
36147
  break;
36127
36148
  }
36128
36149
  case "setFontUrl": {
36129
36150
  if (!s) throw new Error("Missing data for setFontUrl message");
36130
36151
  const { url: i } = s;
36131
- Zt.baseUrl = i, self.postMessage({
36152
+ Gt.baseUrl = i, self.postMessage({
36132
36153
  type: "setFontUrl",
36133
36154
  id: e,
36134
36155
  success: !0,
@@ -36148,7 +36169,7 @@ self.addEventListener("message", async (n) => {
36148
36169
  }
36149
36170
  case "getMemoryStats": {
36150
36171
  const i = nx(
36151
- Zt,
36172
+ Gt,
36152
36173
  {
36153
36174
  id: "worker",
36154
36175
  styleManager: rh