@syncfusion/ej2-pdf-data-extract 31.1.17 → 31.1.19

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.
Files changed (60) hide show
  1. package/dist/ej2-pdf-data-extract.umd.min.js +1 -1
  2. package/dist/global/ej2-pdf-data-extract.min.js +1 -1
  3. package/dist/global/index.d.ts +1 -1
  4. package/package.json +12 -44
  5. package/dist/ts/index.d.ts +0 -23
  6. package/dist/ts/index.ts +0 -23
  7. package/dist/ts/pdf-data-extract/core/content-parser-helper.d.ts +0 -62
  8. package/dist/ts/pdf-data-extract/core/content-parser-helper.ts +0 -661
  9. package/dist/ts/pdf-data-extract/core/enum.d.ts +0 -6
  10. package/dist/ts/pdf-data-extract/core/enum.ts +0 -6
  11. package/dist/ts/pdf-data-extract/core/graphic-state.d.ts +0 -33
  12. package/dist/ts/pdf-data-extract/core/graphic-state.ts +0 -106
  13. package/dist/ts/pdf-data-extract/core/pdf-data-extractor.d.ts +0 -210
  14. package/dist/ts/pdf-data-extract/core/pdf-data-extractor.ts +0 -998
  15. package/dist/ts/pdf-data-extract/core/pdf-text-parser.d.ts +0 -63
  16. package/dist/ts/pdf-data-extract/core/pdf-text-parser.ts +0 -498
  17. package/dist/ts/pdf-data-extract/core/redaction/index.d.ts +0 -7
  18. package/dist/ts/pdf-data-extract/core/redaction/index.ts +0 -7
  19. package/dist/ts/pdf-data-extract/core/redaction/pdf-path-segment.d.ts +0 -24
  20. package/dist/ts/pdf-data-extract/core/redaction/pdf-path-segment.ts +0 -59
  21. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-processor.d.ts +0 -55
  22. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-processor.ts +0 -590
  23. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-region.d.ts +0 -281
  24. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-region.ts +0 -342
  25. package/dist/ts/pdf-data-extract/core/redaction/pdf-redactor.d.ts +0 -172
  26. package/dist/ts/pdf-data-extract/core/redaction/pdf-redactor.ts +0 -414
  27. package/dist/ts/pdf-data-extract/core/redaction/pdf-shape-redaction.d.ts +0 -45
  28. package/dist/ts/pdf-data-extract/core/redaction/pdf-shape-redaction.ts +0 -281
  29. package/dist/ts/pdf-data-extract/core/redaction/shape-parser-helper.d.ts +0 -32
  30. package/dist/ts/pdf-data-extract/core/redaction/shape-parser-helper.ts +0 -479
  31. package/dist/ts/pdf-data-extract/core/redaction/text-glyph-mapper.d.ts +0 -12
  32. package/dist/ts/pdf-data-extract/core/redaction/text-glyph-mapper.ts +0 -153
  33. package/dist/ts/pdf-data-extract/core/text-extraction/binary-cmap-reader.d.ts +0 -24
  34. package/dist/ts/pdf-data-extract/core/text-extraction/binary-cmap-reader.ts +0 -281
  35. package/dist/ts/pdf-data-extract/core/text-extraction/cmap.d.ts +0 -50
  36. package/dist/ts/pdf-data-extract/core/text-extraction/cmap.ts +0 -565
  37. package/dist/ts/pdf-data-extract/core/text-extraction/compact-font-parser.d.ts +0 -191
  38. package/dist/ts/pdf-data-extract/core/text-extraction/compact-font-parser.ts +0 -1928
  39. package/dist/ts/pdf-data-extract/core/text-extraction/encoding-utils.d.ts +0 -102
  40. package/dist/ts/pdf-data-extract/core/text-extraction/encoding-utils.ts +0 -5780
  41. package/dist/ts/pdf-data-extract/core/text-extraction/font-structure.d.ts +0 -167
  42. package/dist/ts/pdf-data-extract/core/text-extraction/font-structure.ts +0 -1842
  43. package/dist/ts/pdf-data-extract/core/text-extraction/font-tables.d.ts +0 -5
  44. package/dist/ts/pdf-data-extract/core/text-extraction/font-tables.ts +0 -16
  45. package/dist/ts/pdf-data-extract/core/text-extraction/font-utils.d.ts +0 -18
  46. package/dist/ts/pdf-data-extract/core/text-extraction/font-utils.ts +0 -630
  47. package/dist/ts/pdf-data-extract/core/text-extraction/glyph.d.ts +0 -93
  48. package/dist/ts/pdf-data-extract/core/text-extraction/glyph.ts +0 -622
  49. package/dist/ts/pdf-data-extract/core/text-extraction/index.d.ts +0 -10
  50. package/dist/ts/pdf-data-extract/core/text-extraction/index.ts +0 -10
  51. package/dist/ts/pdf-data-extract/core/text-extraction/matrix-helper.d.ts +0 -38
  52. package/dist/ts/pdf-data-extract/core/text-extraction/matrix-helper.ts +0 -150
  53. package/dist/ts/pdf-data-extract/core/text-extraction/metrics.d.ts +0 -16
  54. package/dist/ts/pdf-data-extract/core/text-extraction/metrics.ts +0 -2938
  55. package/dist/ts/pdf-data-extract/core/text-structure.d.ts +0 -628
  56. package/dist/ts/pdf-data-extract/core/text-structure.ts +0 -668
  57. package/dist/ts/pdf-data-extract/core/utils.d.ts +0 -99
  58. package/dist/ts/pdf-data-extract/core/utils.ts +0 -626
  59. package/dist/ts/pdf-data-extract/index.d.ts +0 -23
  60. package/dist/ts/pdf-data-extract/index.ts +0 -23
