@mlightcad/mtext-renderer 0.9.0 → 0.9.1

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
@@ -3621,7 +3621,7 @@ function _n(t, e, r) {
3621
3621
  O = c.length % 2 !== 0, O && !h && (k = c.shift() + m), u += c.length >> 1, c.length = 0, h = !0;
3622
3622
  }
3623
3623
  function B(O) {
3624
- for (var H, W, z, ce, ie, j, Z, $, te, se, ne, ue, G = 0; G < O.length; ) {
3624
+ for (var H, W, z, ce, ae, j, Z, $, te, ie, ne, ue, G = 0; G < O.length; ) {
3625
3625
  var V = O[G];
3626
3626
  switch (G += 1, V) {
3627
3627
  case 1:
@@ -3650,23 +3650,23 @@ function _n(t, e, r) {
3650
3650
  n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), p = i + c.shift(), g = s + c.shift(), o.curveTo(n, a, i, s, p, g);
3651
3651
  break;
3652
3652
  case 10:
3653
- ie = c.pop() + v, j = S[ie], j && B(j);
3653
+ ae = c.pop() + v, j = S[ae], j && B(j);
3654
3654
  break;
3655
3655
  case 11:
3656
3656
  return;
3657
3657
  case 12:
3658
3658
  switch (V = O[G], G += 1, V) {
3659
3659
  case 35:
3660
- n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s + c.shift(), te = Z + c.shift(), se = $ + c.shift(), ne = te + c.shift(), ue = se + c.shift(), p = ne + c.shift(), g = ue + c.shift(), c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, se, ne, ue, p, g);
3660
+ n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s + c.shift(), te = Z + c.shift(), ie = $ + c.shift(), ne = te + c.shift(), ue = ie + c.shift(), p = ne + c.shift(), g = ue + c.shift(), c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, ie, ne, ue, p, g);
3661
3661
  break;
3662
3662
  case 34:
3663
- n = p + c.shift(), a = g, i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s, te = Z + c.shift(), se = s, ne = te + c.shift(), ue = g, p = ne + c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, se, ne, ue, p, g);
3663
+ n = p + c.shift(), a = g, i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s, te = Z + c.shift(), ie = s, ne = te + c.shift(), ue = g, p = ne + c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, ie, ne, ue, p, g);
3664
3664
  break;
3665
3665
  case 36:
3666
- n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s, te = Z + c.shift(), se = s, ne = te + c.shift(), ue = se + c.shift(), p = ne + c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, se, ne, ue, p, g);
3666
+ n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s, te = Z + c.shift(), ie = s, ne = te + c.shift(), ue = ie + c.shift(), p = ne + c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, ie, ne, ue, p, g);
3667
3667
  break;
3668
3668
  case 37:
3669
- n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s + c.shift(), te = Z + c.shift(), se = $ + c.shift(), ne = te + c.shift(), ue = se + c.shift(), Math.abs(ne - p) > Math.abs(ue - g) ? p = ne + c.shift() : g = ue + c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, se, ne, ue, p, g);
3669
+ n = p + c.shift(), a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), Z = i + c.shift(), $ = s + c.shift(), te = Z + c.shift(), ie = $ + c.shift(), ne = te + c.shift(), ue = ie + c.shift(), Math.abs(ne - p) > Math.abs(ue - g) ? p = ne + c.shift() : g = ue + c.shift(), o.curveTo(n, a, i, s, Z, $), o.curveTo(te, ie, ne, ue, p, g);
3670
3670
  break;
3671
3671
  default:
3672
3672
  console.log("Glyph " + e.index + ": unknown operator 1200" + V), c.length = 0;
