pdfjs-dist 2.0.489 → 2.2.228

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