@mlightcad/mtext-parser 1.0.5 → 1.0.7

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/parser.es.js CHANGED
@@ -1,9 +1,9 @@
1
- var k = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.WORD = 1] = "WORD", s[s.STACK = 2] = "STACK", s[s.SPACE = 3] = "SPACE", s[s.NBSP = 4] = "NBSP", s[s.TABULATOR = 5] = "TABULATOR", s[s.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", s[s.NEW_COLUMN = 7] = "NEW_COLUMN", s[s.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", s[s.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", s))(k || {}), b = /* @__PURE__ */ ((s) => (s[s.BOTTOM = 0] = "BOTTOM", s[s.MIDDLE = 1] = "MIDDLE", s[s.TOP = 2] = "TOP", s))(b || {}), _ = /* @__PURE__ */ ((s) => (s[s.DEFAULT = 0] = "DEFAULT", s[s.LEFT = 1] = "LEFT", s[s.RIGHT = 2] = "RIGHT", s[s.CENTER = 3] = "CENTER", s[s.JUSTIFIED = 4] = "JUSTIFIED", s[s.DISTRIBUTED = 5] = "DISTRIBUTED", s))(_ || {}), E = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.UNDERLINE = 1] = "UNDERLINE", s[s.OVERLINE = 2] = "OVERLINE", s[s.STRIKE_THROUGH = 4] = "STRIKE_THROUGH", s))(E || {});
1
+ var k = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.WORD = 1] = "WORD", s[s.STACK = 2] = "STACK", s[s.SPACE = 3] = "SPACE", s[s.NBSP = 4] = "NBSP", s[s.TABULATOR = 5] = "TABULATOR", s[s.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", s[s.NEW_COLUMN = 7] = "NEW_COLUMN", s[s.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", s[s.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", s))(k || {}), b = /* @__PURE__ */ ((s) => (s[s.BOTTOM = 0] = "BOTTOM", s[s.MIDDLE = 1] = "MIDDLE", s[s.TOP = 2] = "TOP", s))(b || {}), E = /* @__PURE__ */ ((s) => (s[s.DEFAULT = 0] = "DEFAULT", s[s.LEFT = 1] = "LEFT", s[s.RIGHT = 2] = "RIGHT", s[s.CENTER = 3] = "CENTER", s[s.JUSTIFIED = 4] = "JUSTIFIED", s[s.DISTRIBUTED = 5] = "DISTRIBUTED", s))(E || {}), F = /* @__PURE__ */ ((s) => (s[s.NONE = 0] = "NONE", s[s.UNDERLINE = 1] = "UNDERLINE", s[s.OVERLINE = 2] = "OVERLINE", s[s.STRIKE_THROUGH = 4] = "STRIKE_THROUGH", s))(F || {});
2
2
  const m = {
3
3
  c: "Ø",
4
4
  d: "°",
5
5
  p: "±"
6
- }, F = {
6
+ }, _ = {
7
7
  l: 1,
8
8
  r: 2,
9
9
  c: 3,
@@ -11,28 +11,21 @@ const m = {
11
11
  d: 5
12
12
  /* DISTRIBUTED */
13
13
  };
14
- function I(s) {
14
+ function R(s) {
15
15
  const [e, t, r] = s;
16
16
  return r << 16 | t << 8 | e;
17
17
  }
18
- function R(s) {
18
+ function S(s) {
19
19
  const e = s & 255, t = s >> 8 & 255, r = s >> 16 & 255;
20
20
  return [e, t, r];
21
21
  }
22
- function S(s) {
23
- return s.replace(/\^(.)/g, (e, t) => {
24
- const r = t.charCodeAt(0);
25
- return r === 32 ? "^" : r === 73 ? " " : r === 74 ? `
26
- ` : r === 77 ? "" : "▯";
27
- });
28
- }
29
- function N(s) {
22
+ function v(s) {
30
23
  return s.replace(/\r\n|\r|\n/g, "\\P");
31
24
  }
32
- function O(s) {
25
+ function I(s) {
33
26
  return s.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
34
27
  }
35
- class v {
28
+ class N {
36
29
  /**
37
30
  * Creates a new MTextParser instance
38
31
  * @param content - The MText content to parse
@@ -40,7 +33,7 @@ class v {
40
33
  * @param yieldPropertyCommands - Whether to yield property change commands
41
34
  */
42
35
  constructor(e, t, r = !1) {
43
- this.ctxStack = [], this.continueStroke = !1, this.scanner = new p(S(e)), this.ctx = t ?? new g(), this.lastCtx = this.ctx.copy(), this.yieldPropertyCommands = r, this.decoder = new TextDecoder("gbk");
36
+ this.ctxStack = [], this.continueStroke = !1, this.inStackContext = !1, this.scanner = new f(e), this.ctx = t ?? new g(), this.lastCtx = this.ctx.copy(), this.yieldPropertyCommands = r, this.decoder = new TextDecoder("gbk");
44
37
  }
45
38
  /**
46
39
  * Decode multi-byte character from hex code
@@ -52,8 +45,11 @@ class v {
52
45
  const t = new Uint8Array([
53
46
  parseInt(e.substr(0, 2), 16),
54
47
  parseInt(e.substr(2, 2), 16)
55
- ]);
56
- return this.decoder.decode(t);
48
+ ]), a = new TextDecoder("gbk").decode(t);
49
+ if (a !== "▯")
50
+ return a;
51
+ const h = new TextDecoder("big5").decode(t);
52
+ return h !== "▯" ? h : "▯";
57
53
  } catch {
58
54
  return "▯";
59
55
  }
@@ -75,29 +71,33 @@ class v {
75
71
  * @returns Tuple of [TokenType.STACK, [numerator, denominator, type]]
76
72
  */
77
73
  parseStacking() {
78
- const e = new p(this.extractExpression(!0));
79
- let t = "", r = "", n = "";
74
+ const e = new f(this.extractExpression(!0));
75
+ let t = "", r = "", a = "";
80
76
  const i = () => {
81
- let a = e.peek(), o = !1;
82
- return a.charCodeAt(0) < 32 && (a = " "), a === "\\" && (o = !0, e.consume(1), a = e.peek()), e.consume(1), [a, o];
83
- }, c = () => {
84
- let a = "";
77
+ let n = e.peek(), l = !1;
78
+ return n.charCodeAt(0) < 32 && (n = " "), n === "\\" && (l = !0, e.consume(1), n = e.peek()), e.consume(1), [n, l];
79
+ }, h = () => {
80
+ let n = "";
85
81
  for (; e.hasData; ) {
86
- const [o, h] = i();
87
- if (!h && "^/#".includes(o))
88
- return [a, o];
89
- a += o;
82
+ const [l, o] = i();
83
+ if (!o && (l === "/" || l === "#" || l === "^"))
84
+ return [n, l];
85
+ n += l;
90
86
  }
91
- return [a, ""];
92
- }, u = () => {
93
- let a = "";
87
+ return [n, ""];
88
+ }, u = (n) => {
89
+ let l = "", o = n;
94
90
  for (; e.hasData; ) {
95
- const [o, h] = i();
96
- h && o === ";" ? a += ";" : a += o;
91
+ const [c, p] = i();
92
+ if (!(o && c === " ")) {
93
+ if (o = !1, !p && c === ";")
94
+ break;
95
+ l += c;
96
+ }
97
97
  }
98
- return a;
98
+ return l;
99
99
  };
100
- return [t, n] = c(), n && (r = u()), [2, [t, r, n]];
100
+ return [t, a] = h(), a && (r = u(a === "^")), t === "" && r.includes("I/") ? [2, [" ", " ", "/"]] : a === "^" ? [2, [t, r, "^"]] : [2, [t, r, a]];
101
101
  }
102
102
  /**
103
103
  * Parse MText properties
@@ -156,7 +156,7 @@ class v {
156
156
  default:
157
157
  throw new Error(`Unknown command: ${e}`);
158
158
  }
159
- if (t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
159
+ if (this.continueStroke = t.hasAnyStroke, t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
160
160
  const r = this.getPropertyChanges(this.lastCtx, t);
161
161
  if (Object.keys(r).length > 0)
162
162
  return this.lastCtx = this.ctx.copy(), {
@@ -173,9 +173,9 @@ class v {
173
173
  */
174
174
  getPropertyChanges(e, t) {
175
175
  const r = {};
176
- if (e.underline !== t.underline && (r.underline = t.underline), e.overline !== t.overline && (r.overline = t.overline), e.strikeThrough !== t.strikeThrough && (r.strikeThrough = t.strikeThrough), e.aci !== t.aci && (r.aci = t.aci, r.rgb = t.rgb), e.rgb !== t.rgb && (r.rgb = t.rgb), e.align !== t.align && (r.align = t.align), JSON.stringify(e.fontFace) !== JSON.stringify(t.fontFace) && (r.fontFace = t.fontFace), (e.capHeight !== t.capHeight || e.isHeightRelative !== t.isHeightRelative) && (r.capHeight = t.capHeight, r.isHeightRelative = t.isHeightRelative), (e.widthFactor !== t.widthFactor || e.isWidthRelative !== t.isWidthRelative) && (r.widthFactor = t.widthFactor, r.isWidthRelative = t.isWidthRelative), e.charTrackingFactor !== t.charTrackingFactor && (r.charTrackingFactor = t.charTrackingFactor), e.oblique !== t.oblique && (r.oblique = t.oblique), JSON.stringify(e.paragraph) !== JSON.stringify(t.paragraph)) {
177
- const n = {};
178
- e.paragraph.indent !== t.paragraph.indent && (n.indent = t.paragraph.indent), e.paragraph.align !== t.paragraph.align && (n.align = t.paragraph.align), e.paragraph.left !== t.paragraph.left && (n.left = t.paragraph.left), e.paragraph.right !== t.paragraph.right && (n.right = t.paragraph.right), JSON.stringify(e.paragraph.tab_stops) !== JSON.stringify(t.paragraph.tab_stops) && (n.tab_stops = t.paragraph.tab_stops), Object.keys(n).length > 0 && (r.paragraph = n);
176
+ if (e.underline !== t.underline && (r.underline = t.underline), e.overline !== t.overline && (r.overline = t.overline), e.strikeThrough !== t.strikeThrough && (r.strikeThrough = t.strikeThrough), e.aci !== t.aci && (r.aci = t.aci, r.rgb = t.rgb), e.rgb !== t.rgb && (r.rgb = t.rgb), e.align !== t.align && (r.align = t.align), JSON.stringify(e.fontFace) !== JSON.stringify(t.fontFace) && (r.fontFace = t.fontFace), (e.capHeight.value !== t.capHeight.value || e.capHeight.isRelative !== t.capHeight.isRelative) && (r.capHeight = t.capHeight), (e.widthFactor.value !== t.widthFactor.value || e.widthFactor.isRelative !== t.widthFactor.isRelative) && (r.widthFactor = t.widthFactor), (e.charTrackingFactor.value !== t.charTrackingFactor.value || e.charTrackingFactor.isRelative !== t.charTrackingFactor.isRelative) && (r.charTrackingFactor = t.charTrackingFactor), e.oblique !== t.oblique && (r.oblique = t.oblique), JSON.stringify(e.paragraph) !== JSON.stringify(t.paragraph)) {
177
+ const a = {};
178
+ e.paragraph.indent !== t.paragraph.indent && (a.indent = t.paragraph.indent), e.paragraph.align !== t.paragraph.align && (a.align = t.paragraph.align), e.paragraph.left !== t.paragraph.left && (a.left = t.paragraph.left), e.paragraph.right !== t.paragraph.right && (a.right = t.paragraph.right), JSON.stringify(e.paragraph.tab_stops) !== JSON.stringify(t.paragraph.tab_stops) && (a.tab_stops = t.paragraph.tab_stops), Object.keys(a).length > 0 && (r.paragraph = a);
179
179
  }
180
180
  return r;
181
181
  }
@@ -237,7 +237,13 @@ class v {
237
237
  const t = this.extractFloatExpression(!0);
238
238
  if (t)
239
239
  try {
240
- t.endsWith("x") ? e.charTrackingFactor = Math.abs(parseFloat(t.slice(0, -1))) : e.charTrackingFactor = Math.abs(parseFloat(t));
240
+ t.endsWith("x") ? e.charTrackingFactor = {
241
+ value: Math.abs(parseFloat(t.slice(0, -1))),
242
+ isRelative: !0
243
+ } : e.charTrackingFactor = {
244
+ value: Math.abs(parseFloat(t)),
245
+ isRelative: !1
246
+ };
241
247
  } catch {
242
248
  this.scanner.consume(-t.length);
243
249
  return;
@@ -254,9 +260,9 @@ class v {
254
260
  if (t)
255
261
  if (t.endsWith("x")) {
256
262
  const r = parseFloat(t.slice(0, -1));
257
- e *= Math.abs(r);
263
+ e *= r;
258
264
  } else
259
- e = Math.abs(parseFloat(t));
265
+ e = parseFloat(t);
260
266
  return e;
261
267
  }
262
268
  /**
@@ -286,8 +292,8 @@ class v {
286
292
  parseRgbColor(e) {
287
293
  const t = this.extractIntExpression();
288
294
  if (t) {
289
- const r = parseInt(t) & 16777215, [n, i, c] = R(r);
290
- e.rgb = [c, i, n];
295
+ const r = parseInt(t) & 16777215, [a, i, h] = S(r);
296
+ e.rgb = [h, i, a];
291
297
  }
292
298
  this.consumeOptionalTerminator();
293
299
  }
@@ -299,8 +305,8 @@ class v {
299
305
  extractFloatExpression(e = !1) {
300
306
  const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, r = this.scanner.tail.match(t);
301
307
  if (r) {
302
- const n = r[0];
303
- return this.scanner.consume(n.length), n;
308
+ const a = r[0];
309
+ return this.scanner.consume(a.length), a;
304
310
  }
305
311
  return "";
306
312
  }
@@ -324,10 +330,10 @@ class v {
324
330
  extractExpression(e = !1) {
325
331
  const t = this.scanner.find(";", e);
326
332
  if (t < 0) {
327
- const c = this.scanner.tail;
328
- return this.scanner.consume(c.length), c;
333
+ const h = this.scanner.tail;
334
+ return this.scanner.consume(h.length), h;
329
335
  }
330
- const n = this.scanner.peek(t - this.scanner.currentIndex - 1) === "\\", i = this.scanner.tail.slice(0, t - this.scanner.currentIndex + (n ? 1 : 0));
336
+ const a = this.scanner.peek(t - this.scanner.currentIndex - 1) === "\\", i = this.scanner.tail.slice(0, t - this.scanner.currentIndex + (a ? 1 : 0));
331
337
  return this.scanner.consume(i.length + 1), i;
332
338
  }
333
339
  /**
@@ -338,12 +344,12 @@ class v {
338
344
  const t = this.extractExpression().split("|");
339
345
  if (t.length > 0 && t[0]) {
340
346
  const r = t[0];
341
- let n = "Regular", i = 400;
342
- for (const c of t.slice(1))
343
- c.startsWith("b1") ? i = 700 : c.startsWith("i1") && (n = "Italic");
347
+ let a = "Regular", i = 400;
348
+ for (const h of t.slice(1))
349
+ h.startsWith("b1") ? i = 700 : h.startsWith("i1") && (a = "Italic");
344
350
  e.fontFace = {
345
351
  family: r,
346
- style: n,
352
+ style: a,
347
353
  weight: i
348
354
  };
349
355
  }
@@ -354,56 +360,56 @@ class v {
354
360
  * @param ctx - The context to update
355
361
  */
356
362
  parseParagraphProperties(e) {
357
- const t = new p(this.extractExpression());
358
- let r = e.paragraph.indent, n = e.paragraph.left, i = e.paragraph.right, c = e.paragraph.align, u = [];
359
- const a = () => {
360
- const o = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
361
- if (o) {
362
- const h = parseFloat(o[0]);
363
- for (t.consume(o[0].length); t.peek() === ","; )
363
+ const t = new f(this.extractExpression());
364
+ let r = e.paragraph.indent, a = e.paragraph.left, i = e.paragraph.right, h = e.paragraph.align, u = [];
365
+ const n = () => {
366
+ const l = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
367
+ if (l) {
368
+ const o = parseFloat(l[0]);
369
+ for (t.consume(l[0].length); t.peek() === ","; )
364
370
  t.consume(1);
365
- return h;
371
+ return o;
366
372
  }
367
373
  return 0;
368
374
  };
369
375
  for (; t.hasData; )
370
376
  switch (t.get()) {
371
377
  case "i":
372
- r = a();
378
+ r = n();
373
379
  break;
374
380
  case "l":
375
- n = a();
381
+ a = n();
376
382
  break;
377
383
  case "r":
378
- i = a();
384
+ i = n();
379
385
  break;
380
386
  case "x":
381
387
  break;
382
388
  case "q": {
383
- const h = t.get();
384
- for (c = F[h] || 0; t.peek() === ","; )
389
+ const o = t.get();
390
+ for (h = _[o] || 0; t.peek() === ","; )
385
391
  t.consume(1);
386
392
  break;
387
393
  }
388
394
  case "t":
389
395
  for (u = []; t.hasData; ) {
390
- const h = t.peek();
391
- if (h === "r" || h === "c") {
396
+ const o = t.peek();
397
+ if (o === "r" || o === "c") {
392
398
  t.consume(1);
393
- const l = a();
394
- u.push(h + l.toString());
399
+ const c = n();
400
+ u.push(o + c.toString());
395
401
  } else {
396
- const l = a();
397
- isNaN(l) ? t.consume(1) : u.push(l);
402
+ const c = n();
403
+ isNaN(c) ? t.consume(1) : u.push(c);
398
404
  }
399
405
  }
400
406
  break;
401
407
  }
402
408
  e.paragraph = {
403
409
  indent: r,
404
- left: n,
410
+ left: a,
405
411
  right: i,
406
- align: c,
412
+ align: h,
407
413
  tab_stops: u
408
414
  };
409
415
  }
@@ -419,29 +425,29 @@ class v {
419
425
  */
420
426
  *parse() {
421
427
  let r = null;
422
- const n = () => {
423
- var c;
428
+ const a = () => {
429
+ var h;
424
430
  let i = "";
425
431
  for (; this.scanner.hasData; ) {
426
- let u = !1, a = this.scanner.peek();
427
- const o = this.scanner.currentIndex;
428
- if (a.charCodeAt(0) < 32) {
429
- if (this.scanner.consume(1), a === " ")
432
+ let u = !1, n = this.scanner.peek();
433
+ const l = this.scanner.currentIndex;
434
+ if (n.charCodeAt(0) < 32) {
435
+ if (this.scanner.consume(1), n === " ")
430
436
  return [5, null];
431
- if (a === `
437
+ if (n === `
432
438
  `)
433
439
  return [6, null];
434
- a = " ";
440
+ n = " ";
435
441
  }
436
- if (a === "\\")
442
+ if (n === "\\")
437
443
  if ("\\{}".includes(this.scanner.peek(1)))
438
- u = !0, this.scanner.consume(1), a = this.scanner.peek();
444
+ u = !0, this.scanner.consume(1), n = this.scanner.peek();
439
445
  else {
440
446
  if (i)
441
447
  return [1, i];
442
448
  this.scanner.consume(1);
443
- const h = this.scanner.get();
444
- switch (h) {
449
+ const o = this.scanner.get();
450
+ switch (o) {
445
451
  case "~":
446
452
  return [4, null];
447
453
  case "P":
@@ -450,78 +456,99 @@ class v {
450
456
  return [7, null];
451
457
  case "X":
452
458
  return [8, null];
453
- case "S":
454
- return this.parseStacking();
459
+ case "S": {
460
+ this.inStackContext = !0;
461
+ const c = this.parseStacking();
462
+ return this.inStackContext = !1, c;
463
+ }
455
464
  case "m":
456
465
  case "M":
457
466
  if (this.scanner.peek() === "+") {
458
467
  this.scanner.consume(1);
459
- const l = (c = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : c[0];
460
- if (l) {
468
+ const c = (h = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : h[0];
469
+ if (c) {
461
470
  this.scanner.consume(4);
462
- const d = this.decodeMultiByteChar(l);
463
- return i ? [1, i] : [1, d];
471
+ const p = this.decodeMultiByteChar(c);
472
+ return i ? [1, i] : [1, p];
464
473
  }
465
474
  this.scanner.consume(-1);
466
475
  }
467
476
  i += "\\M";
468
477
  continue;
469
478
  default:
470
- if (h)
479
+ if (o)
471
480
  try {
472
- const l = this.parseProperties(h);
473
- if (this.yieldPropertyCommands && l)
474
- return this.lastCtx = this.ctx.copy(), [9, l];
481
+ const c = this.parseProperties(o);
482
+ if (this.yieldPropertyCommands && c)
483
+ return this.lastCtx = this.ctx.copy(), [9, c];
475
484
  continue;
476
485
  } catch {
477
- const l = this.scanner.tail.slice(
478
- o,
486
+ const c = this.scanner.tail.slice(
487
+ l,
479
488
  this.scanner.currentIndex
480
489
  );
481
- i += l;
490
+ i += c;
482
491
  }
483
492
  }
484
493
  continue;
485
494
  }
486
- if (a === "%" && this.scanner.peek(1) === "%") {
487
- const h = this.scanner.peek(2).toLowerCase(), l = m[h];
488
- if (l) {
489
- this.scanner.consume(3), i += l;
495
+ if (n === "%" && this.scanner.peek(1) === "%") {
496
+ const o = this.scanner.peek(2).toLowerCase(), c = m[o];
497
+ if (c) {
498
+ this.scanner.consume(3), i += c;
490
499
  continue;
491
500
  } else {
492
501
  this.scanner.consume(3);
493
502
  continue;
494
503
  }
495
504
  }
496
- if (a === " ")
505
+ if (n === " ")
497
506
  return i ? (this.scanner.consume(1), r = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
498
507
  if (!u) {
499
- if (a === "{") {
508
+ if (n === "{") {
500
509
  if (i)
501
510
  return [1, i];
502
511
  this.scanner.consume(1), this.pushCtx();
503
512
  continue;
504
- } else if (a === "}") {
513
+ } else if (n === "}") {
505
514
  if (i)
506
515
  return [1, i];
507
516
  this.scanner.consume(1), this.popCtx();
508
517
  continue;
509
518
  }
510
519
  }
511
- this.scanner.consume(1), a.charCodeAt(0) >= 32 && (i += a);
520
+ if (!this.inStackContext && n === "^") {
521
+ const o = this.scanner.peek(1);
522
+ if (o) {
523
+ const c = o.charCodeAt(0);
524
+ if (this.scanner.consume(2), c === 32)
525
+ i += "^";
526
+ else {
527
+ if (c === 73)
528
+ return i ? [1, i] : [5, null];
529
+ if (c === 74)
530
+ return i ? [1, i] : [6, null];
531
+ if (c === 77)
532
+ continue;
533
+ i += "▯";
534
+ }
535
+ continue;
536
+ }
537
+ }
538
+ this.scanner.consume(1), n.charCodeAt(0) >= 32 && (i += n);
512
539
  }
513
540
  return i ? [1, i] : [0, null];
514
541
  };
515
542
  for (; ; ) {
516
- const [i, c] = n();
543
+ const [i, h] = a();
517
544
  if (i)
518
- yield new f(i, this.ctx, c), r && (yield new f(r, this.ctx, null), r = null);
545
+ yield new d(i, this.ctx, h), r && (yield new d(r, this.ctx, null), r = null);
519
546
  else
520
547
  break;
521
548
  }
522
549
  }
523
550
  }
524
- class p {
551
+ class f {
525
552
  /**
526
553
  * Create a new text scanner
527
554
  * @param text - The text to scan
@@ -623,7 +650,7 @@ class p {
623
650
  }
624
651
  class g {
625
652
  constructor() {
626
- this._stroke = 0, this.continueStroke = !1, this._aci = 7, this.rgb = null, this.align = 0, this.fontFace = { family: "", style: "Regular", weight: 400 }, this._capHeight = 1, this._isHeightRelative = !1, this._widthFactor = 1, this._isWidthRelative = !1, this.charTrackingFactor = 1, this.oblique = 0, this.paragraph = {
653
+ this._stroke = 0, this.continueStroke = !1, this._aci = 7, this.rgb = null, this.align = 0, this.fontFace = { family: "", style: "Regular", weight: 400 }, this._capHeight = { value: 1, isRelative: !1 }, this._widthFactor = { value: 1, isRelative: !1 }, this._charTrackingFactor = { value: 1, isRelative: !1 }, this.oblique = 0, this.paragraph = {
627
654
  indent: 0,
628
655
  left: 0,
629
656
  right: 0,
@@ -640,16 +667,12 @@ class g {
640
667
  /**
641
668
  * Set the capital letter height
642
669
  * @param value - Height value
643
- * @param isRelative - Whether the value is relative
644
670
  */
645
671
  set capHeight(e) {
646
- this._capHeight = Math.abs(e.value), this._isHeightRelative = e.isRelative;
647
- }
648
- /**
649
- * Get whether height is relative
650
- */
651
- get isHeightRelative() {
652
- return this._isHeightRelative;
672
+ this._capHeight = {
673
+ value: Math.abs(e.value),
674
+ isRelative: e.isRelative
675
+ };
653
676
  }
654
677
  /**
655
678
  * Get the character width factor
@@ -660,16 +683,28 @@ class g {
660
683
  /**
661
684
  * Set the character width factor
662
685
  * @param value - Width factor value
663
- * @param isRelative - Whether the value is relative
664
686
  */
665
687
  set widthFactor(e) {
666
- this._widthFactor = Math.abs(e.value), this._isWidthRelative = e.isRelative;
688
+ this._widthFactor = {
689
+ value: Math.abs(e.value),
690
+ isRelative: e.isRelative
691
+ };
667
692
  }
668
693
  /**
669
- * Get whether width is relative
694
+ * Get the character tracking factor
670
695
  */
671
- get isWidthRelative() {
672
- return this._isWidthRelative;
696
+ get charTrackingFactor() {
697
+ return this._charTrackingFactor;
698
+ }
699
+ /**
700
+ * Set the character tracking factor
701
+ * @param value - Tracking factor value
702
+ */
703
+ set charTrackingFactor(e) {
704
+ this._charTrackingFactor = {
705
+ value: Math.abs(e.value),
706
+ isRelative: e.isRelative
707
+ };
673
708
  }
674
709
  /**
675
710
  * Get the ACI color value
@@ -747,10 +782,10 @@ class g {
747
782
  */
748
783
  copy() {
749
784
  const e = new g();
750
- return e._stroke = this._stroke, e.continueStroke = this.continueStroke, e._aci = this._aci, e.rgb = this.rgb, e.align = this.align, e.fontFace = { ...this.fontFace }, e._capHeight = this._capHeight, e._isHeightRelative = this._isHeightRelative, e._widthFactor = this._widthFactor, e._isWidthRelative = this._isWidthRelative, e.charTrackingFactor = this.charTrackingFactor, e.oblique = this.oblique, e.paragraph = { ...this.paragraph }, e;
785
+ return e._stroke = this._stroke, e.continueStroke = this.continueStroke, e._aci = this._aci, e.rgb = this.rgb, e.align = this.align, e.fontFace = { ...this.fontFace }, e._capHeight = { ...this._capHeight }, e._widthFactor = { ...this._widthFactor }, e._charTrackingFactor = { ...this._charTrackingFactor }, e.oblique = this.oblique, e.paragraph = { ...this.paragraph }, e;
751
786
  }
752
787
  }
753
- class f {
788
+ class d {
754
789
  /**
755
790
  * Create a new MText token
756
791
  * @param type - The token type
@@ -764,16 +799,15 @@ class f {
764
799
  export {
765
800
  g as MTextContext,
766
801
  b as MTextLineAlignment,
767
- _ as MTextParagraphAlignment,
768
- v as MTextParser,
769
- E as MTextStroke,
770
- f as MTextToken,
771
- p as TextScanner,
802
+ E as MTextParagraphAlignment,
803
+ N as MTextParser,
804
+ F as MTextStroke,
805
+ d as MTextToken,
806
+ f as TextScanner,
772
807
  k as TokenType,
773
- S as caretDecode,
774
- N as escapeDxfLineEndings,
775
- O as hasInlineFormattingCodes,
776
- R as int2rgb,
777
- I as rgb2int
808
+ v as escapeDxfLineEndings,
809
+ I as hasInlineFormattingCodes,
810
+ S as int2rgb,
811
+ R as rgb2int
778
812
  };
779
813
  //# sourceMappingURL=parser.es.js.map