@@ -3713,7 +3713,7 @@ function _n(t, e, r) {
3713
3713
  H = O[G], W = O[G + 1], c.push((H << 24 | W << 16) >> 16), G += 2;
3714
3714
  break;
3715
3715
  case 29:
3716
- ie = c.pop() + t.gsubrsBias, j = t.gsubrs[ie], j && B(j);
3716
+ ae = c.pop() + t.gsubrsBias, j = t.gsubrs[ae], j && B(j);
3717
3717
  break;
3718
3718
  case 30:
3719
3719
  for (; c.length > 0 && (n = p, a = g + c.shift(), i = n + c.shift(), s = a + c.shift(), p = i + c.shift(), g = s + (c.length === 1 ? c.shift() : 0), o.curveTo(n, a, i, s, p, g), c.length !== 0); )
@@ -5632,22 +5632,22 @@ function Do(t) {
5632
5632
  // Use space as the default character, if available.
5633
5633
  usBreakChar: t.hasChar(" ") ? 32 : 0
5634
5634
  // Use space as the break character, if available.
5635
- }, t.tables.os2)), O = hi.make(t.glyphs), H = $a.make(t.glyphs), W = t.getEnglishName("fontFamily"), z = t.getEnglishName("fontSubfamily"), ce = W + " " + z, ie = t.getEnglishName("postScriptName");
5636
- ie || (ie = W.replace(/\s/g, "") + "-" + z);
5635
+ }, t.tables.os2)), O = hi.make(t.glyphs), H = $a.make(t.glyphs), W = t.getEnglishName("fontFamily"), z = t.getEnglishName("fontSubfamily"), ce = W + " " + z, ae = t.getEnglishName("postScriptName");
5636
+ ae || (ae = W.replace(/\s/g, "") + "-" + z);
5637
5637
  var j = {};
5638
5638
  for (var Z in t.names)
5639
5639
  j[Z] = t.names[Z];