@@ -1,622 +0,0 @@
1
- const _onCurvePoint: number = 1 << 0;
2
- const _xShortVector: number = 1 << 1;
3
- const _yShortVector: number = 1 << 2;
4
- const _repeatFlag: number = 1 << 3;
5
- const _xOrPostiveXshortVector: number = 1 << 4;
6
- const _yOrPostiveXshortVector: number = 1 << 5;
7
- const _simpleOverlap: number = 1 << 6;
8
- const _words: number = 1 << 0;
9
- const _argsAreXYValues: number = 1 << 1;
10
- const _scale: number = 1 << 3;
11
- const _moreComponents: number = 1 << 5;
12
- const _xyScale: number = 1 << 6;
13
- const _twoByTwo: number = 1 << 7;
14
- const _instructions: number = 1 << 8;
15
- export class _PdfGlyphTable {
16
- glyphs: _PdfGlyph[];
17
- constructor({
18
- glyfTable,
19
- isGlyphLocationsLong,
20
- locaTable,
21
- numGlyphs
22
- }: {
23
- glyfTable: DataView;
24
- isGlyphLocationsLong: boolean;
25
- locaTable: DataView;
26
- numGlyphs: number;
27
- }) {
28
- this.glyphs = [];
29
- const loca: DataView = new DataView(
30
- locaTable.buffer,
31
- locaTable.byteOffset,
32
- locaTable.byteLength
33
- );
34
- const data: DataView = new DataView(
35
- glyfTable.buffer,
36
- glyfTable.byteOffset,
37
- glyfTable.byteLength
38
- );
39
- const offsetSize: number = isGlyphLocationsLong ? 4 : 2;
40
- let prev: number = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
41
- let pos: number = 0;
42
- for (let i: number = 0; i < numGlyphs; i++) {
43
- pos += offsetSize;
44
- const next: number = isGlyphLocationsLong ? loca.getUint32(pos) : 2 * loca.getUint16(pos);
45
- if (next === prev) {
46
- this.glyphs.push(new _PdfGlyph({}));
47
- continue;
48
- }
49
- const pdfGlyph: _PdfGlyph = new _PdfGlyph();
50
- const glyph: any = pdfGlyph.parse(prev, data); //eslint-disable-line
51
- this.glyphs.push(glyph);
52
- prev = next;
53
- }
54
- }
55
- _getSize(): number {
56
- return this.glyphs.reduce((a, g) => { //eslint-disable-line
57
- const size: number = g._getSize();
58
- return a + ((size + 3) & ~3);
59
- }, 0);
60
- }
61
- _write(): {
62
- isLocationLong: boolean;
63
- loca: Uint8Array;
64
- data: Uint8Array;
65
- } {
66
- const totalSize: number = this._getSize();
67
- const glyfTable: DataView = new DataView(new ArrayBuffer(totalSize));
68
- const isLocationLong: boolean = totalSize > /* 0xffff * 2 */ 0x1fffe;
69
- const offsetSize: number = isLocationLong ? 4 : 2;
70
- const locaTable: DataView = new DataView(
71
- new ArrayBuffer((this.glyphs.length + 1) * offsetSize)
72
- );
73
- if (isLocationLong) {
74
- locaTable.setUint32(0, 0);
75
- } else {
76
- locaTable.setUint16(0, 0);
77
- }
78
- let pos: number = 0;
79
- let locaIndex: number = 0;
80
- for (const glyph of this.glyphs) {
81
- pos += glyph._write(pos, glyfTable);
82
- pos = (pos + 3) & ~3;
83
- locaIndex += offsetSize;
84
- if (isLocationLong) {
85
- locaTable.setUint32(locaIndex, pos);
86
- } else {
87
- locaTable.setUint16(locaIndex, pos >> 1);
88
- }
89
- }
90
- return {
91
- isLocationLong,
92
- loca: new Uint8Array(locaTable.buffer),
93
- data: new Uint8Array(glyfTable.buffer)
94
- };
95
- }
96
- scale(factors: number[]): void {
97
- for (let i: number = 0, ii: number = this.glyphs.length; i < ii; i++) {
98
- this.glyphs[Number.parseInt(i.toString(), 10)]._scale(factors[Number.parseInt(i.toString(), 10)]);
99
- }
100
- }
101
- }
102
- export class _PdfGlyph {
103
- header: _GlyphHeader | null;
104
- simple: _SimpleGlyph | null;
105
- composites: _CompositeGlyph[] | null;
106
- constructor();
107
- constructor({ header, simple, composites }: { header?: _GlyphHeader | null; simple?: _SimpleGlyph | null;
108
- composites?: _CompositeGlyph[] | null; });
109
- constructor(params?: { header?: _GlyphHeader; simple?: _SimpleGlyph; composites?: _CompositeGlyph[]; }) {
110
- if (params) {
111
- this.header = params.header;
112
- this.simple = params.simple;
113
- this.composites = params.composites;
114
- } else {
115
- this.header = null;
116
- this.simple = null;
117
- this.composites = null;
118
- }
119
- }
120
- parse(pos: number, data: any): _PdfGlyph { //eslint-disable-line
121
- const glyphHeader: _GlyphHeader = new _GlyphHeader();
122
- const [read, header] = glyphHeader.parse(pos, data);
123
- pos += read;
124
- if (header.numberOfContours < 0) {
125
- const composites: _CompositeGlyph[] = [];
126
- const compositeGlyph: _CompositeGlyph = new _CompositeGlyph();
127
- while (true) { //eslint-disable-line
128
- const [n, composite] = compositeGlyph.parse(pos, data);
129
- pos += n;
130
- composites.push(composite);
131
- if (!(composite.flags & _moreComponents)) {
132
- break;
133
- }
134
- }
135
- return new _PdfGlyph({ header, composites });
136
- }
137
- const simpleGlyph: _SimpleGlyph = new _SimpleGlyph();
138
- const simple: any = simpleGlyph.parse(pos, data, header.numberOfContours); //eslint-disable-line
139
- return new _PdfGlyph({ header, simple });
140
- }
141
- _getSize(): number {
142
- if (!this.header) {
143
- return 0;
144
- }
145
- const size: any = this.simple //eslint-disable-line
146
- ? this.simple.getSize()
147
- : this.composites!.reduce((a, c) => a + c.getSize(), 0); //eslint-disable-line
148
- return this.header.getSize() + size;
149
- }
150
- _write(pos: number, buffer: any): number { //eslint-disable-line
151
- if (!this.header) {
152
- return 0;
153
- }
154
- const spos: number = pos;
155
- pos += this.header.write(pos, buffer);
156
- if (this.simple) {
157
- pos += this.simple.write(pos, buffer);
158
- } else {
159
- for (const composite of this.composites) {
160
- pos += composite.write(pos, buffer);
161
- }
162
- }
163
- return pos - spos;
164
- }
165
- _scale(factor: number): void {
166
- if (!this.header) {
167
- return;
168
- }
169
- const xMiddle: number = (this.header.xMin + this.header.xMax) / 2;
170
- this.header.scale(xMiddle, factor);
171
- if (this.simple) {
172
- this.simple.scale(xMiddle, factor);
173
- }
174
- }
175
- }
176
- export class _GlyphHeader {
177
- numberOfContours: number;
178
- xMin: number;
179
- yMin: number;
180
- xMax: number;
181
- yMax: number;
182
- constructor();
183
- constructor({ numberOfContours, xMin, yMin, xMax, yMax }:
184
- { numberOfContours: number; xMin: number; yMin: number; xMax: number; yMax: number; });
185
- constructor(params?: { numberOfContours: number; xMin: number; yMin: number; xMax: number; yMax: number; }) {
186
- if (params) {
187
- this.numberOfContours = params.numberOfContours;
188
- this.xMin = params.xMin;
189
- this.yMin = params.yMin;
190
- this.xMax = params.xMax;
191
- this.yMax = params.yMax;
192
- } else {
193
- this.numberOfContours = 0;
194
- this.xMin = 0;
195
- this.yMin = 0;
196
- this.xMax = 0;
197
- this.yMax = 0;
198
- }
199
- }
200
- parse(pos: number, data: DataView): [number, _GlyphHeader] {
201
- return [
202
- 10,
203
- new _GlyphHeader({
204
- numberOfContours: data.getInt16(pos),
205
- xMin: data.getInt16(pos + 2),
206
- yMin: data.getInt16(pos + 4),
207
- xMax: data.getInt16(pos + 6),
208
- yMax: data.getInt16(pos + 8)
209
- })
210
- ];
211
- }
212
- getSize(): number {
213
- return 10;
214
- }
215
- write(pos: number, buffer: any): number { //eslint-disable-line
216
- buffer.setInt16(pos, this.numberOfContours);
217
- buffer.setInt16(pos + 2, this.xMin);
218
- buffer.setInt16(pos + 4, this.yMin);
219
- buffer.setInt16(pos + 6, this.xMax);
220
- buffer.setInt16(pos + 8, this.yMax);
221
- return 10;
222
- }
223
- scale(x: number, factor: number): void {
224
- this.xMin = Math.round(x + (this.xMin - x) * factor);
225
- this.xMax = Math.round(x + (this.xMax - x) * factor);
226
- }
227
- }
228
- export class _Contour {
229
- xCoordinates: number[];
230
- yCoordinates: number[];
231
- flags: number[];
232
- constructor({ flags, xCoordinates, yCoordinates }: { flags: number[]; xCoordinates: number[]; yCoordinates: number[]; }) {
233
- this.xCoordinates = xCoordinates;
234
- this.yCoordinates = yCoordinates;
235
- this.flags = flags;
236
- }
237
- }
238
- export class _SimpleGlyph {
239
- contours: _Contour[];
240
- instructions: Uint8Array;
241
- constructor();
242
- constructor({ contours, instructions }: { contours: _Contour[]; instructions: Uint8Array });
243
- constructor(params?: { contours: _Contour[]; instructions: Uint8Array }) {
244
- if (params) {
245
- this.contours = params.contours;
246
- this.instructions = params.instructions;
247
- } else {
248
- this.contours = [];
249
- }
250
- }
251
- parse(pos: number, data: DataView, numberOfContours: number): _SimpleGlyph {
252
- const endPtsOfContours: number[] = [];
253
- for (let i: number = 0; i < numberOfContours; i++) {
254
- const endPt: number = data.getUint16(pos);
255
- pos += 2;
256
- endPtsOfContours.push(endPt);
257
- }
258
- const numberOfPt: number = endPtsOfContours[numberOfContours - 1] + 1;
259
- const instructionLength: number = data.getUint16(pos);
260
- pos += 2;
261
- const instructions: Uint8Array = new Uint8Array(data.buffer, pos, instructionLength);
262
- pos += instructionLength;
263
- const flags: number[] = [];
264
- for (let i: number = 0; i < numberOfPt; pos++, i++) {
265
- let flag: number = data.getUint8(pos);
266
- flags.push(flag);
267
- if (flag & _repeatFlag) {
268
- const count: number = data.getUint8(++pos);
269
- flag ^= _repeatFlag;
270
- for (let m: number = 0; m < count; m++) {
271
- flags.push(flag);
272
- }
273
- i += count;
274
- }
275
- }
276
- const allXCoordinates: number[][] = [];
277
- let xCoordinates: number[] = [];
278
- let yCoordinates: number[] = [];
279
- let pointFlags: number[] = [];
280
- const contours: _Contour[] = [];
281
- let endPtsOfContoursIndex: number = 0;
282
- let lastCoordinate: number = 0;
283
- for (let i: number = 0; i < numberOfPt; i++) {
284
- const flag: number = flags[Number.parseInt(i.toString(), 10)];
285
- if (flag & _xShortVector) {
286
- const x: number = data.getUint8(pos++);
287
- lastCoordinate += flag & _xOrPostiveXshortVector ? x : -x;
288
- xCoordinates.push(lastCoordinate);
289
- } else if (flag & _xOrPostiveXshortVector) {
290
- xCoordinates.push(lastCoordinate);
291
- } else {
292
- lastCoordinate += data.getInt16(pos);
293
- pos += 2;
294
- xCoordinates.push(lastCoordinate);
295
- }
296
- if (endPtsOfContours[Number.parseInt(endPtsOfContoursIndex.toString(), 10)] === i) {
297
- endPtsOfContoursIndex++;
298
- allXCoordinates.push(xCoordinates);
299
- xCoordinates = [];
300
- }
301
- }
302
- lastCoordinate = 0;
303
- endPtsOfContoursIndex = 0;
304
- for (let i: number = 0; i < numberOfPt; i++) {
305
- const flag: number = flags[Number.parseInt(i.toString(), 10)];
306
- if (flag & _yShortVector) {
307
- const y: number = data.getUint8(pos++);
308
- lastCoordinate += flag & _yOrPostiveXshortVector ? y : -y;
309
- yCoordinates.push(lastCoordinate);
310
- } else if (flag & _yOrPostiveXshortVector) {
311
- yCoordinates.push(lastCoordinate);
312
- } else {
313
- lastCoordinate += data.getInt16(pos);
314
- pos += 2;
315
- yCoordinates.push(lastCoordinate);
316
- }
317
- pointFlags.push((flag & _onCurvePoint) | (flag & _simpleOverlap));
318
- if (endPtsOfContours[Number.parseInt(endPtsOfContoursIndex.toString(), 10)] === i) {
319
- xCoordinates = allXCoordinates[Number.parseInt(endPtsOfContoursIndex.toString(), 10)];
320
- endPtsOfContoursIndex++;
321
- contours.push(
322
- new _Contour({
323
- flags: pointFlags,
324
- xCoordinates,
325
- yCoordinates
326
- })
327
- );
328
- yCoordinates = [];
329
- pointFlags = [];
330
- }
331
- }
332
- return new _SimpleGlyph({
333
- contours,
334
- instructions
335
- });
336
- }
337
- getSize(): number {
338
- let size: number = this.contours.length * 2 + 2 + this.instructions.length;
339
- let lastX: number = 0;
340
- let lastY: number = 0;
341
- for (const contour of this.contours) {
342
- size += contour.flags.length;
343
- for (let i: number = 0, ii: number = contour.xCoordinates.length; i < ii; i++) {
344
- const x: number = contour.xCoordinates[Number.parseInt(i.toString(), 10)];
345
- const y: number = contour.yCoordinates[Number.parseInt(i.toString(), 10)];
346
- let abs: number = Math.abs(x - lastX);
347
- if (abs > 255) {
348
- size += 2;
349
- } else if (abs > 0) {
350
- size += 1;
351
- }
352
- lastX = x;
353
- abs = Math.abs(y - lastY);
354
- if (abs > 255) {
355
- size += 2;
356
- } else if (abs > 0) {
357
- size += 1;
358
- }
359
- lastY = y;
360
- }
361
- }
362
- return size;
363
- }
364
- write(pos: number, buffer: DataView): number {
365
- const spos: number = pos;
366
- const xCoordinates: number[] = [];
367
- const yCoordinates: number[] = [];
368
- const flags: number[] = [];
369
- let lastX: number = 0;
370
- let lastY: number = 0;
371
- for (const contour of this.contours) {
372
- for (let i: number = 0, ii: number = contour.xCoordinates.length; i < ii; i++) {
373
- let flag: number = contour.flags[Number.parseInt(i.toString(), 10)];
374
- const x: number = contour.xCoordinates[Number.parseInt(i.toString(), 10)];
375
- let delta: number = x - lastX;
376
- if (delta === 0) {
377
- flag |= _xOrPostiveXshortVector;
378
- xCoordinates.push(0);
379
- } else {
380
- const abs: number = Math.abs(delta);
381
- if (abs <= 255) {
382
- flag |=
383
- delta >= 0
384
- ? _xShortVector | _xOrPostiveXshortVector
385
- : _xShortVector;
386
- xCoordinates.push(abs);
387
- } else {
388
- xCoordinates.push(delta);
389
- }
390
- }
391
- lastX = x;
392
- const y: number = contour.yCoordinates[Number.parseInt(i.toString(), 10)];
393
- delta = y - lastY;
394
- if (delta === 0) {
395
- flag |= _yOrPostiveXshortVector;
396
- yCoordinates.push(0);
397
- } else {
398
- const abs: number = Math.abs(delta);
399
- if (abs <= 255) {
400
- flag |=
401
- delta >= 0
402
- ? _yShortVector | _yOrPostiveXshortVector
403
- : _yShortVector;
404
- yCoordinates.push(abs);
405
- } else {
406
- yCoordinates.push(delta);
407
- }
408
- }
409
- lastY = y;
410
- flags.push(flag);
411
- }
412
- buffer.setUint16(pos, xCoordinates.length - 1);
413
- pos += 2;
414
- }
415
- buffer.setUint16(pos, this.instructions.length);
416
- pos += 2;
417
- if (this.instructions.length) {
418
- new Uint8Array(buffer.buffer, 0, buffer.buffer.byteLength).set(
419
- this.instructions,
420
- pos
421
- );
422
- pos += this.instructions.length;
423
- }
424
- for (const flag of flags) {
425
- buffer.setUint8(pos++, flag);
426
- }
427
- for (let i: number = 0, ii: number = xCoordinates.length; i < ii; i++) {
428
- const x: number = xCoordinates[Number.parseInt(i.toString(), 10)];
429
- const flag: number = flags[Number.parseInt(i.toString(), 10)];
430
- if (flag & _xShortVector) {
431
- buffer.setUint8(pos++, x);
432
- } else if (!(flag & _xOrPostiveXshortVector)) {
433
- buffer.setInt16(pos, x);
434
- pos += 2;
435
- }
436
- }
437
- for (let i: number = 0, ii: number = yCoordinates.length; i < ii; i++) {
438
- const y: number = yCoordinates[Number.parseInt(i.toString(), 10)];
439
- const flag: number = flags[Number.parseInt(i.toString(), 10)];
440
- if (flag & _yShortVector) {
441
- buffer.setUint8(pos++, y);
442
- } else if (!(flag & _yOrPostiveXshortVector)) {
443
- buffer.setInt16(pos, y);
444
- pos += 2;
445
- }
446
- }
447
- return pos - spos;
448
- }
449
- scale(x: number, factor: number): void {
450
- for (const contour of this.contours) {
451
- if (contour.xCoordinates.length === 0) {
452
- continue;
453
- }
454
- for (let i: number = 0, ii: number = contour.xCoordinates.length; i < ii; i++) {
455
- contour.xCoordinates[Number.parseInt(i.toString(), 10)] = Math.round(
456
- x + (contour.xCoordinates[Number.parseInt(i.toString(), 10)] - x) * factor
457
- );
458
- }
459
- }
460
- }
461
- }
462
- export class _CompositeGlyph {
463
- flags: number;
464
- glyphIndex: number;
465
- argument1: number;
466
- argument2: number;
467
- transform: number[];
468
- instructions: Uint8Array | null;
469
- constructor();
470
- constructor({
471
- flags,
472
- glyphIndex,
473
- argument1,
474
- argument2,
475
- transform,
476
- instructions
477
- }: {
478
- flags: number;
479
- glyphIndex: number;
480
- argument1: number;
481
- argument2: number;
482
- transform: number[];
483
- instructions: Uint8Array | null;
484
- });
485
- constructor(params?: {
486
- flags: number;
487
- glyphIndex: number;
488
- argument1: number;
489
- argument2: number;
490
- transform: number[];
491
- instructions: Uint8Array | null;
492
- }) {
493
- if (params) {
494
- this.flags = params.flags;
495
- this.glyphIndex = params.glyphIndex;
496
- this.argument1 = params.argument1;
497
- this.argument2 = params.argument2;
498
- this.transform = params.transform;
499
- this.instructions = params.instructions;
500
- } else {
501
- this.flags = 0;
502
- this.glyphIndex = 0;
503
- this.argument1 = 0;
504
- this.argument2 = 0;
505
- this.transform = [];
506
- this.instructions = null;
507
- }
508
- }
509
- parse(pos: number, data: DataView): [number, _CompositeGlyph] {
510
- const spos: number = pos;
511
- const transform: number[] = [];
512
- let flags: number = data.getUint16(pos);
513
- const glyphIndex: number = data.getUint16(pos + 2);
514
- pos += 4;
515
- let argument1: number;
516
- let argument2: number;
517
- if (flags & _words) {
518
- if (flags & _argsAreXYValues) {
519
- argument1 = data.getInt16(pos);
520
- argument2 = data.getInt16(pos + 2);
521
- } else {
522
- argument1 = data.getUint16(pos);
523
- argument2 = data.getUint16(pos + 2);
524
- }
525
- pos += 4;
526
- flags ^= _words;
527
- } else {
528
- if (flags & _argsAreXYValues) {
529
- argument1 = data.getInt8(pos);
530
- argument2 = data.getInt8(pos + 1);
531
- } else {
532
- argument1 = data.getUint8(pos);
533
- argument2 = data.getUint8(pos + 1);
534
- }
535
- pos += 2;
536
- }
537
- if (flags & _scale) {
538
- transform.push(data.getUint16(pos));
539
- pos += 2;
540
- } else if (flags & _xyScale) {
541
- transform.push(data.getUint16(pos), data.getUint16(pos + 2));
542
- pos += 4;
543
- } else if (flags & _twoByTwo) {
544
- transform.push(
545
- data.getUint16(pos),
546
- data.getUint16(pos + 2),
547
- data.getUint16(pos + 4),
548
- data.getUint16(pos + 6)
549
- );
550
- pos += 8;
551
- }
552
- let instructions: Uint8Array | null = null;
553
- if (flags & _instructions) {
554
- const instructionLength: number = data.getUint16(pos);
555
- pos += 2;
556
- instructions = new Uint8Array(data.buffer.slice(pos, pos + instructionLength));
557
- pos += instructionLength;
558
- }
559
- return [
560
- pos - spos,
561
- new _CompositeGlyph({
562
- flags,
563
- glyphIndex,
564
- argument1,
565
- argument2,
566
- transform,
567
- instructions
568
- })
569
- ];
570
- }
571
- getSize(): number {
572
- let size: number = 2 + 2 + this.transform.length * 2;
573
- if (this.flags & _instructions) {
574
- size += 2 + (this.instructions ? this.instructions.length : 0);
575
- }
576
- size += 2;
577
- if (this.flags & 2) {
578
- if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
579
- size += 2;
580
- }
581
- } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
582
- size += 2;
583
- }
584
- return size;
585
- }
586
- write(pos: number, buffer: DataView): number {
587
- const spos: number = pos;
588
- if (this.flags & _argsAreXYValues) {
589
- if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
590
- this.flags |= _words;
591
- }
592
- } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
593
- this.flags |= _words;
594
- }
595
- buffer.setUint16(pos, this.flags);
596
- buffer.setUint16(pos + 2, this.glyphIndex);
597
- pos += 4;
598
- if (this.flags & _words) {
599
- if (this.flags & _argsAreXYValues) {
600
- buffer.setInt16(pos, this.argument1);
601
- buffer.setInt16(pos + 2, this.argument2);
602
- } else {
603
- buffer.setUint16(pos, this.argument1);
604
- buffer.setUint16(pos + 2, this.argument2);
605
- }
606
- pos += 4;
607
- } else {
608
- buffer.setUint8(pos, this.argument1);
609
- buffer.setUint8(pos + 1, this.argument2);
610
- pos += 2;
611
- }
612
- if (this.flags & _instructions) {
613
- buffer.setUint16(pos, this.instructions ? this.instructions.length : 0);
614
- pos += 2;
615
- if (this.instructions && this.instructions.length) {
616
- new Uint8Array(buffer.buffer, 0, buffer.buffer.byteLength).set(this.instructions, pos);
617
- pos += this.instructions.length;
618
- }
619
- }
620
- return pos - spos;
621
- }
622
- }
@@ -1,10 +0,0 @@
1
- export * from './binary-cmap-reader';
2
- export * from './cmap';
3
- export * from './compact-font-parser';
4
- export * from './encoding-utils';
5
- export * from './font-structure';
6
- export * from './font-tables';
7
- export * from './font-utils';
8
- export * from './glyph';
9
- export * from './matrix-helper';
10
- export * from './metrics';
@@ -1,10 +0,0 @@
1
- export * from './binary-cmap-reader';
2
- export * from './cmap';
3
- export * from './compact-font-parser';
4
- export * from './encoding-utils';
5
- export * from './font-structure';
6
- export * from './font-tables';
7
- export * from './font-utils';
8
- export * from './glyph';
9
- export * from './matrix-helper';
10
- export * from './metrics';
@@ -1,38 +0,0 @@
1
- export declare class _MatrixHelper {
2
- _m11: number;
3
- _m12: number;
4
- _m21: number;
5
- _m22: number;
6
- _offsetX: number;
7
- _offsetY: number;
8
- _type: any;
9
- constructor(m11: number, m12: number, m21: number, m22: number, offsetX: number, offSetY: number);
10
- _scale(scaleX: number, scaleY: number, centerX: number, centerY: number): _MatrixHelper;
11
- _clone(): _MatrixHelper;
12
- _setMatrix(m11: number, m12: number, m21: number, m22: number, offsetX: number, offsetY: number, type: _MatrixTypes): void;
13
- _translate(offsetX: number, offsetY: number): _MatrixHelper;
14
- _transform(x: number, y: number): [number, number];
15
- _multiply(matrix: _MatrixHelper): _MatrixHelper;
16
- readonly _identity: _MatrixHelper;
17
- _checkMatrixType(): void;
18
- _getTypeIndex(type: _MatrixTypes): number;
19
- }
20
- export declare class _TransformationStack {
21
- _currentTransform: _MatrixHelper;
22
- _initialTransform: _MatrixHelper;
23
- _transformStack: _MatrixHelper[];
24
- readonly _CurrentTransform: _MatrixHelper;
25
- constructor(initialTransform?: _MatrixHelper);
26
- _pushTransform(transformMatrix: _MatrixHelper): void;
27
- _popTransform(): void;
28
- private _clear;
29
- private _multiplyMatrices;
30
- }
31
- declare enum _MatrixTypes {
32
- Identity = 0,
33
- Scaling = 1,
34
- Translation = 2,
35
- scalingAndTranslation = 3,
36
- Unknown = 4
37
- }
38
- export {};