@mlightcad/mtext-renderer 0.10.10 → 0.10.12
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 +69 -56
- package/dist/index.umd.cjs +6 -6
- package/dist/mtext-renderer-worker.js +80 -68
- package/lib/index.d.ts +1 -0
- package/lib/renderer/mtextProcessor.d.ts +9 -0
- package/lib/shxParser.d.ts +9 -0
- package/package.json +1 -1
|
@@ -8,10 +8,10 @@ var P1 = Fc((L) => {
|
|
|
8
8
|
(function(n) {
|
|
9
9
|
n[n.BOTTOM = 0] = "BOTTOM", n[n.MIDDLE = 1] = "MIDDLE", n[n.TOP = 2] = "TOP";
|
|
10
10
|
})(_t || (_t = {}));
|
|
11
|
-
var
|
|
11
|
+
var ce;
|
|
12
12
|
(function(n) {
|
|
13
13
|
n[n.DEFAULT = 0] = "DEFAULT", n[n.LEFT = 1] = "LEFT", n[n.RIGHT = 2] = "RIGHT", n[n.CENTER = 3] = "CENTER", n[n.JUSTIFIED = 4] = "JUSTIFIED", n[n.DISTRIBUTED = 5] = "DISTRIBUTED";
|
|
14
|
-
})(
|
|
14
|
+
})(ce || (ce = {}));
|
|
15
15
|
var At;
|
|
16
16
|
(function(n) {
|
|
17
17
|
n[n.NONE = 0] = "NONE", n[n.UNDERLINE = 1] = "UNDERLINE", n[n.OVERLINE = 2] = "OVERLINE", n[n.STRIKE_THROUGH = 4] = "STRIKE_THROUGH";
|
|
@@ -22,11 +22,11 @@ var P1 = Fc((L) => {
|
|
|
22
22
|
p: "±",
|
|
23
23
|
"%": "%"
|
|
24
24
|
}, Tc = {
|
|
25
|
-
l:
|
|
26
|
-
r:
|
|
27
|
-
c:
|
|
28
|
-
j:
|
|
29
|
-
d:
|
|
25
|
+
l: ce.LEFT,
|
|
26
|
+
r: ce.RIGHT,
|
|
27
|
+
c: ce.CENTER,
|
|
28
|
+
j: ce.JUSTIFIED,
|
|
29
|
+
d: ce.DISTRIBUTED
|
|
30
30
|
};
|
|
31
31
|
function kc(n) {
|
|
32
32
|
const [e, t, r] = n;
|
|
@@ -538,7 +538,7 @@ var P1 = Fc((L) => {
|
|
|
538
538
|
break;
|
|
539
539
|
case "q": {
|
|
540
540
|
const u = t.get();
|
|
541
|
-
for (a = Tc[u] ||
|
|
541
|
+
for (a = Tc[u] || ce.DEFAULT; t.peek() === ","; )
|
|
542
542
|
t.consume(1);
|
|
543
543
|
break;
|
|
544
544
|
}
|
|
@@ -583,11 +583,11 @@ var P1 = Fc((L) => {
|
|
|
583
583
|
indent: 0,
|
|
584
584
|
left: 0,
|
|
585
585
|
right: 0,
|
|
586
|
-
align:
|
|
586
|
+
align: ce.DEFAULT,
|
|
587
587
|
tabs: []
|
|
588
588
|
};
|
|
589
589
|
const h = {};
|
|
590
|
-
return o.indent !== 0 && (h.indent = 0), o.left !== 0 && (h.left = 0), o.right !== 0 && (h.right = 0), o.align !==
|
|
590
|
+
return o.indent !== 0 && (h.indent = 0), o.left !== 0 && (h.left = 0), o.right !== 0 && (h.right = 0), o.align !== ce.DEFAULT && (h.align = ce.DEFAULT), JSON.stringify(o.tabs) !== JSON.stringify([]) && (h.tabs = []), h;
|
|
591
591
|
}
|
|
592
592
|
const s = () => {
|
|
593
593
|
let a = "";
|
|
@@ -970,7 +970,7 @@ var P1 = Fc((L) => {
|
|
|
970
970
|
indent: 0,
|
|
971
971
|
left: 0,
|
|
972
972
|
right: 0,
|
|
973
|
-
align:
|
|
973
|
+
align: ce.DEFAULT,
|
|
974
974
|
tabs: []
|
|
975
975
|
};
|
|
976
976
|
}
|
|
@@ -5718,7 +5718,7 @@ var P1 = Fc((L) => {
|
|
|
5718
5718
|
e || (e = n);
|
|
5719
5719
|
let t = n, r;
|
|
5720
5720
|
do
|
|
5721
|
-
if (r = !1, !t.steiner && (oi(t, t.next) ||
|
|
5721
|
+
if (r = !1, !t.steiner && (oi(t, t.next) || ue(t.prev, t, t.next) === 0)) {
|
|
5722
5722
|
if (Xr(t), t = e = t.prev, t === t.next) break;
|
|
5723
5723
|
r = !0;
|
|
5724
5724
|
} else
|
|
@@ -5743,30 +5743,30 @@ var P1 = Fc((L) => {
|
|
|
5743
5743
|
}
|
|
5744
5744
|
function wu(n) {
|
|
5745
5745
|
const e = n.prev, t = n, r = n.next;
|
|
5746
|
-
if (
|
|
5746
|
+
if (ue(e, t, r) >= 0) return !1;
|
|
5747
5747
|
const i = e.x, s = t.x, a = r.x, o = e.y, h = t.y, c = r.y, u = i < s ? i < a ? i : a : s < a ? s : a, f = o < h ? o < c ? o : c : h < c ? h : c, l = i > s ? i > a ? i : a : s > a ? s : a, p = o > h ? o > c ? o : c : h > c ? h : c;
|
|
5748
5748
|
let g = r.next;
|
|
5749
5749
|
for (; g !== e; ) {
|
|
5750
|
-
if (g.x >= u && g.x <= l && g.y >= f && g.y <= p && dr(i, o, s, h, a, c, g.x, g.y) &&
|
|
5750
|
+
if (g.x >= u && g.x <= l && g.y >= f && g.y <= p && dr(i, o, s, h, a, c, g.x, g.y) && ue(g.prev, g, g.next) >= 0) return !1;
|
|
5751
5751
|
g = g.next;
|
|
5752
5752
|
}
|
|
5753
5753
|
return !0;
|
|
5754
5754
|
}
|
|
5755
5755
|
function Su(n, e, t, r) {
|
|
5756
5756
|
const i = n.prev, s = n, a = n.next;
|
|
5757
|
-
if (
|
|
5757
|
+
if (ue(i, s, a) >= 0) return !1;
|
|
5758
5758
|
const o = i.x, h = s.x, c = a.x, u = i.y, f = s.y, l = a.y, p = o < h ? o < c ? o : c : h < c ? h : c, g = u < f ? u < l ? u : l : f < l ? f : l, m = o > h ? o > c ? o : c : h > c ? h : c, x = u > f ? u > l ? u : l : f > l ? f : l, v = gs(p, g, e, t, r), w = gs(m, x, e, t, r);
|
|
5759
5759
|
let b = n.prevZ, S = n.nextZ;
|
|
5760
5760
|
for (; b && b.z >= v && S && S.z <= w; ) {
|
|
5761
|
-
if (b.x >= p && b.x <= m && b.y >= g && b.y <= x && b !== i && b !== a && dr(o, u, h, f, c, l, b.x, b.y) &&
|
|
5761
|
+
if (b.x >= p && b.x <= m && b.y >= g && b.y <= x && b !== i && b !== a && dr(o, u, h, f, c, l, b.x, b.y) && ue(b.prev, b, b.next) >= 0 || (b = b.prevZ, S.x >= p && S.x <= m && S.y >= g && S.y <= x && S !== i && S !== a && dr(o, u, h, f, c, l, S.x, S.y) && ue(S.prev, S, S.next) >= 0)) return !1;
|
|
5762
5762
|
S = S.nextZ;
|
|
5763
5763
|
}
|
|
5764
5764
|
for (; b && b.z >= v; ) {
|
|
5765
|
-
if (b.x >= p && b.x <= m && b.y >= g && b.y <= x && b !== i && b !== a && dr(o, u, h, f, c, l, b.x, b.y) &&
|
|
5765
|
+
if (b.x >= p && b.x <= m && b.y >= g && b.y <= x && b !== i && b !== a && dr(o, u, h, f, c, l, b.x, b.y) && ue(b.prev, b, b.next) >= 0) return !1;
|
|
5766
5766
|
b = b.prevZ;
|
|
5767
5767
|
}
|
|
5768
5768
|
for (; S && S.z <= w; ) {
|
|
5769
|
-
if (S.x >= p && S.x <= m && S.y >= g && S.y <= x && S !== i && S !== a && dr(o, u, h, f, c, l, S.x, S.y) &&
|
|
5769
|
+
if (S.x >= p && S.x <= m && S.y >= g && S.y <= x && S !== i && S !== a && dr(o, u, h, f, c, l, S.x, S.y) && ue(S.prev, S, S.next) >= 0) return !1;
|
|
5770
5770
|
S = S.nextZ;
|
|
5771
5771
|
}
|
|
5772
5772
|
return !0;
|
|
@@ -5834,7 +5834,7 @@ var P1 = Fc((L) => {
|
|
|
5834
5834
|
return i;
|
|
5835
5835
|
}
|
|
5836
5836
|
function Mu(n, e) {
|
|
5837
|
-
return
|
|
5837
|
+
return ue(n.prev, n, e.prev) < 0 && ue(e.next, n, n.next) < 0;
|
|
5838
5838
|
}
|
|
5839
5839
|
function _u(n, e, t, r) {
|
|
5840
5840
|
let i = n;
|
|
@@ -5873,17 +5873,17 @@ var P1 = Fc((L) => {
|
|
|
5873
5873
|
function Ou(n, e) {
|
|
5874
5874
|
return n.next.i !== e.i && n.prev.i !== e.i && !Ru(n, e) && // doesn't intersect other edges
|
|
5875
5875
|
(qr(n, e) && qr(e, n) && Uu(n, e) && // locally visible
|
|
5876
|
-
(
|
|
5877
|
-
oi(n, e) &&
|
|
5876
|
+
(ue(n.prev, n, e.prev) || ue(n, e.prev, e)) || // does not create opposite-facing sectors
|
|
5877
|
+
oi(n, e) && ue(n.prev, n, n.next) > 0 && ue(e.prev, e, e.next) > 0);
|
|
5878
5878
|
}
|
|
5879
|
-
function
|
|
5879
|
+
function ue(n, e, t) {
|
|
5880
5880
|
return (e.y - n.y) * (t.x - e.x) - (e.x - n.x) * (t.y - e.y);
|
|
5881
5881
|
}
|
|
5882
5882
|
function oi(n, e) {
|
|
5883
5883
|
return n.x === e.x && n.y === e.y;
|
|
5884
5884
|
}
|
|
5885
5885
|
function ph(n, e, t, r) {
|
|
5886
|
-
const i = Rn(
|
|
5886
|
+
const i = Rn(ue(n, e, t)), s = Rn(ue(n, e, r)), a = Rn(ue(t, r, n)), o = Rn(ue(t, r, e));
|
|
5887
5887
|
return !!(i !== s && a !== o || i === 0 && On(n, t, e) || s === 0 && On(n, r, e) || a === 0 && On(t, n, r) || o === 0 && On(t, e, r));
|
|
5888
5888
|
}
|
|
5889
5889
|
function On(n, e, t) {
|
|
@@ -5901,7 +5901,7 @@ var P1 = Fc((L) => {
|
|
|
5901
5901
|
return !1;
|
|
5902
5902
|
}
|
|
5903
5903
|
function qr(n, e) {
|
|
5904
|
-
return
|
|
5904
|
+
return ue(n.prev, n, n.next) < 0 ? ue(n, e, n.next) >= 0 && ue(n, n.prev, e) >= 0 : ue(n, e, n.prev) < 0 || ue(n, n.next, e) < 0;
|
|
5905
5905
|
}
|
|
5906
5906
|
function Uu(n, e) {
|
|
5907
5907
|
let t = n, r = !1;
|
|
@@ -16610,7 +16610,7 @@ var P1 = Fc((L) => {
|
|
|
16610
16610
|
}
|
|
16611
16611
|
}
|
|
16612
16612
|
}
|
|
16613
|
-
class
|
|
16613
|
+
class fe {
|
|
16614
16614
|
/**
|
|
16615
16615
|
* Creates a new Point instance.
|
|
16616
16616
|
* @param x - The x-coordinate (defaults to 0)
|
|
@@ -16648,7 +16648,7 @@ var P1 = Fc((L) => {
|
|
|
16648
16648
|
* @returns A new Point instance with the same x and y values
|
|
16649
16649
|
*/
|
|
16650
16650
|
clone() {
|
|
16651
|
-
return new
|
|
16651
|
+
return new fe(this.x, this.y);
|
|
16652
16652
|
}
|
|
16653
16653
|
/**
|
|
16654
16654
|
* Adds another point's coordinates to this point.
|
|
@@ -16753,18 +16753,18 @@ var P1 = Fc((L) => {
|
|
|
16753
16753
|
}
|
|
16754
16754
|
const i = 4 * Math.atan(Math.abs(this.bulge));
|
|
16755
16755
|
this.radius = r / (2 * Math.sin(i / 2));
|
|
16756
|
-
const s = this.start.clone().add(t.clone().divide(2)), a = new
|
|
16756
|
+
const s = this.start.clone().add(t.clone().divide(2)), a = new fe(-t.y, t.x);
|
|
16757
16757
|
a.normalize(), a.multiply(Math.abs(this.radius * Math.cos(i / 2))), this.center = s.clone(), this.isClockwise ? this.center.subtract(a) : this.center.add(a), this.startAngle = Math.atan2(this.start.y - this.center.y, this.start.x - this.center.x), this.endAngle = Math.atan2(this.end.y - this.center.y, this.end.x - this.center.x), this.isClockwise ? this.endAngle >= this.startAngle && (this.endAngle -= 2 * Math.PI) : this.endAngle <= this.startAngle && (this.endAngle += 2 * Math.PI);
|
|
16758
16758
|
} else if (e.center && e.radius !== void 0 && e.startOctant !== void 0 && e.octantCount !== void 0 && e.isClockwise !== void 0) {
|
|
16759
16759
|
this.center = e.center.clone(), this.radius = e.radius, this.isClockwise = e.isClockwise, this.startAngle = e.startOctant * Io;
|
|
16760
16760
|
const t = (e.octantCount === 0 ? 8 : e.octantCount) * Io;
|
|
16761
16761
|
this.endAngle = this.startAngle + (this.isClockwise ? -t : t), this.start = this.center.clone().add(
|
|
16762
|
-
new
|
|
16762
|
+
new fe(
|
|
16763
16763
|
this.radius * Math.cos(this.startAngle),
|
|
16764
16764
|
this.radius * Math.sin(this.startAngle)
|
|
16765
16765
|
)
|
|
16766
16766
|
), this.end = this.center.clone().add(
|
|
16767
|
-
new
|
|
16767
|
+
new fe(this.radius * Math.cos(this.endAngle), this.radius * Math.sin(this.endAngle))
|
|
16768
16768
|
);
|
|
16769
16769
|
} else
|
|
16770
16770
|
throw new Error("Invalid arc parameters");
|
|
@@ -16781,12 +16781,12 @@ var P1 = Fc((L) => {
|
|
|
16781
16781
|
for (let s = 1; s < i; s++) {
|
|
16782
16782
|
const a = s / i, o = this.isClockwise ? this.startAngle - a * r : this.startAngle + a * r;
|
|
16783
16783
|
t.push(
|
|
16784
|
-
this.center.clone().add(new
|
|
16784
|
+
this.center.clone().add(new fe(this.radius * Math.cos(o), this.radius * Math.sin(o)))
|
|
16785
16785
|
);
|
|
16786
16786
|
}
|
|
16787
16787
|
return t.push(
|
|
16788
16788
|
this.end ? this.end.clone() : this.center.clone().add(
|
|
16789
|
-
new
|
|
16789
|
+
new fe(
|
|
16790
16790
|
this.radius * Math.cos(this.endAngle),
|
|
16791
16791
|
this.radius * Math.sin(this.endAngle)
|
|
16792
16792
|
)
|
|
@@ -16833,7 +16833,7 @@ var P1 = Fc((L) => {
|
|
|
16833
16833
|
*/
|
|
16834
16834
|
normalizeToOrigin(e = !1) {
|
|
16835
16835
|
const t = this.bbox;
|
|
16836
|
-
return this.offset(new
|
|
16836
|
+
return this.offset(new fe(-t.minX, -t.minY), e);
|
|
16837
16837
|
}
|
|
16838
16838
|
/**
|
|
16839
16839
|
* Converts the shape to an SVG string
|
|
@@ -16952,7 +16952,7 @@ var P1 = Fc((L) => {
|
|
|
16952
16952
|
*/
|
|
16953
16953
|
parseShape(e) {
|
|
16954
16954
|
const t = {
|
|
16955
|
-
currentPoint: new
|
|
16955
|
+
currentPoint: new fe(),
|
|
16956
16956
|
polylines: [],
|
|
16957
16957
|
currentPolyline: [],
|
|
16958
16958
|
sp: [],
|
|
@@ -17038,7 +17038,7 @@ var P1 = Fc((L) => {
|
|
|
17038
17038
|
* @returns Returns the vector for the given direction code
|
|
17039
17039
|
*/
|
|
17040
17040
|
getVectorForDirection(e) {
|
|
17041
|
-
const t = new
|
|
17041
|
+
const t = new fe();
|
|
17042
17042
|
switch (e) {
|
|
17043
17043
|
case 0:
|
|
17044
17044
|
t.x = 1;
|
|
@@ -17109,13 +17109,13 @@ var P1 = Fc((L) => {
|
|
|
17109
17109
|
}
|
|
17110
17110
|
handleXYDisplacement(e, t, r) {
|
|
17111
17111
|
let i = t;
|
|
17112
|
-
const s = new
|
|
17112
|
+
const s = new fe();
|
|
17113
17113
|
return s.x = Ce.byteToSByte(e[++i]), s.y = Ce.byteToSByte(e[++i]), r.currentPoint.add(s.multiply(r.scale)), r.isPenDown && r.currentPolyline.push(r.currentPoint.clone()), i;
|
|
17114
17114
|
}
|
|
17115
17115
|
handleMultipleXYDisplacements(e, t, r) {
|
|
17116
17116
|
let i = t;
|
|
17117
17117
|
for (; ; ) {
|
|
17118
|
-
const s = new
|
|
17118
|
+
const s = new fe();
|
|
17119
17119
|
if (s.x = Ce.byteToSByte(e[++i]), s.y = Ce.byteToSByte(e[++i]), s.x === 0 && s.y === 0)
|
|
17120
17120
|
break;
|
|
17121
17121
|
r.currentPoint.add(s.multiply(r.scale)), r.isPenDown && r.currentPolyline.push(r.currentPoint.clone());
|
|
@@ -17127,7 +17127,7 @@ var P1 = Fc((L) => {
|
|
|
17127
17127
|
let s = t;
|
|
17128
17128
|
const a = e[++s] * r.scale, o = Ce.byteToSByte(e[++s]), h = (o & 112) >> 4;
|
|
17129
17129
|
let c = o & 7;
|
|
17130
|
-
const u = o < 0, f = Math.PI / 4 * h, l = r.currentPoint.clone().subtract(new
|
|
17130
|
+
const u = o < 0, f = Math.PI / 4 * h, l = r.currentPoint.clone().subtract(new fe(Math.cos(f) * a, Math.sin(f) * a)), p = jr.fromOctant(l, a, h, c, u);
|
|
17131
17131
|
if (r.isPenDown) {
|
|
17132
17132
|
const g = p.tessellate();
|
|
17133
17133
|
r.currentPolyline.pop(), r.currentPolyline.push(...g.slice());
|
|
@@ -17144,29 +17144,29 @@ var P1 = Fc((L) => {
|
|
|
17144
17144
|
u < 0 && (m = -m, g = -g, x = -1);
|
|
17145
17145
|
let v = p * f, w = v + g;
|
|
17146
17146
|
v += p * s / 256 * x, w += p * a / 256 * x;
|
|
17147
|
-
const b = r.currentPoint.clone().subtract(new
|
|
17148
|
-
if (r.currentPoint = b.clone().add(new
|
|
17147
|
+
const b = r.currentPoint.clone().subtract(new fe(c * Math.cos(v), c * Math.sin(v)));
|
|
17148
|
+
if (r.currentPoint = b.clone().add(new fe(c * Math.cos(w), c * Math.sin(w))), r.isPenDown) {
|
|
17149
17149
|
let S = v;
|
|
17150
17150
|
const T = [];
|
|
17151
17151
|
if (T.push(
|
|
17152
|
-
b.clone().add(new
|
|
17152
|
+
b.clone().add(new fe(c * Math.cos(S), c * Math.sin(S)))
|
|
17153
17153
|
), m > 0)
|
|
17154
17154
|
for (; S + m < w; )
|
|
17155
17155
|
S += m, T.push(
|
|
17156
|
-
b.clone().add(new
|
|
17156
|
+
b.clone().add(new fe(c * Math.cos(S), c * Math.sin(S)))
|
|
17157
17157
|
);
|
|
17158
17158
|
else
|
|
17159
17159
|
for (; S + m > w; )
|
|
17160
17160
|
S += m, T.push(
|
|
17161
|
-
b.clone().add(new
|
|
17161
|
+
b.clone().add(new fe(c * Math.cos(S), c * Math.sin(S)))
|
|
17162
17162
|
);
|
|
17163
|
-
T.push(b.clone().add(new
|
|
17163
|
+
T.push(b.clone().add(new fe(c * Math.cos(w), c * Math.sin(w)))), r.currentPolyline.push(...T);
|
|
17164
17164
|
}
|
|
17165
17165
|
return i;
|
|
17166
17166
|
}
|
|
17167
17167
|
handleBulgeArc(e, t, r) {
|
|
17168
17168
|
let i = t;
|
|
17169
|
-
const s = new
|
|
17169
|
+
const s = new fe();
|
|
17170
17170
|
s.x = Ce.byteToSByte(e[++i]), s.y = Ce.byteToSByte(e[++i]);
|
|
17171
17171
|
const a = Ce.byteToSByte(e[++i]);
|
|
17172
17172
|
return r.currentPoint = this.handleArcSegment(
|
|
@@ -17181,7 +17181,7 @@ var P1 = Fc((L) => {
|
|
|
17181
17181
|
handleMultipleBulgeArcs(e, t, r) {
|
|
17182
17182
|
let i = t;
|
|
17183
17183
|
for (; ; ) {
|
|
17184
|
-
const s = new
|
|
17184
|
+
const s = new fe();
|
|
17185
17185
|
if (s.x = Ce.byteToSByte(e[++i]), s.y = Ce.byteToSByte(e[++i]), s.x === 0 && s.y === 0)
|
|
17186
17186
|
break;
|
|
17187
17187
|
const a = Ce.byteToSByte(e[++i]);
|
|
@@ -17747,9 +17747,9 @@ var P1 = Fc((L) => {
|
|
|
17747
17747
|
if (y >= C)
|
|
17748
17748
|
return 1;
|
|
17749
17749
|
if (y >>>= 0, C >>>= 0, k >>>= 0, O >>>= 0, this === d) return 0;
|
|
17750
|
-
for (var R = O - k, J = C - y, te = Math.min(R, J), oe = this.slice(k, O), be = d.slice(y, C),
|
|
17751
|
-
if (oe[
|
|
17752
|
-
R = oe[
|
|
17750
|
+
for (var R = O - k, J = C - y, te = Math.min(R, J), oe = this.slice(k, O), be = d.slice(y, C), le = 0; le < te; ++le)
|
|
17751
|
+
if (oe[le] !== be[le]) {
|
|
17752
|
+
R = oe[le], J = be[le];
|
|
17753
17753
|
break;
|
|
17754
17754
|
}
|
|
17755
17755
|
return R < J ? -1 : J < R ? 1 : 0;
|
|
@@ -17788,12 +17788,12 @@ var P1 = Fc((L) => {
|
|
|
17788
17788
|
be !== -1 && (oe -= oe - be), be = -1;
|
|
17789
17789
|
} else
|
|
17790
17790
|
for (y + J > R && (y = R - J), oe = y; oe >= 0; oe--) {
|
|
17791
|
-
for (var
|
|
17791
|
+
for (var le = !0, ln = 0; ln < J; ln++)
|
|
17792
17792
|
if (te(F, oe + ln) !== te(d, ln)) {
|
|
17793
|
-
|
|
17793
|
+
le = !1;
|
|
17794
17794
|
break;
|
|
17795
17795
|
}
|
|
17796
|
-
if (
|
|
17796
|
+
if (le) return oe;
|
|
17797
17797
|
}
|
|
17798
17798
|
return -1;
|
|
17799
17799
|
}
|
|
@@ -17880,19 +17880,19 @@ var P1 = Fc((L) => {
|
|
|
17880
17880
|
for (var C = [], k = d; k < y; ) {
|
|
17881
17881
|
var O = F[k], R = null, J = O > 239 ? 4 : O > 223 ? 3 : O > 191 ? 2 : 1;
|
|
17882
17882
|
if (k + J <= y) {
|
|
17883
|
-
var te, oe, be,
|
|
17883
|
+
var te, oe, be, le;
|
|
17884
17884
|
switch (J) {
|
|
17885
17885
|
case 1:
|
|
17886
17886
|
O < 128 && (R = O);
|
|
17887
17887
|
break;
|
|
17888
17888
|
case 2:
|
|
17889
|
-
te = F[k + 1], (te & 192) === 128 && (
|
|
17889
|
+
te = F[k + 1], (te & 192) === 128 && (le = (O & 31) << 6 | te & 63, le > 127 && (R = le));
|
|
17890
17890
|
break;
|
|
17891
17891
|
case 3:
|
|
17892
|
-
te = F[k + 1], oe = F[k + 2], (te & 192) === 128 && (oe & 192) === 128 && (
|
|
17892
|
+
te = F[k + 1], oe = F[k + 2], (te & 192) === 128 && (oe & 192) === 128 && (le = (O & 15) << 12 | (te & 63) << 6 | oe & 63, le > 2047 && (le < 55296 || le > 57343) && (R = le));
|
|
17893
17893
|
break;
|
|
17894
17894
|
case 4:
|
|
17895
|
-
te = F[k + 1], oe = F[k + 2], be = F[k + 3], (te & 192) === 128 && (oe & 192) === 128 && (be & 192) === 128 && (
|
|
17895
|
+
te = F[k + 1], oe = F[k + 2], be = F[k + 3], (te & 192) === 128 && (oe & 192) === 128 && (be & 192) === 128 && (le = (O & 15) << 18 | (te & 63) << 12 | (oe & 63) << 6 | be & 63, le > 65535 && le < 1114112 && (R = le));
|
|
17896
17896
|
}
|
|
17897
17897
|
}
|
|
17898
17898
|
R === null ? (R = 65533, J = 1) : R > 65535 && (R -= 65536, C.push(R >>> 10 & 1023 | 55296), R = 56320 | R & 1023), C.push(R), k += J;
|
|
@@ -28493,7 +28493,7 @@ var P1 = Fc((L) => {
|
|
|
28493
28493
|
i += t, this.addUnsupportedChar(a);
|
|
28494
28494
|
continue;
|
|
28495
28495
|
}
|
|
28496
|
-
r.push(o.offset(new
|
|
28496
|
+
r.push(o.offset(new fe(i, 0))), i += o.width;
|
|
28497
28497
|
}
|
|
28498
28498
|
return r;
|
|
28499
28499
|
}
|
|
@@ -29311,7 +29311,7 @@ var P1 = Fc((L) => {
|
|
|
29311
29311
|
* - underline/overline/strike-through flags
|
|
29312
29312
|
*/
|
|
29313
29313
|
applyPropertyChanges(e) {
|
|
29314
|
-
this.applyFontFaceChange(e.fontFace), this.applyColorCommandChanges(e), this.applyWidthFactorChange(e.widthFactor), this.applyCapHeightChange(e.capHeight), this.applyCharTrackingChange(e.charTrackingFactor), this.
|
|
29314
|
+
this.applyFontFaceChange(e.fontFace), this.applyColorCommandChanges(e), this.applyWidthFactorChange(e.widthFactor), this.applyCapHeightChange(e.capHeight), this.applyCharTrackingChange(e.charTrackingFactor), this.applyParagraphMarginsOnly(e.paragraph), typeof e.underline == "boolean" && (this._currentContext.underline = e.underline), typeof e.overline == "boolean" && (this._currentContext.overline = e.overline), typeof e.strikeThrough == "boolean" && (this._currentContext.strikeThrough = e.strikeThrough), e.oblique !== void 0 && (this._currentContext.oblique = e.oblique);
|
|
29315
29315
|
}
|
|
29316
29316
|
/**
|
|
29317
29317
|
* Apply a font face change to the current render context, including
|
|
@@ -29373,12 +29373,23 @@ var P1 = Fc((L) => {
|
|
|
29373
29373
|
isRelative: !1
|
|
29374
29374
|
});
|
|
29375
29375
|
}
|
|
29376
|
+
/**
|
|
29377
|
+
* Applies indent and margins from a paragraph snapshot only.
|
|
29378
|
+
*
|
|
29379
|
+
* Used when exiting `{}` formatting groups: the parser restores full context
|
|
29380
|
+
* including `paragraph.align`, but paragraph alignment is not scoped to `{}`
|
|
29381
|
+
* (see class comment on `_currentHorizontalAlignment`). Restoring align here
|
|
29382
|
+
* would undo an active `\\p...` alignment before the line is finalized.
|
|
29383
|
+
*/
|
|
29384
|
+
applyParagraphMarginsOnly(e) {
|
|
29385
|
+
e && (typeof e.indent == "number" && (this._currentIndent = e.indent * this.defaultFontSize, this._hOffset += this._currentIndent), typeof e.left == "number" && (this._currentLeftMargin = e.left * this.defaultFontSize), typeof e.right == "number" && (this._currentRightMargin = e.right * this.defaultFontSize));
|
|
29386
|
+
}
|
|
29376
29387
|
/**
|
|
29377
29388
|
* Apply paragraph-level changes such as alignment and margins.
|
|
29378
29389
|
* @param paragraph Paragraph change data.
|
|
29379
29390
|
*/
|
|
29380
29391
|
applyParagraphChange(e) {
|
|
29381
|
-
e && (
|
|
29392
|
+
e && ("align" in e && (this._currentHorizontalAlignment = e.align), typeof e.indent == "number" && (this._currentIndent = e.indent * this.defaultFontSize, this._hOffset += this._currentIndent), typeof e.left == "number" && (this._currentLeftMargin = e.left * this.defaultFontSize), typeof e.right == "number" && (this._currentRightMargin = e.right * this.defaultFontSize));
|
|
29382
29393
|
}
|
|
29383
29394
|
/**
|
|
29384
29395
|
* Reset paragraph properties to their default values from options.
|
|
@@ -29524,7 +29535,7 @@ var P1 = Fc((L) => {
|
|
|
29524
29535
|
let a = 0;
|
|
29525
29536
|
for (let o = 0; o < e.length; o++) {
|
|
29526
29537
|
const h = this.getCharShape(e[o]);
|
|
29527
|
-
h ? this.currentHorizontalAlignment ==
|
|
29538
|
+
h ? this.currentHorizontalAlignment == ce.DISTRIBUTED ? a += h.width * this.currentWidthFactor : a += h.width * this.currentWordSpace * this.currentWidthFactor : a += this._currentContext.blankWidth;
|
|
29528
29539
|
}
|
|
29529
29540
|
this.hOffset + a > (this.maxLineWidth || 1 / 0) && (this._vOffset <= 0 && this._currentLineObjects.length <= 0 || (this.recordVisualLineBreak(i, s), this.advanceToNextLine(!1)));
|
|
29530
29541
|
for (let o = 0; o < e.length; o++)
|
|
@@ -29737,7 +29748,7 @@ var P1 = Fc((L) => {
|
|
|
29737
29748
|
const c = this.fontManager.getFontType(this.currentFont);
|
|
29738
29749
|
this._currentContext.bold && c === "mesh" && o.scale(1.06, 1.06, 1), this.hOffset > (this.maxLineWidth || 1 / 0) && (this.recordVisualLineBreak(i, s), this.advanceToNextLine(!1));
|
|
29739
29750
|
const u = this.hOffset, f = this.flowDirection == Mt.BOTTOM_TO_TOP ? this.vOffset : this.vOffset - this.currentLayoutFontSize, l = a.width * this.currentWidthFactor, p = this.currentLayoutFontSize;
|
|
29740
|
-
if (o.translate(u, f, 0), this.currentHorizontalAlignment ==
|
|
29751
|
+
if (o.translate(u, f, 0), this.currentHorizontalAlignment == ce.DISTRIBUTED ? this._hOffset += a.width * this.currentWidthFactor : this._hOffset += a.width * this.currentWordSpace * this.currentWidthFactor, t.push(o), this._lineHasRenderableChar = !0, this._options.collectCharBoxes !== !1) {
|
|
29741
29752
|
o.userData.char = e, o.boundingBox || o.computeBoundingBox();
|
|
29742
29753
|
const x = new Ee().copy(o.boundingBox);
|
|
29743
29754
|
o instanceof mr ? (this._lastCharBoxTarget = "mesh", i.push({
|
|
@@ -29902,28 +29913,29 @@ var P1 = Fc((L) => {
|
|
|
29902
29913
|
}
|
|
29903
29914
|
};
|
|
29904
29915
|
switch (this.currentHorizontalAlignment) {
|
|
29905
|
-
case
|
|
29916
|
+
case ce.LEFT:
|
|
29917
|
+
case ce.JUSTIFIED: {
|
|
29906
29918
|
const a = this._currentLeftMargin - r.min.x, o = /* @__PURE__ */ new Set();
|
|
29907
29919
|
e.forEach((h) => {
|
|
29908
29920
|
h.geometry.translate(a, 0, 0), o.has(h.owner) || (s(h.owner, a), o.add(h.owner));
|
|
29909
29921
|
});
|
|
29910
29922
|
break;
|
|
29911
29923
|
}
|
|
29912
|
-
case
|
|
29924
|
+
case ce.CENTER: {
|
|
29913
29925
|
const a = this._currentLeftMargin + (this.maxLineWidth - i.x) / 2 - r.min.x, o = /* @__PURE__ */ new Set();
|
|
29914
29926
|
e.forEach((h) => {
|
|
29915
29927
|
h.geometry.translate(a, 0, 0), o.has(h.owner) || (s(h.owner, a), o.add(h.owner));
|
|
29916
29928
|
});
|
|
29917
29929
|
break;
|
|
29918
29930
|
}
|
|
29919
|
-
case
|
|
29931
|
+
case ce.RIGHT: {
|
|
29920
29932
|
const a = this._currentLeftMargin + this.maxLineWidth - i.x - r.min.x, o = /* @__PURE__ */ new Set();
|
|
29921
29933
|
e.forEach((h) => {
|
|
29922
29934
|
h.geometry.translate(a, 0, 0), o.has(h.owner) || (s(h.owner, a), o.add(h.owner));
|
|
29923
29935
|
});
|
|
29924
29936
|
break;
|
|
29925
29937
|
}
|
|
29926
|
-
case
|
|
29938
|
+
case ce.DISTRIBUTED: {
|
|
29927
29939
|
const a = e.length > 1 ? (this.maxLineWidth - i.x) / (e.length - 1) : 0, o = /* @__PURE__ */ new Set();
|
|
29928
29940
|
e.forEach((h, c) => {
|
|
29929
29941
|
const u = a * c + (this._currentLeftMargin - r.min.x);
|
|
@@ -30204,23 +30216,23 @@ var P1 = Fc((L) => {
|
|
|
30204
30216
|
this.styleManager.unsupportedTextStyles[v] || (this.styleManager.unsupportedTextStyles[v] = 0), this.styleManager.unsupportedTextStyles[v]++;
|
|
30205
30217
|
}
|
|
30206
30218
|
const r = e.width || 0, i = Number.isFinite(r) && r > 0;
|
|
30207
|
-
let s =
|
|
30219
|
+
let s = ce.LEFT;
|
|
30208
30220
|
i && e.attachmentPoint && ([
|
|
30209
30221
|
j.TopLeft,
|
|
30210
30222
|
j.MiddleLeft,
|
|
30211
30223
|
j.BottomLeft,
|
|
30212
30224
|
j.BaselineLeft
|
|
30213
|
-
].includes(e.attachmentPoint) ? s =
|
|
30225
|
+
].includes(e.attachmentPoint) ? s = ce.LEFT : [
|
|
30214
30226
|
j.TopCenter,
|
|
30215
30227
|
j.MiddleCenter,
|
|
30216
30228
|
j.BottomCenter,
|
|
30217
30229
|
j.BaselineCenter
|
|
30218
|
-
].includes(e.attachmentPoint) ? s =
|
|
30230
|
+
].includes(e.attachmentPoint) ? s = ce.CENTER : [
|
|
30219
30231
|
j.TopRight,
|
|
30220
30232
|
j.MiddleRight,
|
|
30221
30233
|
j.BottomRight,
|
|
30222
30234
|
j.BaselineRight
|
|
30223
|
-
].includes(e.attachmentPoint) && (s =
|
|
30235
|
+
].includes(e.attachmentPoint) && (s = ce.RIGHT));
|
|
30224
30236
|
let a = _t.BOTTOM;
|
|
30225
30237
|
e.attachmentPoint && ([
|
|
30226
30238
|
j.TopLeft,
|
package/lib/index.d.ts
CHANGED
|
@@ -236,6 +236,15 @@ export declare class MTextProcessor {
|
|
|
236
236
|
* @param charTrackingFactor Character tracking change data.
|
|
237
237
|
*/
|
|
238
238
|
private applyCharTrackingChange;
|
|
239
|
+
/**
|
|
240
|
+
* Applies indent and margins from a paragraph snapshot only.
|
|
241
|
+
*
|
|
242
|
+
* Used when exiting `{}` formatting groups: the parser restores full context
|
|
243
|
+
* including `paragraph.align`, but paragraph alignment is not scoped to `{}`
|
|
244
|
+
* (see class comment on `_currentHorizontalAlignment`). Restoring align here
|
|
245
|
+
* would undo an active `\\p...` alignment before the line is finalized.
|
|
246
|
+
*/
|
|
247
|
+
private applyParagraphMarginsOnly;
|
|
239
248
|
/**
|
|
240
249
|
* Apply paragraph-level changes such as alignment and margins.
|
|
241
250
|
* @param paragraph Paragraph change data.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports from @mlightcad/shx-parser so consumers can use SHX parsing utilities
|
|
3
|
+
* (e.g. character-map SVG preview) without a direct shx-parser dependency.
|
|
4
|
+
*
|
|
5
|
+
* `ShxParserFont` is the parser library font class; this package also exports a
|
|
6
|
+
* renderer-facing `ShxFont` wrapper under `./font/shxFont`.
|
|
7
|
+
*/
|
|
8
|
+
export { ShxFont as ShxParserFont } from '@mlightcad/shx-parser';
|
|
9
|
+
export type { ShxFontData } from '@mlightcad/shx-parser';
|