pdfjs-dist 2.0.943 → 2.1.266

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3438 -1209
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
@@ -19,74 +19,99 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.FontRendererFactory = undefined;
27
+ exports.FontRendererFactory = void 0;
28
28
 
29
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
29
+ var _util = require("../shared/util");
30
30
 
31
- var _util = require('../shared/util');
31
+ var _cff_parser = require("./cff_parser");
32
32
 
33
- var _cff_parser = require('./cff_parser');
33
+ var _glyphlist = require("./glyphlist");
34
34
 
35
- var _glyphlist = require('./glyphlist');
35
+ var _encodings = require("./encodings");
36
36
 
37
- var _encodings = require('./encodings');
37
+ var _stream = require("./stream");
38
38
 
39
- var _stream = require('./stream');
39
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
40
40
 
41
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
41
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
42
42
 
43
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
43
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
44
+
45
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
46
+
47
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
48
+
49
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
44
50
 
45
51
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
46
52
 
53
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
54
+
55
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
56
+
47
57
  var FontRendererFactory = function FontRendererFactoryClosure() {
48
58
  function getLong(data, offset) {
49
59
  return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
50
60
  }
61
+
51
62
  function getUshort(data, offset) {
52
63
  return data[offset] << 8 | data[offset + 1];
53
64
  }
65
+
54
66
  function parseCmap(data, start, end) {
55
67
  var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
56
68
  var format = getUshort(data, start + offset);
57
69
  var ranges, p, i;
70
+
58
71
  if (format === 4) {
59
72
  getUshort(data, start + offset + 2);
60
73
  var segCount = getUshort(data, start + offset + 6) >> 1;
61
74
  p = start + offset + 14;
62
75
  ranges = [];
76
+
63
77
  for (i = 0; i < segCount; i++, p += 2) {
64
- ranges[i] = { end: getUshort(data, p) };
78
+ ranges[i] = {
79
+ end: getUshort(data, p)
80
+ };
65
81
  }
82
+
66
83
  p += 2;
84
+
67
85
  for (i = 0; i < segCount; i++, p += 2) {
68
86
  ranges[i].start = getUshort(data, p);
69
87
  }
88
+
70
89
  for (i = 0; i < segCount; i++, p += 2) {
71
90
  ranges[i].idDelta = getUshort(data, p);
72
91
  }
92
+
73
93
  for (i = 0; i < segCount; i++, p += 2) {
74
94
  var idOffset = getUshort(data, p);
95
+
75
96
  if (idOffset === 0) {
76
97
  continue;
77
98
  }
99
+
78
100
  ranges[i].ids = [];
101
+
79
102
  for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
80
103
  ranges[i].ids[j] = getUshort(data, p + idOffset);
81
104
  idOffset += 2;
82
105
  }
83
106
  }
107
+
84
108
  return ranges;
85
109
  } else if (format === 12) {
86
110
  getLong(data, start + offset + 4);
87
111
  var groups = getLong(data, start + offset + 12);
88
112
  p = start + offset + 16;
89
113
  ranges = [];
114
+
90
115
  for (i = 0; i < groups; i++) {
91
116
  ranges.push({
92
117
  start: getLong(data, p),
@@ -95,10 +120,13 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
95
120
  });
96
121
  p += 12;
97
122
  }
123
+
98
124
  return ranges;
99
125
  }
100
- throw new _util.FormatError('unsupported cmap: ' + format);
126
+
127
+ throw new _util.FormatError("unsupported cmap: ".concat(format));
101
128
  }
129
+
102
130
  function parseCff(data, start, end, seacAnalysisEnabled) {
103
131
  var properties = {};
104
132
  var parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
@@ -112,49 +140,62 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
112
140
  fdArray: cff.fdArray
113
141
  };
114
142
  }
143
+
115
144
  function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
116
145
  var itemSize, itemDecode;
146
+
117
147
  if (isGlyphLocationsLong) {
118
148
  itemSize = 4;
149
+
119
150
  itemDecode = function fontItemDecodeLong(data, offset) {
120
151
  return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
121
152
  };
122
153
  } else {
123
154
  itemSize = 2;
155
+
124
156
  itemDecode = function fontItemDecode(data, offset) {
125
157
  return data[offset] << 9 | data[offset + 1] << 1;
126
158
  };
127
159
  }
160
+
128
161
  var glyphs = [];
129
162
  var startOffset = itemDecode(loca, 0);
