@mlightcad/mtext-parser 1.0.4 → 1.0.6

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__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.WORD = 1] = "WORD", r[r.STACK = 2] = "STACK", r[r.SPACE = 3] = "SPACE", r[r.NBSP = 4] = "NBSP", r[r.TABULATOR = 5] = "TABULATOR", r[r.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", r[r.NEW_COLUMN = 7] = "NEW_COLUMN", r[r.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", r[r.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED", r))(k || {}), b = /* @__PURE__ */ ((r) => (r[r.BOTTOM = 0] = "BOTTOM", r[r.MIDDLE = 1] = "MIDDLE", r[r.TOP = 2] = "TOP", r))(b || {}), E = /* @__PURE__ */ ((r) => (r[r.DEFAULT = 0] = "DEFAULT", r[r.LEFT = 1] = "LEFT", r[r.RIGHT = 2] = "RIGHT", r[r.CENTER = 3] = "CENTER", r[r.JUSTIFIED = 4] = "JUSTIFIED", r[r.DISTRIBUTED = 5] = "DISTRIBUTED", r))(E || {}), m = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.UNDERLINE = 1] = "UNDERLINE", r[r.OVERLINE = 2] = "OVERLINE", r[r.STRIKE_THROUGH = 4] = "STRIKE_THROUGH", r))(m || {});
2
- const F = {
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
+ const m = {
3
3
  c: "Ø",
4
4
  d: "°",
5
5
  p: "±"
6
- }, S = {
6
+ }, _ = {
7
7
  l: 1,
8
8
  r: 2,
9
9
  c: 3,
@@ -11,36 +11,36 @@ const F = {
11
11
  d: 5
12
12
  /* DISTRIBUTED */
13
13
  };
14
- function N(r) {
15
- const [e, t, s] = r;
16
- return s << 16 | t << 8 | e;
14
+ function v(s) {
15
+ const [e, t, r] = s;
16
+ return r << 16 | t << 8 | e;
17
17
  }
18
- function _(r) {
19
- const e = r & 255, t = r >> 8 & 255, s = r >> 16 & 255;
20
- return [e, t, s];
18
+ function R(s) {
19
+ const e = s & 255, t = s >> 8 & 255, r = s >> 16 & 255;
20
+ return [e, t, r];
21
21
  }
22
- function I(r) {
23
- return r.replace(/\^(.)/g, (e, t) => {
24
- const s = t.charCodeAt(0);
25
- return s === 32 ? "^" : s === 73 ? " " : s === 74 ? `
26
- ` : s === 77 ? "" : "▯";
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
27
  });
28
28
  }
29
- function O(r) {
30
- return r.replace(/\r\n|\r|\n/g, "\\P");
29
+ function I(s) {
30
+ return s.replace(/\r\n|\r|\n/g, "\\P");
31
31
  }
32
- function R(r) {
33
- return r.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
32
+ function N(s) {
33
+ return s.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
34
34
  }
35
- class D {
35
+ class O {
36
36
  /**
37
37
  * Creates a new MTextParser instance
38
38
  * @param content - The MText content to parse
39
39
  * @param ctx - Optional initial MText context
40
40
  * @param yieldPropertyCommands - Whether to yield property change commands
41
41
  */
42
- constructor(e, t, s = !1) {
43
- this.ctxStack = [], this.continueStroke = !1, this.scanner = new p(I(e)), this.ctx = t ?? new f(), this.lastCtx = this.ctx.copy(), this.yieldPropertyCommands = s, this.decoder = new TextDecoder("gbk");
42
+ 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");
44
44
  }
45
45
  /**
46
46
  * Decode multi-byte character from hex code
@@ -76,28 +76,28 @@ class D {
76
76
  */
77
77
  parseStacking() {
78
78
  const e = new p(this.extractExpression(!0));
79
- let t = "", s = "", n = "";
79
+ let t = "", r = "", n = "";
80
80
  const i = () => {
81
- let a = e.peek(), h = !1;
82
- return a.charCodeAt(0) < 32 && (a = " "), a === "\\" && (h = !0, e.consume(1), a = e.peek()), e.consume(1), [a, h];
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
83
  }, c = () => {
84
84
  let a = "";
85
85
  for (; e.hasData; ) {
86
- const [h, o] = i();
87
- if (!o && "^/#".includes(h))
88
- return [a, h];
89
- a += h;
86
+ const [o, h] = i();
87
+ if (!h && "^/#".includes(o))
88
+ return [a, o];
89
+ a += o;
90
90
  }
91
91
  return [a, ""];
92
- }, l = () => {
92
+ }, u = () => {
93
93
  let a = "";
94
94
  for (; e.hasData; ) {
95
- const [h, o] = i();
96
- o && h === ";" ? a += ";" : a += h;
95
+ const [o, h] = i();
96
+ h && o === ";" ? a += ";" : a += o;
97
97
  }
98
98
  return a;
99
99
  };
100
- return [t, n] = c(), n && (s = l()), [2, [t, s, n]];
100
+ return [t, n] = c(), n && (r = u()), [2, [t, r, n]];
101
101
  }
102
102
  /**
103
103
  * Parse MText properties
@@ -157,11 +157,11 @@ class D {
157
157
  throw new Error(`Unknown command: ${e}`);
158
158
  }
159
159
  if (t.continueStroke = this.continueStroke, this.ctx = t, this.yieldPropertyCommands) {
160
- const s = this.getPropertyChanges(this.lastCtx, t);
161
- if (Object.keys(s).length > 0)
160
+ const r = this.getPropertyChanges(this.lastCtx, t);
161
+ if (Object.keys(r).length > 0)
162
162
  return this.lastCtx = this.ctx.copy(), {
163
163
  command: e,
164
- changes: s
164
+ changes: r
165
165
  };
166
166
  }
167
167
  }
@@ -172,12 +172,12 @@ class D {
172
172
  * @returns Object containing changed properties
173
173
  */
174
174
  getPropertyChanges(e, t) {
175
- const s = {};
176
- if (e.underline !== t.underline && (s.underline = t.underline), e.overline !== t.overline && (s.overline = t.overline), e.strikeThrough !== t.strikeThrough && (s.strikeThrough = t.strikeThrough), e.aci !== t.aci && (s.aci = t.aci, s.rgb = t.rgb), e.rgb !== t.rgb && (s.rgb = t.rgb), e.align !== t.align && (s.align = t.align), JSON.stringify(e.fontFace) !== JSON.stringify(t.fontFace) && (s.fontFace = t.fontFace), e.capHeight !== t.capHeight && (s.capHeight = t.capHeight), e.widthFactor !== t.widthFactor && (s.widthFactor = t.widthFactor), e.charTrackingFactor !== t.charTrackingFactor && (s.charTrackingFactor = t.charTrackingFactor), e.oblique !== t.oblique && (s.oblique = t.oblique), JSON.stringify(e.paragraph) !== JSON.stringify(t.paragraph)) {
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.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
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 && (s.paragraph = 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);
179
179
  }
180
- return s;
180
+ return r;
181
181
  }
182
182
  /**
183
183
  * Parse alignment property
@@ -195,7 +195,13 @@ class D {
195
195
  const t = this.extractFloatExpression(!0);
196
196
  if (t)
197
197
  try {
198
- t.endsWith("x") ? e.capHeight = Math.abs(parseFloat(t.slice(0, -1))) : e.capHeight = Math.abs(parseFloat(t));
198
+ t.endsWith("x") ? e.capHeight = {
199
+ value: parseFloat(t.slice(0, -1)),
200
+ isRelative: !0
201
+ } : e.capHeight = {
202
+ value: parseFloat(t),
203
+ isRelative: !1
204
+ };
199
205
  } catch {
200
206
  this.scanner.consume(-t.length);
201
207
  return;
@@ -210,7 +216,13 @@ class D {
210
216
  const t = this.extractFloatExpression(!0);
211
217
  if (t)
212
218
  try {
213
- t.endsWith("x") ? e.widthFactor = Math.abs(parseFloat(t.slice(0, -1))) : e.widthFactor = Math.abs(parseFloat(t));
219
+ t.endsWith("x") ? e.widthFactor = {
220
+ value: parseFloat(t.slice(0, -1)),
221
+ isRelative: !0
222
+ } : e.widthFactor = {
223
+ value: parseFloat(t),
224
+ isRelative: !1
225
+ };
214
226
  } catch {
215
227
  this.scanner.consume(-t.length);
216
228
  return;
@@ -225,7 +237,13 @@ class D {
225
237
  const t = this.extractFloatExpression(!0);
226
238
  if (t)
227
239
  try {
228
- 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
+ };
229
247
  } catch {
230
248
  this.scanner.consume(-t.length);
231
249
  return;
@@ -241,8 +259,8 @@ class D {
241
259
  const t = this.extractFloatExpression(!0);
242
260
  if (t)
243
261
  if (t.endsWith("x")) {
244
- const s = parseFloat(t.slice(0, -1));
245
- e *= Math.abs(s);
262
+ const r = parseFloat(t.slice(0, -1));
263
+ e *= Math.abs(r);
246
264
  } else
247
265
  e = Math.abs(parseFloat(t));
248
266
  return e;
@@ -262,8 +280,8 @@ class D {
262
280
  parseAciColor(e) {
263
281
  const t = this.extractIntExpression();
264
282
  if (t) {
265
- const s = parseInt(t);
266
- s < 257 && (e.aci = s, e.rgb = null);
283
+ const r = parseInt(t);
284
+ r < 257 && (e.aci = r, e.rgb = null);
267
285
  }
268
286
  this.consumeOptionalTerminator();
269
287
  }
@@ -274,7 +292,7 @@ class D {
274
292
  parseRgbColor(e) {
275
293
  const t = this.extractIntExpression();
276
294
  if (t) {
277
- const s = parseInt(t) & 16777215, [n, i, c] = _(s);
295
+ const r = parseInt(t) & 16777215, [n, i, c] = R(r);
278
296
  e.rgb = [c, i, n];
279
297
  }
280
298
  this.consumeOptionalTerminator();
@@ -285,9 +303,9 @@ class D {
285
303
  * @returns Extracted expression
286
304
  */
287
305
  extractFloatExpression(e = !1) {
288
- const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, s = this.scanner.tail.match(t);
289
- if (s) {
290
- const n = s[0];
306
+ const t = e ? /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/ : /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, r = this.scanner.tail.match(t);
307
+ if (r) {
308
+ const n = r[0];
291
309
  return this.scanner.consume(n.length), n;
292
310
  }
293
311
  return "";
@@ -325,12 +343,12 @@ class D {
325
343
  parseFontProperties(e) {
326
344
  const t = this.extractExpression().split("|");
327
345
  if (t.length > 0 && t[0]) {
328
- const s = t[0];
346
+ const r = t[0];
329
347
  let n = "Regular", i = 400;
330
348
  for (const c of t.slice(1))
331
349
  c.startsWith("b1") ? i = 700 : c.startsWith("i1") && (n = "Italic");
332
350
  e.fontFace = {
333
- family: s,
351
+ family: r,
334
352
  style: n,
335
353
  weight: i
336
354
  };
@@ -343,21 +361,21 @@ class D {
343
361
  */
344
362
  parseParagraphProperties(e) {
345
363
  const t = new p(this.extractExpression());
346
- let s = e.paragraph.indent, n = e.paragraph.left, i = e.paragraph.right, c = e.paragraph.align, l = [];
364
+ let r = e.paragraph.indent, n = e.paragraph.left, i = e.paragraph.right, c = e.paragraph.align, u = [];
347
365
  const a = () => {
348
- const h = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
349
- if (h) {
350
- const o = parseFloat(h[0]);
351
- for (t.consume(h[0].length); t.peek() === ","; )
366
+ const o = t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);
367
+ if (o) {
368
+ const h = parseFloat(o[0]);
369
+ for (t.consume(o[0].length); t.peek() === ","; )
352
370
  t.consume(1);
353
- return o;
371
+ return h;
354
372
  }
355
373
  return 0;
356
374
  };
357
375
  for (; t.hasData; )
358
376
  switch (t.get()) {
359
377
  case "i":
360
- s = a();
378
+ r = a();
361
379
  break;
362
380
  case "l":
363
381
  n = a();
@@ -368,31 +386,31 @@ class D {
368
386
  case "x":
369
387
  break;
370
388
  case "q": {
371
- const o = t.get();
372
- for (c = S[o] || 0; t.peek() === ","; )
389
+ const h = t.get();
390
+ for (c = _[h] || 0; t.peek() === ","; )
373
391
  t.consume(1);
374
392
  break;
375
393
  }
376
394
  case "t":
377
- for (l = []; t.hasData; ) {
378
- const o = t.peek();
379
- if (o === "r" || o === "c") {
395
+ for (u = []; t.hasData; ) {
396
+ const h = t.peek();
397
+ if (h === "r" || h === "c") {
380
398
  t.consume(1);
381
- const u = a();
382
- l.push(o + u.toString());
399
+ const l = a();
400
+ u.push(h + l.toString());
383
401
  } else {
384
- const u = a();
385
- isNaN(u) ? t.consume(1) : l.push(u);
402
+ const l = a();
403
+ isNaN(l) ? t.consume(1) : u.push(l);
386
404
  }
387
405
  }
388
406
  break;
389
407
  }
390
408
  e.paragraph = {
391
- indent: s,
409
+ indent: r,
392
410
  left: n,
393
411
  right: i,
394
412
  align: c,
395
- tab_stops: l
413
+ tab_stops: u
396
414
  };
397
415
  }
398
416
  /**
@@ -406,13 +424,13 @@ class D {
406
424
  * @yields MTextToken objects
407
425
  */
408
426
  *parse() {
409
- let s = null;
427
+ let r = null;
410
428
  const n = () => {
411
429
  var c;
412
430
  let i = "";
413
431
  for (; this.scanner.hasData; ) {
414
- let l = !1, a = this.scanner.peek();
415
- const h = this.scanner.currentIndex;
432
+ let u = !1, a = this.scanner.peek();
433
+ const o = this.scanner.currentIndex;
416
434
  if (a.charCodeAt(0) < 32) {
417
435
  if (this.scanner.consume(1), a === " ")
418
436
  return [5, null];
@@ -423,13 +441,13 @@ class D {
423
441
  }
424
442
  if (a === "\\")
425
443
  if ("\\{}".includes(this.scanner.peek(1)))
426
- l = !0, this.scanner.consume(1), a = this.scanner.peek();
444
+ u = !0, this.scanner.consume(1), a = this.scanner.peek();
427
445
  else {
428
446
  if (i)
429
447
  return [1, i];
430
448
  this.scanner.consume(1);
431
- const o = this.scanner.get();
432
- switch (o) {
449
+ const h = this.scanner.get();
450
+ switch (h) {
433
451
  case "~":
434
452
  return [4, null];
435
453
  case "P":
@@ -444,10 +462,10 @@ class D {
444
462
  case "M":
445
463
  if (this.scanner.peek() === "+") {
446
464
  this.scanner.consume(1);
447
- const u = (c = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : c[0];
448
- if (u) {
465
+ const l = (c = this.scanner.tail.match(/^[0-9A-Fa-f]{4}/)) == null ? void 0 : c[0];
466
+ if (l) {
449
467
  this.scanner.consume(4);
450
- const d = this.decodeMultiByteChar(u);
468
+ const d = this.decodeMultiByteChar(l);
451
469
  return i ? [1, i] : [1, d];
452
470
  }
453
471
  this.scanner.consume(-1);
@@ -455,26 +473,26 @@ class D {
455
473
  i += "\\M";
456
474
  continue;
457
475
  default:
458
- if (o)
476
+ if (h)
459
477
  try {
460
- const u = this.parseProperties(o);
461
- if (this.yieldPropertyCommands && u)
462
- return this.lastCtx = this.ctx.copy(), [9, u];
478
+ const l = this.parseProperties(h);
479
+ if (this.yieldPropertyCommands && l)
480
+ return this.lastCtx = this.ctx.copy(), [9, l];
463
481
  continue;
464
482
  } catch {
465
- const u = this.scanner.tail.slice(
466
- h,
483
+ const l = this.scanner.tail.slice(
484
+ o,
467
485
  this.scanner.currentIndex
468
486
  );
469
- i += u;
487
+ i += l;
470
488
  }
471
489
  }
472
490
  continue;
473
491
  }
474
492
  if (a === "%" && this.scanner.peek(1) === "%") {
475
- const o = this.scanner.peek(2).toLowerCase(), u = F[o];
476
- if (u) {
477
- this.scanner.consume(3), i += u;
493
+ const h = this.scanner.peek(2).toLowerCase(), l = m[h];
494
+ if (l) {
495
+ this.scanner.consume(3), i += l;
478
496
  continue;
479
497
  } else {
480
498
  this.scanner.consume(3);
@@ -482,8 +500,8 @@ class D {
482
500
  }
483
501
  }
484
502
  if (a === " ")
485
- return i ? (this.scanner.consume(1), s = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
486
- if (!l) {
503
+ return i ? (this.scanner.consume(1), r = 3, [1, i]) : (this.scanner.consume(1), [3, null]);
504
+ if (!u) {
487
505
  if (a === "{") {
488
506
  if (i)
489
507
  return [1, i];
@@ -503,7 +521,7 @@ class D {
503
521
  for (; ; ) {
504
522
  const [i, c] = n();
505
523
  if (i)
506
- yield new g(i, this.ctx, c), s && (yield new g(s, this.ctx, null), s = null);
524
+ yield new f(i, this.ctx, c), r && (yield new f(r, this.ctx, null), r = null);
507
525
  else
508
526
  break;
509
527
  }
@@ -568,21 +586,21 @@ class p {
568
586
  * @returns Index of the character, or -1 if not found
569
587
  */
570
588
  find(e, t = !1) {
571
- let s = this._index;
572
- for (; s < this.textLen; ) {
573
- if (t && this.text[s] === "\\") {
574
- if (s + 1 < this.textLen) {
575
- if (this.text[s + 1] === e)
576
- return s + 1;
577
- s += 2;
589
+ let r = this._index;
590
+ for (; r < this.textLen; ) {
591
+ if (t && this.text[r] === "\\") {
592
+ if (r + 1 < this.textLen) {
593
+ if (this.text[r + 1] === e)
594
+ return r + 1;
595
+ r += 2;
578
596
  continue;
579
597
  }
580
- s++;
598
+ r++;
581
599
  continue;
582
600
  }
583
- if (this.text[s] === e)
584
- return s;
585
- s++;
601
+ if (this.text[r] === e)
602
+ return r;
603
+ r++;
586
604
  }
587
605
  return -1;
588
606
  }
@@ -609,9 +627,9 @@ class p {
609
627
  return e;
610
628
  }
611
629
  }
612
- class f {
630
+ class g {
613
631
  constructor() {
614
- 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.widthFactor = 1, this.charTrackingFactor = 1, this.oblique = 0, this.paragraph = {
632
+ 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 = {
615
633
  indent: 0,
616
634
  left: 0,
617
635
  right: 0,
@@ -619,6 +637,54 @@ class f {
619
637
  tab_stops: []
620
638
  };
621
639
  }
640
+ /**
641
+ * Get the capital letter height
642
+ */
643
+ get capHeight() {
644
+ return this._capHeight;
645
+ }
646
+ /**
647
+ * Set the capital letter height
648
+ * @param value - Height value
649
+ */
650
+ set capHeight(e) {
651
+ this._capHeight = {
652
+ value: Math.abs(e.value),
653
+ isRelative: e.isRelative
654
+ };
655
+ }
656
+ /**
657
+ * Get the character width factor
658
+ */
659
+ get widthFactor() {
660
+ return this._widthFactor;
661
+ }
662
+ /**
663
+ * Set the character width factor
664
+ * @param value - Width factor value
665
+ */
666
+ set widthFactor(e) {
667
+ this._widthFactor = {
668
+ value: Math.abs(e.value),
669
+ isRelative: e.isRelative
670
+ };
671
+ }
672
+ /**
673
+ * Get the character tracking factor
674
+ */
675
+ get charTrackingFactor() {
676
+ return this._charTrackingFactor;
677
+ }
678
+ /**
679
+ * Set the character tracking factor
680
+ * @param value - Tracking factor value
681
+ */
682
+ set charTrackingFactor(e) {
683
+ this._charTrackingFactor = {
684
+ value: Math.abs(e.value),
685
+ isRelative: e.isRelative
686
+ };
687
+ }
622
688
  /**
623
689
  * Get the ACI color value
624
690
  */
@@ -694,34 +760,34 @@ class f {
694
760
  * @returns A new context with the same properties
695
761
  */
696
762
  copy() {
697
- const e = new f();
698
- 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;
763
+ const e = new g();
764
+ 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;
699
765
  }
700
766
  }
701
- class g {
767
+ class f {
702
768
  /**
703
769
  * Create a new MText token
704
770
  * @param type - The token type
705
771
  * @param ctx - The text context at this token
706
772
  * @param data - Optional token data
707
773
  */
708
- constructor(e, t, s) {
709
- this.type = e, this.ctx = t, this.data = s;
774
+ constructor(e, t, r) {
775
+ this.type = e, this.ctx = t, this.data = r;
710
776
  }
711
777
  }
712
778
  export {
713
- f as MTextContext,
779
+ g as MTextContext,
714
780
  b as MTextLineAlignment,
715
781
  E as MTextParagraphAlignment,
716
- D as MTextParser,
717
- m as MTextStroke,
718
- g as MTextToken,
782
+ O as MTextParser,
783
+ F as MTextStroke,
784
+ f as MTextToken,
719
785
  p as TextScanner,
720
786
  k as TokenType,
721
- I as caretDecode,
722
- O as escapeDxfLineEndings,
723
- R as hasInlineFormattingCodes,
724
- _ as int2rgb,
725
- N as rgb2int
787
+ S as caretDecode,
788
+ I as escapeDxfLineEndings,
789
+ N as hasInlineFormattingCodes,
790
+ R as int2rgb,
791
+ v as rgb2int
726
792
  };
727
793
  //# sourceMappingURL=parser.es.js.map