5640
- j.uniqueID || (j.uniqueID = { en: t.getEnglishName("manufacturer") + ":" + ce }), j.postScriptName || (j.postScriptName = { en: ie }), j.preferredFamily || (j.preferredFamily = t.names.fontFamily), j.preferredSubfamily || (j.preferredSubfamily = t.names.fontSubfamily);
5641
- var $ = [], te = yi.make(j, $), se = $.length > 0 ? li.make($) : void 0, ne = mi.make(), ue = oi.make(t.glyphs, {
5640
+ j.uniqueID || (j.uniqueID = { en: t.getEnglishName("manufacturer") + ":" + ce }), j.postScriptName || (j.postScriptName = { en: ae }), j.preferredFamily || (j.preferredFamily = t.names.fontFamily), j.preferredSubfamily || (j.preferredSubfamily = t.names.fontSubfamily);
5641
+ var $ = [], te = yi.make(j, $), ie = $.length > 0 ? li.make($) : void 0, ne = mi.make(), ue = oi.make(t.glyphs, {
5642
5642
  version: t.getEnglishName("version"),
5643
5643
  fullName: ce,
5644
5644
  familyName: W,
5645
5645
  weightName: z,
5646
- postScriptName: ie,
5646
+ postScriptName: ae,
5647
5647
  unitsPerEm: t.unitsPerEm,
5648
5648
  fontBBox: [0, w.yMin, w.ascender, w.advanceWidthMax]
5649
5649
  }), G = t.metas && Object.keys(t.metas).length > 0 ? xi.make(t.metas) : void 0, V = [k, E, L, B, te, H, ne, ue, O];
5650
- se && V.push(se), t.tables.gsub && V.push(bi.make(t.tables.gsub)), G && V.push(G);
5650
+ ie && V.push(ie), t.tables.gsub && V.push(bi.make(t.tables.gsub)), G && V.push(G);
5651
5651
  for (var tt = Si(V), Bt = tt.encode(), Lt = tn(Bt), ft = tt.fields, Ot = !1, Pe = 0; Pe < ft.length; Pe += 1)
5652
5652
  if (ft[Pe].name === "head table") {
5653
5653
  ft[Pe].value.checkSumAdjustment = 2981146554 - Lt, Ot = !0;
@@ -9254,8 +9254,8 @@ function wh(t, e) {
9254
9254
  }
9255
9255
  var H = re(i, w);
9256
9256
  if (a.tables.name = yi.parse(H.data, H.offset, n), a.names = a.tables.name, p && F) {
9257
- var W = r === 0, z = re(i, F), ce = xh.parse(z.data, z.offset, a.numGlyphs, W), ie = re(i, p);
9258
- a.glyphs = Ti.parse(ie.data, ie.offset, ce, a, e);
9257
+ var W = r === 0, z = re(i, F), ce = xh.parse(z.data, z.offset, a.numGlyphs, W), ae = re(i, p);
9258
+ a.glyphs = Ti.parse(ae.data, ae.offset, ce, a, e);
9259
9259
  } else if (h) {
9260
9260
  var j = re(i, h);
9261
9261
  oi.parse(j.data, j.offset, a, e);
@@ -9272,8 +9272,8 @@ function wh(t, e) {
9272
9272
  a.tables.gdef = hh.parse(te.data, te.offset);
9273
9273
  }
9274
9274
  if (S) {
9275
- var se = re(i, S);
9276
- a.tables.gpos = dh.parse(se.data, se.offset), a.position.init();
9275
+ var ie = re(i, S);
9276
+ a.tables.gpos = dh.parse(ie.data, ie.offset), a.position.init();
9277
9277
  }
9278
9278
  if (v) {
9279
9279
  var ne = re(i, v);
@@ -9418,8 +9418,8 @@ function Fh(t, e = 1e-4) {
9418
9418
  else {
9419
9419
  for (let E = 0, L = o.length; E < L; E++) {
9420
9420
  const B = o[E], O = t.getAttribute(B), H = t.morphAttributes[B], W = O.itemSize, z = c[B], ce = u[B];
9421
- for (let ie = 0; ie < W; ie++) {
9422
- const j = d[ie], Z = p[ie];
9421
+ for (let ae = 0; ae < W; ae++) {
9422
+ const j = d[ae], Z = p[ae];
9423
9423
  if (z[Z](s, O[j](w)), H)
9424
9424
  for (let $ = 0, te = H.length; $ < te; $++)
9425
9425
  ce[$][Z](s, H[$][j](w));
@@ -11371,9 +11371,9 @@ cn.write = function(t, e, r, n, a, i) {
11371
11371
  return te(this, l, f);
11372
11372
  case "latin1":
11373
11373
  case "binary":
11374
- return se(this, l, f);
11375
- case "base64":
11376
11374
  return ie(this, l, f);
11375
+ case "base64":
11376
+ return ae(this, l, f);
11377
11377
  case "ucs2":
11378
11378
  case "ucs-2":
11379
11379
  case "utf16le":
@@ -11558,7 +11558,7 @@ cn.write = function(t, e, r, n, a, i) {
11558
11558
  data: Array.prototype.slice.call(this._arr || this, 0)
11559
11559
  };
11560
11560
  };
11561
- function ie(y, l, f) {
11561
+ function ae(y, l, f) {
11562
11562
  return l === 0 && f === y.length ? e.fromByteArray(y) : e.fromByteArray(y.slice(l, f));
11563
11563
  }
11564
11564
  function j(y, l, f) {
@@ -11604,7 +11604,7 @@ cn.write = function(t, e, r, n, a, i) {
11604
11604
  b += String.fromCharCode(y[T] & 127);
11605
11605
  return b;
11606
11606
  }
11607
- function se(y, l, f) {
11607
+ function ie(y, l, f) {
11608
11608
  var b = "";
11609
11609
  f = Math.min(y.length, f);
11610
11610
  for (var T = l; T < f; ++T)
@@ -23684,7 +23684,7 @@ class Ur {
23684
23684
  this.type = e, this.ctx = r, this.data = n;
23685
23685
  }
23686
23686
  }
23687
- var ct = /* @__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))(ct || {}), _l = /* @__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))(_l || {}), ae = /* @__PURE__ */ ((t) => (t.CHAR = "CHAR", t.NEW_PARAGRAPH = "NEW_PARAGRAPH", t.STACK = "STACK", t))(ae || {});
23687
+ var ct = /* @__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))(ct || {}), _l = /* @__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))(_l || {}), se = /* @__PURE__ */ ((t) => (t.CHAR = "CHAR", t.NEW_PARAGRAPH = "NEW_PARAGRAPH", t.STACK = "STACK", t))(se || {});
23688
23688
  const Pl = /* @__PURE__ */ new _.Vector3(), Nl = 1.666666, zt = 0.3, jr = "";
23689
23689
  class dn extends Ut {
23690
23690
  /**
@@ -24025,7 +24025,7 @@ class Gl {
24025
24025
  a,
24026
24026
  i
24027
24027
  );
24028
- const u = c[2] === "^" ? ae.CHAR : ae.STACK;
24028
+ const u = c[2] === "^" ? se.CHAR : se.STACK;
24029
24029
  this.processGeometries(
24030
24030
  r,
24031
24031
  n,
@@ -24043,7 +24043,7 @@ class Gl {
24043
24043
  s
24044
24044
  ), this.processLastLine(), s;
24045
24045
  }
24046
- processGeometries(e, r, n, a, i, s = ae.CHAR) {
24046
+ processGeometries(e, r, n, a, i, s = se.CHAR) {
24047
24047
  if (e.length > 0 || r.length > 0) {
24048
24048
  const o = this.toThreeObject(
24049
24049
  e,
@@ -24181,12 +24181,12 @@ class Gl {
24181
24181
  new _.Vector3(e + n, s, 0)
24182
24182
  );
24183
24183
  this.resolveCharBoxTarget(a, i) === "mesh" ? a.push({
24184
- type: ae.CHAR,
24184
+ type: se.CHAR,
24185
24185
  box: o,
24186
24186
  char: jr,
24187
24187
  children: []
24188
24188
  }) : i.push({
24189
- type: ae.CHAR,
24189
+ type: se.CHAR,
24190
24190
  box: o,
24191
24191
  char: jr,
24192
24192
  children: []
@@ -24210,12 +24210,12 @@ class Gl {
24210
24210
  )
24211
24211
  );
24212
24212
  this.resolveCharBoxTarget(e, r) === "mesh" ? e.push({
24213
- type: ae.CHAR,
24213
+ type: se.CHAR,
24214
24214
  box: i,
24215
24215
  char: " ",
24216
24216
  children: []
24217
24217
  }) : r.push({
24218
- type: ae.CHAR,
24218
+ type: se.CHAR,
24219
24219
  box: i,
24220
24220
  char: " ",
24221
24221
  children: []
@@ -24225,15 +24225,16 @@ class Gl {
24225
24225
  }
24226
24226
  recordLineBreak(e, r) {
24227
24227
  if (this._options.collectCharBoxes === !1 || !e || !r) return;
24228
+ const n = new _.Vector3(this._hOffset, this._vOffset, 0), a = new _.Box3(n.clone(), n.clone());
24228
24229
  this.resolveCharBoxTarget(e, r) === "mesh" ? e.push({
24229
- type: ae.NEW_PARAGRAPH,
24230
- box: void 0,
24230
+ type: se.NEW_PARAGRAPH,
24231
+ box: a,
24231
24232
  char: `
24232
24233
  `,
24233
24234
  children: []
24234
24235
  }) : r.push({
24235
- type: ae.NEW_PARAGRAPH,
24236
- box: void 0,
24236
+ type: se.NEW_PARAGRAPH,
24237
+ box: a,
24237
24238
  char: `
24238
24239
  `,
24239
24240
  children: []
@@ -24276,12 +24277,12 @@ class Gl {
24276
24277
  o.userData.char = e, o.boundingBox || o.computeBoundingBox();
24277
24278
  const x = new _.Box3().copy(o.boundingBox);
24278
24279
  o instanceof _.ShapeGeometry ? (this._lastCharBoxTarget = "mesh", a.push({
24279
- type: ae.CHAR,
24280
+ type: se.CHAR,
24280
24281
  box: x,
24281
24282
  char: e,
24282
24283
  children: []
24283
24284
  })) : (this._lastCharBoxTarget = "line", i.push({
24284
- type: ae.CHAR,
24285
+ type: se.CHAR,
24285
24286
  box: x,
24286
24287
  char: e,
24287
24288
  children: []
@@ -24610,7 +24611,8 @@ class Qt extends _.Object3D {
24610
24611
  *
24611
24612
  * Token semantics:
24612
24613
  * - `CHAR`: `char` is the rendered character, `box` is defined, `children` is empty.
24613
- * - `NEW_PARAGRAPH`: `char` is `\n`, `box` is `undefined`, `children` is empty.
24614
+ * - `NEW_PARAGRAPH`: `char` is `\n`. The `box` represents a zero-width vertical
24615
+ * line whose height equals the current line height. `children` is empty.
24614
24616
  * - `STACK`: `char` is empty string (`''`), `box` is the union of stack component boxes,
24615
24617
  * and `children` contains the stack sub-components.
24616
24618
  *
@@ -24772,29 +24774,27 @@ class Qt extends _.Object3D {
24772
24774
  const c = n.filter((h) => h.char !== jr).map((h) => {
24773
24775
  const d = h.box ? new _.Box3().copy(h.box).applyMatrix4(e.matrixWorld) : void 0;
24774
24776
  return {
24775
- type: h.type === ae.NEW_PARAGRAPH ? ae.NEW_PARAGRAPH : ae.CHAR,
24777
+ type: h.type === se.NEW_PARAGRAPH ? se.NEW_PARAGRAPH : se.CHAR,
24776
24778
  box: d,
24777
- char: h.type === ae.NEW_PARAGRAPH ? `
24779
+ char: h.type === se.NEW_PARAGRAPH ? `
24778
24780
  ` : h.char,
24779
24781
  children: []
24780
24782
  };
24781
24783
  });
24782
- if (((s = e.userData) == null ? void 0 : s.charBoxType) === ae.STACK) {
24784
+ if (((s = e.userData) == null ? void 0 : s.charBoxType) === se.STACK) {
24783
24785
  const h = new _.Box3();
24784
- let d = !1;
24785
- c.forEach((p) => {
24786
- p.box && (d ? h.union(p.box) : (h.copy(p.box), d = !0));
24786
+ c.forEach((d) => {
24787
+ h.union(d.box);
24787
24788
  }), r.push({
24788
- type: ae.STACK,
24789
+ type: se.STACK,
24789
24790
  char: "",
24790
- box: d ? h : void 0,
24791
+ box: h,
24791
24792
  children: c
24792
24793
  });
24793
24794
  } else
24794
24795
  c.forEach((h) => {
24795
24796
  r.push({
24796
- ...h,
24797
- box: h.type === ae.NEW_PARAGRAPH ? void 0 : h.box
24797
+ ...h
24798
24798
  });
24799
24799
  });
24800
24800
  return;
@@ -24805,7 +24805,7 @@ class Qt extends _.Object3D {
24805
24805
  c.boundingBox === null && c.computeBoundingBox();
24806
24806
  const u = new _.Box3().copy(c.boundingBox);
24807
24807
  u.applyMatrix4(e.matrixWorld), r.push({
24808
- type: ae.CHAR,
24808
+ type: se.CHAR,
24809
24809
  box: u,
24810
24810
  char: "",
24811
24811
  children: []
@@ -25273,7 +25273,7 @@ class Yl {
25273
25273
  export {
25274
25274
  Pa as BaseFont,
25275
25275
  Na as BaseTextShape,
25276
- ae as CharBoxType,
25276
+ se as CharBoxType,
25277
25277
  Ll as DefaultFontLoader,
25278
25278
  Sn as EventManager,
25279
25279
  We as FontFactory,