163
+
130
164
  for (var j = itemSize; j < loca.length; j += itemSize) {
131
165
  var endOffset = itemDecode(loca, j);
132
166
  glyphs.push(glyf.subarray(startOffset, endOffset));
133
167
  startOffset = endOffset;
134
168
  }
169
+
135
170
  return glyphs;
136
171
  }
172
+
137
173
  function lookupCmap(ranges, unicode) {
138
174
  var code = unicode.codePointAt(0),
139
175
  gid = 0;
140
176
  var l = 0,
141
177
  r = ranges.length - 1;
178
+
142
179
  while (l < r) {
143
180
  var c = l + r + 1 >> 1;
181
+
144
182
  if (code < ranges[c].start) {
145
183
  r = c - 1;
146
184
  } else {
147
185
  l = c;
148
186
  }
149
187
  }
188
+
150
189
  if (ranges[l].start <= code && code <= ranges[l].end) {
151
190
  gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
152
191
  }
192
+
153
193
  return {
154
194
  charCode: code,
155
195
  glyphId: gid
156
196
  };
157
197
  }
198
+
158
199
  function compileGlyf(code, cmds, font) {
159
200
  function moveTo(x, y) {
160
201
  cmds.push({
@@ -162,30 +203,35 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
162
203
  args: [x, y]
163
204
  });
164
205
  }
206
+
165
207
  function lineTo(x, y) {
166
208
  cmds.push({
167
209
  cmd: 'lineTo',
168
210
  args: [x, y]
169
211
  });
170
212
  }
213
+
171
214
  function quadraticCurveTo(xa, ya, x, y) {
172
215
  cmds.push({
173
216
  cmd: 'quadraticCurveTo',
174
217
  args: [xa, ya, x, y]
175
218
  });
176
219
  }
220
+
177
221
  var i = 0;
178
222
  var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
179
223
  var flags;
180
224
  var x = 0,
181
225
  y = 0;
182
226
  i += 10;
227
+
183
228
  if (numberOfContours < 0) {
184
229
  do {
185
230
  flags = code[i] << 8 | code[i + 1];
186
231
  var glyphIndex = code[i + 2] << 8 | code[i + 3];
187
232
  i += 4;
188
233
  var arg1, arg2;
234
+
189
235
  if (flags & 0x01) {
190
236
  arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
191
237
  arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
@@ -194,6 +240,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
194
240
  arg1 = code[i++];
195
241
  arg2 = code[i++];
196
242
  }
243
+
197
244
  if (flags & 0x02) {
198
245
  x = arg1;
199
246
  y = arg2;
@@ -201,10 +248,12 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
201
248
  x = 0;
202
249
  y = 0;
203
250
  }
251
+
204
252
  var scaleX = 1,
205
253
  scaleY = 1,
206
254
  scale01 = 0,
207
255
  scale10 = 0;
256
+
208
257
  if (flags & 0x08) {
209
258
  scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
210
259
  i += 2;
@@ -219,72 +268,96 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
219
268
  scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
220
269
  i += 8;
221
270
  }
271
+
222
272
  var subglyph = font.glyphs[glyphIndex];
273
+
223
274
  if (subglyph) {
224
- cmds.push({ cmd: 'save' });
275
+ cmds.push({
276
+ cmd: 'save'
277
+ });
225
278
  cmds.push({
226
279
  cmd: 'transform',
227
280
  args: [scaleX, scale01, scale10, scaleY, x, y]
228
281
  });
229
282
  compileGlyf(subglyph, cmds, font);
230
- cmds.push({ cmd: 'restore' });
283
+ cmds.push({
284
+ cmd: 'restore'
285
+ });
231
286
  }
232
287
  } while (flags & 0x20);
233
288
  } else {
234
289
  var endPtsOfContours = [];
235
290
  var j, jj;
291
+
236
292
  for (j = 0; j < numberOfContours; j++) {
237
293
  endPtsOfContours.push(code[i] << 8 | code[i + 1]);
238
294
  i += 2;
239
295
  }
296
+
240
297
  var instructionLength = code[i] << 8 | code[i + 1];
241
298
  i += 2 + instructionLength;
242
299
  var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
243
300
  var points = [];
301
+
244
302
  while (points.length < numberOfPoints) {
245
303
  flags = code[i++];
246
304
  var repeat = 1;
305
+
247
306
  if (flags & 0x08) {
248
307
  repeat += code[i++];
249
308
  }
309
+
250
310
  while (repeat-- > 0) {
251
- points.push({ flags: flags });
311
+ points.push({
312
+ flags: flags
313
+ });
252
314
  }
253
315
  }
316
+
254
317
  for (j = 0; j < numberOfPoints; j++) {
255
318
  switch (points[j].flags & 0x12) {
256
319
  case 0x00:
257
320
  x += (code[i] << 24 | code[i + 1] << 16) >> 16;
258
321
  i += 2;
259
322
  break;
323
+
260
324
  case 0x02:
261
325
  x -= code[i++];
262
326
  break;
327
+
263
328
  case 0x12:
264
329
  x += code[i++];
265
330
  break;
266
331
  }
332
+
267
333
  points[j].x = x;
268
334
  }
335
+
269
336
  for (j = 0; j < numberOfPoints; j++) {
270
337
  switch (points[j].flags & 0x24) {
271
338
  case 0x00:
272
339
  y += (code[i] << 24 | code[i + 1] << 16) >> 16;
273
340
  i += 2;
274
341
  break;
342
+
275
343
  case 0x04:
276
344
  y -= code[i++];
277
345
  break;
346
+
278
347
  case 0x24:
279
348
  y += code[i++];
280
349
  break;
281
350
  }
351
+
282
352
  points[j].y = y;
283
353
  }
354
+
284
355
  var startPoint = 0;
356
+
285
357
  for (i = 0; i < numberOfContours; i++) {
286
358
  var endPoint = endPtsOfContours[i];
287
359
  var contour = points.slice(startPoint, endPoint + 1);
360
+
288
361
  if (contour[0].flags & 1) {
289
362
  contour.push(contour[0]);
290
363
  } else if (contour[contour.length - 1].flags & 1) {
@@ -298,7 +371,9 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
298
371
  contour.unshift(p);
299
372
  contour.push(p);
300
373
  }
374
+
301
375
  moveTo(contour[0].x, contour[0].y);
376
+
302
377
  for (j = 1, jj = contour.length; j < jj; j++) {
303
378
  if (contour[j].flags & 1) {
304
379
  lineTo(contour[j].x, contour[j].y);
@@ -309,82 +384,103 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
309
384
  quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
310
385
  }
311
386
  }
387
+
312
388
  startPoint = endPoint + 1;
313
389
  }
314
390
  }
315
391
  }
392
+
316
393
  function compileCharString(code, cmds, font, glyphId) {
317
394
  var stack = [];
318
395
  var x = 0,
319
396
  y = 0;
320
397
  var stems = 0;
398
+
321
399
  function moveTo(x, y) {
322
400
  cmds.push({
323
401
  cmd: 'moveTo',
324
402
  args: [x, y]
325
403
  });
326
404
  }
405
+
327
406
  function lineTo(x, y) {
328
407
  cmds.push({
329
408
  cmd: 'lineTo',
330
409
  args: [x, y]
331
410
  });
332
411
  }
412
+
333
413
  function bezierCurveTo(x1, y1, x2, y2, x, y) {
334
414
  cmds.push({
335
415
  cmd: 'bezierCurveTo',
336
416
  args: [x1, y1, x2, y2, x, y]
337
417
  });
338
418
  }
419
+
339
420
  function parse(code) {
340
421
  var i = 0;
422
+
341
423
  while (i < code.length) {
342
424
  var stackClean = false;
343
425
  var v = code[i++];
344
426
  var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
427
+
345
428
  switch (v) {
346
429
  case 1:
347
430
  stems += stack.length >> 1;
348
431
  stackClean = true;
349
432
  break;
433
+
350
434
  case 3:
351
435
  stems += stack.length >> 1;
352
436
  stackClean = true;
353
437
  break;
438
+
354
439
  case 4:
355
440
  y += stack.pop();
356
441
  moveTo(x, y);
357
442
  stackClean = true;
358
443
  break;
444
+
359
445
  case 5:
360
446
  while (stack.length > 0) {
361
447
  x += stack.shift();
362
448
  y += stack.shift();
363
449
  lineTo(x, y);
364
450
  }
451
+
365
452
  break;
453
+
366
454
  case 6:
367
455
  while (stack.length > 0) {
368
456
  x += stack.shift();
369
457
  lineTo(x, y);
458
+
370
459
  if (stack.length === 0) {
371
460
  break;
372
461
  }
462
+
373
463
  y += stack.shift();
374
464
  lineTo(x, y);
375
465
  }
466
+
376
467
  break;
468
+
377
469
  case 7:
378
470
  while (stack.length > 0) {
379
471
  y += stack.shift();
380
472
  lineTo(x, y);
473
+
381
474
  if (stack.length === 0) {
382
475
  break;
383
476
  }
477
+
384
478
  x += stack.shift();
385
479
  lineTo(x, y);
386
480
  }
481
+
387
482
  break;
483
+
388
484
  case 8:
389
485
  while (stack.length > 0) {
390
486
  xa = x + stack.shift();
@@ -395,18 +491,24 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
395
491
  y = yb + stack.shift();
396
492
  bezierCurveTo(xa, ya, xb, yb, x, y);
397
493
  }
494
+
398
495
  break;
496
+
399
497
  case 10:
400
498
  n = stack.pop();
401
499
  subrCode = null;
500
+
402
501
  if (font.isCFFCIDFont) {
403
502
  var fdIndex = font.fdSelect.getFDIndex(glyphId);
503
+
404
504
  if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
405
505
  var fontDict = font.fdArray[fdIndex],
406
506
  subrs = void 0;
507
+
407
508
  if (fontDict.privateDict && fontDict.privateDict.subrsIndex) {
408
509
  subrs = fontDict.privateDict.subrsIndex.objects;
409
510
  }
511
+
410
512
  if (subrs) {
411
513
  var numSubrs = subrs.length;
412
514
  n += numSubrs < 1240 ? 107 : numSubrs < 33900 ? 1131 : 32768;
@@ -418,14 +520,19 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
418
520
  } else {
419
521
  subrCode = font.subrs[n + font.subrsBias];
420
522
  }
523
+
421
524
  if (subrCode) {
422
525
  parse(subrCode);
423
526
  }
527
+
424
528
  break;
529
+
425
530
  case 11:
426
531
  return;
532
+
427
533
  case 12:
428
534
  v = code[i++];
535
+
429
536
  switch (v) {
430
537
  case 34:
431
538
  xa = x + stack.shift();
@@ -438,6 +545,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
438
545
  x = xb + stack.shift();
439
546
  bezierCurveTo(xa, y1, xb, y, x, y);
440
547
  break;
548
+
441
549
  case 35:
442
550
  xa = x + stack.shift();
443
551
  ya = y + stack.shift();
@@ -455,6 +563,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
455
563
  bezierCurveTo(xa, ya, xb, yb, x, y);
456
564
  stack.pop();
457
565
  break;
566
+
458
567
  case 36:
459
568
  xa = x + stack.shift();
460
569
  y1 = y + stack.shift();
@@ -468,6 +577,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
468
577
  x = xb + stack.shift();
469
578
  bezierCurveTo(xa, y2, xb, y3, x, y);
470
579
  break;
580
+
471
581
  case 37:
472
582
  var x0 = x,
473
583
  y0 = y;
@@ -484,64 +594,81 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
484
594
  yb = ya + stack.shift();
485
595
  x = xb;
486
596
  y = yb;
597
+
487
598
  if (Math.abs(x - x0) > Math.abs(y - y0)) {
488
599
  x += stack.shift();
489
600
  } else {
490
601
  y += stack.shift();
491
602
  }
603
+
492
604
  bezierCurveTo(xa, ya, xb, yb, x, y);
493
605
  break;
606
+
494
607
  default:
495
- throw new _util.FormatError('unknown operator: 12 ' + v);
608
+ throw new _util.FormatError("unknown operator: 12 ".concat(v));
496
609
  }
610
+
497
611
  break;
612
+
498
613
  case 14:
499
614
  if (stack.length >= 4) {
500
615
  var achar = stack.pop();
501
616
  var bchar = stack.pop();
502
617
  y = stack.pop();
503
618
  x = stack.pop();
504
- cmds.push({ cmd: 'save' });
619
+ cmds.push({
620
+ cmd: 'save'
621
+ });
505
622
  cmds.push({
506
623
  cmd: 'translate',
507
624
  args: [x, y]
508
625
  });
509
626
  var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
510
627
  compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
511
- cmds.push({ cmd: 'restore' });
628
+ cmds.push({
629
+ cmd: 'restore'
630
+ });
512
631
  cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
513
632
  compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
514
633
  }
634
+
515
635
  return;
636
+
516
637
  case 18:
517
638
  stems += stack.length >> 1;
518
639
  stackClean = true;
519
640
  break;
641
+
520
642
  case 19:
521
643
  stems += stack.length >> 1;
522
644
  i += stems + 7 >> 3;
523
645
  stackClean = true;
524
646
  break;
647
+
525
648
  case 20:
526
649
  stems += stack.length >> 1;
527
650
  i += stems + 7 >> 3;
528
651
  stackClean = true;
529
652
  break;
653
+
530
654
  case 21:
531
655
  y += stack.pop();
532
656
  x += stack.pop();
533
657
  moveTo(x, y);
534
658
  stackClean = true;
535
659
  break;
660
+
536
661
  case 22:
537
662
  x += stack.pop();
538
663
  moveTo(x, y);
539
664
  stackClean = true;
540
665
  break;
666
+
541
667
  case 23:
542
668
  stems += stack.length >> 1;
543
669
  stackClean = true;
544
670
  break;
671
+
545
672
  case 24:
546
673
  while (stack.length > 2) {
547
674
  xa = x + stack.shift();
@@ -552,16 +679,19 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
552
679
  y = yb + stack.shift();
553
680
  bezierCurveTo(xa, ya, xb, yb, x, y);
554
681
  }
682
+
555
683
  x += stack.shift();
556
684
  y += stack.shift();
557
685
  lineTo(x, y);
558
686
  break;
687
+
559
688
  case 25:
560
689
  while (stack.length > 6) {
561
690
  x += stack.shift();
562
691
  y += stack.shift();
563
692
  lineTo(x, y);
564
693
  }
694
+
565
695
  xa = x + stack.shift();
566
696
  ya = y + stack.shift();
567
697
  xb = xa + stack.shift();
@@ -570,10 +700,12 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
570
700
  y = yb + stack.shift();
571
701
  bezierCurveTo(xa, ya, xb, yb, x, y);
572
702
  break;
703
+
573
704
  case 26:
574
705
  if (stack.length % 2) {
575
706
  x += stack.shift();
576
707
  }
708
+
577
709
  while (stack.length > 0) {
578
710
  xa = x;
579
711
  ya = y + stack.shift();
@@ -583,11 +715,14 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
583
715
  y = yb + stack.shift();
584
716
  bezierCurveTo(xa, ya, xb, yb, x, y);
585
717
  }
718
+
586
719
  break;
720
+
587
721
  case 27:
588
722
  if (stack.length % 2) {
589
723
  y += stack.shift();
590
724
  }
725
+
591
726
  while (stack.length > 0) {
592
727
  xa = x + stack.shift();
593
728
  ya = y;
@@ -597,18 +732,24 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
597
732
  y = yb;
598
733
  bezierCurveTo(xa, ya, xb, yb, x, y);
599
734
  }
735
+
600
736
  break;
737
+
601
738
  case 28:
602
739
  stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
603
740
  i += 2;
604
741
  break;
742
+
605
743
  case 29:
606
744
  n = stack.pop() + font.gsubrsBias;
607
745
  subrCode = font.gsubrs[n];
746
+
608
747
  if (subrCode) {
609
748
  parse(subrCode);
610
749
  }
750
+
611
751
  break;
752
+
612
753
  case 30:
613
754
  while (stack.length > 0) {
614
755
  xa = x;
@@ -618,9 +759,11 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
618
759
  x = xb + stack.shift();
619
760
  y = yb + (stack.length === 1 ? stack.shift() : 0);
620
761
  bezierCurveTo(xa, ya, xb, yb, x, y);
762
+
621
763
  if (stack.length === 0) {
622
764
  break;
623
765
  }
766
+
624
767
  xa = x + stack.shift();
625
768
  ya = y;
626
769
  xb = xa + stack.shift();
@@ -629,7 +772,9 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
629
772
  x = xb + (stack.length === 1 ? stack.shift() : 0);
630
773
  bezierCurveTo(xa, ya, xb, yb, x, y);
631
774
  }
775
+
632
776
  break;
777
+
633
778
  case 31:
634
779
  while (stack.length > 0) {
635
780
  xa = x + stack.shift();
@@ -639,9 +784,11 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
639
784
  y = yb + stack.shift();
640
785
  x = xb + (stack.length === 1 ? stack.shift() : 0);
641
786
  bezierCurveTo(xa, ya, xb, yb, x, y);
787
+
642
788
  if (stack.length === 0) {
643
789
  break;
644
790
  }
791
+
645
792
  xa = x;
646
793
  ya = y + stack.shift();
647
794
  xb = xa + stack.shift();
@@ -650,11 +797,14 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
650
797
  y = yb + (stack.length === 1 ? stack.shift() : 0);
651
798
  bezierCurveTo(xa, ya, xb, yb, x, y);
652
799
  }
800
+
653
801
  break;
802
+
654
803
  default:
655
804
  if (v < 32) {
656
- throw new _util.FormatError('unknown operator: ' + v);
805
+ throw new _util.FormatError("unknown operator: ".concat(v));
657
806
  }
807
+
658
808
  if (v < 247) {
659
809
  stack.push(v - 139);
660
810
  } else if (v < 251) {
@@ -665,52 +815,65 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
665
815
  stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
666
816
  i += 4;
667
817
  }
818
+
668
819
  break;
669
820
  }
821
+
670
822
  if (stackClean) {
671
823
  stack.length = 0;
672
824
  }
673
825
  }
674
826
  }
827
+
675
828
  parse(code);
676
829
  }
830
+
677
831
  var NOOP = [];
678
832
 
679
- var CompiledFont = function () {
833
+ var CompiledFont =
834
+ /*#__PURE__*/
835
+ function () {
680
836
  function CompiledFont(fontMatrix) {
681
837
  _classCallCheck(this, CompiledFont);
682
838
 
683
839
  if (this.constructor === CompiledFont) {
684
840
  (0, _util.unreachable)('Cannot initialize CompiledFont.');
685
841
  }
842
+
686
843
  this.fontMatrix = fontMatrix;
687
844
  this.compiledGlyphs = Object.create(null);
688
845
  this.compiledCharCodeToGlyphId = Object.create(null);
689
846
  }
690
847
 
691
848
  _createClass(CompiledFont, [{
692
- key: 'getPathJs',
849
+ key: "getPathJs",
693
850
  value: function getPathJs(unicode) {
694
851
  var cmap = lookupCmap(this.cmap, unicode);
695
852
  var fn = this.compiledGlyphs[cmap.glyphId];
853
+
696
854
  if (!fn) {
697
855
  fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
698
856
  this.compiledGlyphs[cmap.glyphId] = fn;
699
857
  }
858
+
700
859
  if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
701
860
  this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
702
861
  }
862
+
703
863
  return fn;
704
864
  }
705
865
  }, {
706
- key: 'compileGlyph',
866
+ key: "compileGlyph",
707
867
  value: function compileGlyph(code, glyphId) {
708
868
  if (!code || code.length === 0 || code[0] === 14) {
709
869
  return NOOP;
710
870
  }
871
+
711
872
  var fontMatrix = this.fontMatrix;
873
+
712
874
  if (this.isCFFCIDFont) {
713
875
  var fdIndex = this.fdSelect.getFDIndex(glyphId);
876
+
714
877
  if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
715
878
  var fontDict = this.fdArray[fdIndex];
716
879
  fontMatrix = fontDict.getByName('FontMatrix') || _util.FONT_IDENTITY_MATRIX;
@@ -718,8 +881,11 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
718
881
  (0, _util.warn)('Invalid fd index for glyph index.');
719
882
  }
720
883
  }
884
+
721
885
  var cmds = [];
722
- cmds.push({ cmd: 'save' });
886
+ cmds.push({
887
+ cmd: 'save'
888
+ });
723
889
  cmds.push({
724
890
  cmd: 'transform',
725
891
  args: fontMatrix.slice()
@@ -729,16 +895,18 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
729
895
  args: ['size', '-size']
730
896
  });
731
897
  this.compileGlyphImpl(code, cmds, glyphId);
732
- cmds.push({ cmd: 'restore' });
898
+ cmds.push({
899
+ cmd: 'restore'
900
+ });
733
901
  return cmds;
734
902
  }
735
903
  }, {
736
- key: 'compileGlyphImpl',
904
+ key: "compileGlyphImpl",
737
905
  value: function compileGlyphImpl() {
738
906
  (0, _util.unreachable)('Children classes should implement this.');
739
907
  }
740
908
  }, {
741
- key: 'hasBuiltPath',
909
+ key: "hasBuiltPath",
742
910
  value: function hasBuiltPath(unicode) {
743
911
  var cmap = lookupCmap(this.cmap, unicode);
744
912
  return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
@@ -748,21 +916,24 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
748
916
  return CompiledFont;
749
917
  }();
750
918
 
751
- var TrueTypeCompiled = function (_CompiledFont) {
919
+ var TrueTypeCompiled =
920
+ /*#__PURE__*/
921
+ function (_CompiledFont) {
752
922
  _inherits(TrueTypeCompiled, _CompiledFont);
753
923
 
754
924
  function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
755
- _classCallCheck(this, TrueTypeCompiled);
925
+ var _this;
756
926
 
757
- var _this = _possibleConstructorReturn(this, (TrueTypeCompiled.__proto__ || Object.getPrototypeOf(TrueTypeCompiled)).call(this, fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]));
927
+ _classCallCheck(this, TrueTypeCompiled);
758
928
 
929
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(TrueTypeCompiled).call(this, fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]));
759
930
  _this.glyphs = glyphs;
760
931
  _this.cmap = cmap;
761
932
  return _this;
762
933
  }
763
934
 
764
935
  _createClass(TrueTypeCompiled, [{
765
- key: 'compileGlyphImpl',
936
+ key: "compileGlyphImpl",
766
937
  value: function compileGlyphImpl(code, cmds) {
767
938
  compileGlyf(code, cmds, this);
768
939
  }
@@ -771,14 +942,17 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
771
942
  return TrueTypeCompiled;
772
943
  }(CompiledFont);
773
944
 
774
- var Type2Compiled = function (_CompiledFont2) {
945
+ var Type2Compiled =
946
+ /*#__PURE__*/
947
+ function (_CompiledFont2) {
775
948
  _inherits(Type2Compiled, _CompiledFont2);
776
949
 
777
950
  function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
778
- _classCallCheck(this, Type2Compiled);
951
+ var _this2;
779
952
 
780
- var _this2 = _possibleConstructorReturn(this, (Type2Compiled.__proto__ || Object.getPrototypeOf(Type2Compiled)).call(this, fontMatrix || [0.001, 0, 0, 0.001, 0, 0]));
953
+ _classCallCheck(this, Type2Compiled);
781
954
 
955
+ _this2 = _possibleConstructorReturn(this, _getPrototypeOf(Type2Compiled).call(this, fontMatrix || [0.001, 0, 0, 0.001, 0, 0]));
782
956
  _this2.glyphs = cffInfo.glyphs;
783
957
  _this2.gsubrs = cffInfo.gsubrs || [];
784
958
  _this2.subrs = cffInfo.subrs || [];
@@ -793,7 +967,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
793
967
  }
794
968
 
795
969
  _createClass(Type2Compiled, [{
796
- key: 'compileGlyphImpl',
970
+ key: "compileGlyphImpl",
797
971
  value: function compileGlyphImpl(code, cmds, glyphId) {
798
972
  compileCharString(code, cmds, this, glyphId);
799
973
  }
@@ -807,35 +981,44 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
807
981
  var data = new Uint8Array(font.data);
808
982
  var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
809
983
  var numTables = getUshort(data, 4);
984
+
810
985
  for (var i = 0, p = 12; i < numTables; i++, p += 16) {
811
986
  var tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
812
987
  var offset = getLong(data, p + 8);
813
988
  var length = getLong(data, p + 12);
989
+
814
990
  switch (tag) {
815
991
  case 'cmap':
816
992
  cmap = parseCmap(data, offset, offset + length);
817
993
  break;
994
+
818
995
  case 'glyf':
819
996
  glyf = data.subarray(offset, offset + length);
820
997
  break;
998
+
821
999
  case 'loca':
822
1000
  loca = data.subarray(offset, offset + length);
823
1001
  break;
1002
+
824
1003
  case 'head':
825
1004
  unitsPerEm = getUshort(data, offset + 18);
826
1005
  indexToLocFormat = getUshort(data, offset + 50);
827
1006
  break;
1007
+
828
1008
  case 'CFF ':
829
1009
  cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
830
1010
  break;
831
1011
  }
832
1012
  }
1013
+
833
1014
  if (glyf) {
834
1015
  var fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
835
1016
  return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
836
1017
  }
1018
+
837
1019
  return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
838
1020
  }
839
1021
  };
840
1022
  }();
1023
+
841
1024
  exports.FontRendererFactory = FontRendererFactory;