pdfjs-dist 2.2.228 → 2.6.347

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 (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -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 2019 Mozilla Foundation
5
+ * Copyright 2020 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.
@@ -26,236 +26,236 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.CFFFDSelect = exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = void 0;
28
28
 
29
- var _util = require("../shared/util");
29
+ var _util = require("../shared/util.js");
30
30
 
31
- var _charsets = require("./charsets");
31
+ var _charsets = require("./charsets.js");
32
32
 
33
- var _encodings = require("./encodings");
33
+ var _encodings = require("./encodings.js");
34
34
 
35
35
  var MAX_SUBR_NESTING = 10;
36
- var CFFStandardStrings = ['.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent', 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency', 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl', 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis', 'perthousand', 'questiondown', 'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', 'dieresis', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron', 'emdash', 'AE', 'ordfeminine', 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', 'dotlessi', 'lslash', 'oslash', 'oe', 'germandbls', 'onesuperior', 'logicalnot', 'mu', 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', 'onequarter', 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', 'twosuperior', 'registered', 'minus', 'eth', 'multiply', 'threesuperior', 'copyright', 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', 'Atilde', 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', 'Ocircumflex', 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', 'Ucircumflex', 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', 'aacute', 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', 'ccedilla', 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', 'icircumflex', 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', 'odieresis', 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', 'udieresis', 'ugrave', 'yacute', 'ydieresis', 'zcaron', 'exclamsmall', 'Hungarumlautsmall', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'commasuperior', 'threequartersemdash', 'periodsuperior', 'questionsmall', 'asuperior', 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', 'tsuperior', 'ff', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', 'Tildesmall', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall', 'Caronsmall', 'Dotaccentsmall', 'Macronsmall', 'figuredash', 'hypheninferior', 'Ogoneksmall', 'Ringsmall', 'Cedillasmall', 'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior', 'commainferior', 'Agravesmall', 'Aacutesmall', 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall', 'Aringsmall', 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall', 'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall', 'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall', 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall', 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall', 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall', 'Ydieresissmall', '001.000', '001.001', '001.002', '001.003', 'Black', 'Bold', 'Book', 'Light', 'Medium', 'Regular', 'Roman', 'Semibold'];
36
+ var CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
37
37
  exports.CFFStandardStrings = CFFStandardStrings;
38
- var NUM_STANDARD_CFF_STRINGS = 391;
38
+ const NUM_STANDARD_CFF_STRINGS = 391;
39
39
 
40
40
  var CFFParser = function CFFParserClosure() {
41
41
  var CharstringValidationData = [null, {
42
- id: 'hstem',
42
+ id: "hstem",
43
43
  min: 2,
44
44
  stackClearing: true,
45
45
  stem: true
46
46
  }, null, {
47
- id: 'vstem',
47
+ id: "vstem",
48
48
  min: 2,
49
49
  stackClearing: true,
50
50
  stem: true
51
51
  }, {
52
- id: 'vmoveto',
52
+ id: "vmoveto",
53
53
  min: 1,
54
54
  stackClearing: true
55
55
  }, {
56
- id: 'rlineto',
56
+ id: "rlineto",
57
57
  min: 2,
58
58
  resetStack: true
59
59
  }, {
60
- id: 'hlineto',
60
+ id: "hlineto",
61
61
  min: 1,
62
62
  resetStack: true
63
63
  }, {
64
- id: 'vlineto',
64
+ id: "vlineto",
65
65
  min: 1,
66
66
  resetStack: true
67
67
  }, {
68
- id: 'rrcurveto',
68
+ id: "rrcurveto",
69
69
  min: 6,
70
70
  resetStack: true
71
71
  }, null, {
72
- id: 'callsubr',
72
+ id: "callsubr",
73
73
  min: 1,
74
74
  undefStack: true
75
75
  }, {
76
- id: 'return',
76
+ id: "return",
77
77
  min: 0,
78
78
  undefStack: true
79
79
  }, null, null, {
80
- id: 'endchar',
80
+ id: "endchar",
81
81
  min: 0,
82
82
  stackClearing: true
83
83
  }, null, null, null, {
84
- id: 'hstemhm',
84
+ id: "hstemhm",
85
85
  min: 2,
86
86
  stackClearing: true,
87
87
  stem: true
88
88
  }, {
89
- id: 'hintmask',
89
+ id: "hintmask",
90
90
  min: 0,
91
91
  stackClearing: true
92
92
  }, {
93
- id: 'cntrmask',
93
+ id: "cntrmask",
94
94
  min: 0,
95
95
  stackClearing: true
96
96
  }, {
97
- id: 'rmoveto',
97
+ id: "rmoveto",
98
98
  min: 2,
99
99
  stackClearing: true
100
100
  }, {
101
- id: 'hmoveto',
101
+ id: "hmoveto",
102
102
  min: 1,
103
103
  stackClearing: true
104
104
  }, {
105
- id: 'vstemhm',
105
+ id: "vstemhm",
106
106
  min: 2,
107
107
  stackClearing: true,
108
108
  stem: true
109
109
  }, {
110
- id: 'rcurveline',
110
+ id: "rcurveline",
111
111
  min: 8,
112
112
  resetStack: true
113
113
  }, {
114
- id: 'rlinecurve',
114
+ id: "rlinecurve",
115
115
  min: 8,
116
116
  resetStack: true
117
117
  }, {
118
- id: 'vvcurveto',
118
+ id: "vvcurveto",
119
119
  min: 4,
120
120
  resetStack: true
121
121
  }, {
122
- id: 'hhcurveto',
122
+ id: "hhcurveto",
123
123
  min: 4,
124
124
  resetStack: true
125
125
  }, null, {
126
- id: 'callgsubr',
126
+ id: "callgsubr",
127
127
  min: 1,
128
128
  undefStack: true
129
129
  }, {
130
- id: 'vhcurveto',
130
+ id: "vhcurveto",
131
131
  min: 4,
132
132
  resetStack: true
133
133
  }, {
134
- id: 'hvcurveto',
134
+ id: "hvcurveto",
135
135
  min: 4,
136
136
  resetStack: true
137
137
  }];
138
138
  var CharstringValidationData12 = [null, null, null, {
139
- id: 'and',
139
+ id: "and",
140
140
  min: 2,
141
141
  stackDelta: -1
142
142
  }, {
143
- id: 'or',
143
+ id: "or",
144
144
  min: 2,
145
145
  stackDelta: -1
146
146
  }, {
147
- id: 'not',
147
+ id: "not",
148
148
  min: 1,
149
149
  stackDelta: 0
150
150
  }, null, null, null, {
151
- id: 'abs',
151
+ id: "abs",
152
152
  min: 1,
153
153
  stackDelta: 0
154
154
  }, {
155
- id: 'add',
155
+ id: "add",
156
156
  min: 2,
157
157
  stackDelta: -1,
158
158
  stackFn: function stack_div(stack, index) {
159
159
  stack[index - 2] = stack[index - 2] + stack[index - 1];
160
160
  }
161
161
  }, {
162
- id: 'sub',
162
+ id: "sub",
163
163
  min: 2,
164
164
  stackDelta: -1,
165
165
  stackFn: function stack_div(stack, index) {
166
166
  stack[index - 2] = stack[index - 2] - stack[index - 1];
167
167
  }
168
168
  }, {
169
- id: 'div',
169
+ id: "div",
170
170
  min: 2,
171
171
  stackDelta: -1,
172
172
  stackFn: function stack_div(stack, index) {
173
173
  stack[index - 2] = stack[index - 2] / stack[index - 1];
174
174
  }
175
175
  }, null, {
176
- id: 'neg',
176
+ id: "neg",
177
177
  min: 1,
178
178
  stackDelta: 0,
179
179
  stackFn: function stack_div(stack, index) {
180
180
  stack[index - 1] = -stack[index - 1];
181
181
  }
182
182
  }, {
183
- id: 'eq',
183
+ id: "eq",
184
184
  min: 2,
185
185
  stackDelta: -1
186
186
  }, null, null, {
187
- id: 'drop',
187
+ id: "drop",
188
188
  min: 1,
189
189
  stackDelta: -1
190
190
  }, null, {
191
- id: 'put',
191
+ id: "put",
192
192
  min: 2,
193
193
  stackDelta: -2
194
194
  }, {
195
- id: 'get',
195
+ id: "get",
196
196
  min: 1,
197
197
  stackDelta: 0
198
198
  }, {
199
- id: 'ifelse',
199
+ id: "ifelse",
200
200
  min: 4,
201
201
  stackDelta: -3
202
202
  }, {
203
- id: 'random',
203
+ id: "random",
204
204
  min: 0,
205
205
  stackDelta: 1
206
206
  }, {
207
- id: 'mul',
207
+ id: "mul",
208
208
  min: 2,
209
209
  stackDelta: -1,
210
210
  stackFn: function stack_div(stack, index) {
211
211
  stack[index - 2] = stack[index - 2] * stack[index - 1];
212
212
  }
213
213
  }, null, {
214
- id: 'sqrt',
214
+ id: "sqrt",
215
215
  min: 1,
216
216
  stackDelta: 0
217
217
  }, {
218
- id: 'dup',
218
+ id: "dup",
219
219
  min: 1,
220
220
  stackDelta: 1
221
221
  }, {
222
- id: 'exch',
222
+ id: "exch",
223
223
  min: 2,
224
224
  stackDelta: 0
225
225
  }, {
226
- id: 'index',
226
+ id: "index",
227
227
  min: 2,
228
228
  stackDelta: 0
229
229
  }, {
230
- id: 'roll',
230
+ id: "roll",
231
231
  min: 3,
232
232
  stackDelta: -2
233
233
  }, null, null, null, {
234
- id: 'hflex',
234
+ id: "hflex",
235
235
  min: 7,
236
236
  resetStack: true
237
237
  }, {
238
- id: 'flex',
238
+ id: "flex",
239
239
  min: 13,
240
240
  resetStack: true
241
241
  }, {
242
- id: 'hflex1',
242
+ id: "hflex1",
243
243
  min: 9,
244
244
  resetStack: true
245
245
  }, {
246
- id: 'flex1',
246
+ id: "flex1",
247
247
  min: 11,
248
248
  resetStack: true
249
249
  }];
250
250
 
251
- function CFFParser(file, properties, seacAnalysisEnabled) {
252
- this.bytes = file.getBytes();
253
- this.properties = properties;
254
- this.seacAnalysisEnabled = !!seacAnalysisEnabled;
255
- }
251
+ class CFFParser {
252
+ constructor(file, properties, seacAnalysisEnabled) {
253
+ this.bytes = file.getBytes();
254
+ this.properties = properties;
255
+ this.seacAnalysisEnabled = !!seacAnalysisEnabled;
256
+ }
256
257
 
257
- CFFParser.prototype = {
258
- parse: function CFFParser_parse() {
258
+ parse() {
259
259
  var properties = this.properties;
260
260
  var cff = new CFF();
261
261
  this.cff = cff;
@@ -272,16 +272,16 @@ var CFFParser = function CFFParserClosure() {
272
272
  cff.topDict = topDict;
273
273
  cff.globalSubrIndex = globalSubrIndex.obj;
274
274
  this.parsePrivateDict(cff.topDict);
275
- cff.isCIDFont = topDict.hasName('ROS');
276
- var charStringOffset = topDict.getByName('CharStrings');
275
+ cff.isCIDFont = topDict.hasName("ROS");
276
+ var charStringOffset = topDict.getByName("CharStrings");
277
277
  var charStringIndex = this.parseIndex(charStringOffset).obj;
278
- var fontMatrix = topDict.getByName('FontMatrix');
278
+ var fontMatrix = topDict.getByName("FontMatrix");
279
279
 
280
280
  if (fontMatrix) {
281
281
  properties.fontMatrix = fontMatrix;
282
282
  }
283
283
 
284
- var fontBBox = topDict.getByName('FontBBox');
284
+ var fontBBox = topDict.getByName("FontBBox");
285
285
 
286
286
  if (fontBBox) {
287
287
  properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
@@ -292,7 +292,7 @@ var CFFParser = function CFFParserClosure() {
292
292
  var charset, encoding;
293
293
 
294
294
  if (cff.isCIDFont) {
295
- var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
295
+ var fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
296
296
 
297
297
  for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
298
298
  var dictRaw = fdArrayIndex.get(i);
@@ -302,11 +302,11 @@ var CFFParser = function CFFParserClosure() {
302
302
  }
303
303
 
304
304
  encoding = null;
305
- charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
306
- cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
305
+ charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, true);
306
+ cff.fdSelect = this.parseFDSelect(topDict.getByName("FDSelect"), charStringIndex.count);
307
307
  } else {
308
- charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
309
- encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
308
+ charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, false);
309
+ encoding = this.parseEncoding(topDict.getByName("Encoding"), properties, cff.strings, charset.charset);
310
310
  }
311
311
 
312
312
  cff.charset = charset;
@@ -323,8 +323,9 @@ var CFFParser = function CFFParserClosure() {
323
323
  cff.seacs = charStringsAndSeacs.seacs;
324
324
  cff.widths = charStringsAndSeacs.widths;
325
325
  return cff;
326
- },
327
- parseHeader: function CFFParser_parseHeader() {
326
+ }
327
+
328
+ parseHeader() {
328
329
  var bytes = this.bytes;
329
330
  var bytesLength = bytes.length;
330
331
  var offset = 0;
@@ -334,11 +335,11 @@ var CFFParser = function CFFParserClosure() {
334
335
  }
335
336
 
336
337
  if (offset >= bytesLength) {
337
- throw new _util.FormatError('Invalid CFF header');
338
+ throw new _util.FormatError("Invalid CFF header");
338
339
  }
339
340
 
340
341
  if (offset !== 0) {
341
- (0, _util.info)('cff data is shifted');
342
+ (0, _util.info)("cff data is shifted");
342
343
  bytes = bytes.subarray(offset);
343
344
  this.bytes = bytes;
344
345
  }
@@ -352,8 +353,9 @@ var CFFParser = function CFFParserClosure() {
352
353
  obj: header,
353
354
  endPos: hdrSize
354
355
  };
355
- },
356
- parseDict: function CFFParser_parseDict(dict) {
356
+ }
357
+
358
+ parseDict(dict) {
357
359
  var pos = 0;
358
360
 
359
361
  function parseOperand() {
@@ -384,9 +386,9 @@ var CFFParser = function CFFParserClosure() {
384
386
  }
385
387
 
386
388
  function parseFloatOperand() {
387
- var str = '';
389
+ var str = "";
388
390
  var eof = 15;
389
- var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'E', 'E-', null, '-'];
391
+ const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
390
392
  var length = dict.length;
391
393
 
392
394
  while (pos < length) {
@@ -432,8 +434,9 @@ var CFFParser = function CFFParserClosure() {
432
434
  }
433
435
 
434
436
  return entries;
435
- },
436
- parseIndex: function CFFParser_parseIndex(pos) {
437
+ }
438
+
439
+ parseIndex(pos) {
437
440
  var cffIndex = new CFFIndex();
438
441
  var bytes = this.bytes;
439
442
  var count = bytes[pos++] << 8 | bytes[pos++];
@@ -469,8 +472,9 @@ var CFFParser = function CFFParserClosure() {
469
472
  obj: cffIndex,
470
473
  endPos: end
471
474
  };
472
- },
473
- parseNameIndex: function CFFParser_parseNameIndex(index) {
475
+ }
476
+
477
+ parseNameIndex(index) {
474
478
  var names = [];
475
479
 
476
480
  for (var i = 0, ii = index.count; i < ii; ++i) {
@@ -479,8 +483,9 @@ var CFFParser = function CFFParserClosure() {
479
483
  }
480
484
 
481
485
  return names;
482
- },
483
- parseStringIndex: function CFFParser_parseStringIndex(index) {
486
+ }
487
+
488
+ parseStringIndex(index) {
484
489
  var strings = new CFFStrings();
485
490
 
486
491
  for (var i = 0, ii = index.count; i < ii; ++i) {
@@ -489,8 +494,9 @@ var CFFParser = function CFFParserClosure() {
489
494
  }
490
495
 
491
496
  return strings;
492
- },
493
- createDict: function CFFParser_createDict(Type, dict, strings) {
497
+ }
498
+
499
+ createDict(Type, dict, strings) {
494
500
  var cffDict = new Type(strings);
495
501
 
496
502
  for (var i = 0, ii = dict.length; i < ii; ++i) {
@@ -501,8 +507,9 @@ var CFFParser = function CFFParserClosure() {
501
507
  }
502
508
 
503
509
  return cffDict;
504
- },
505
- parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
510
+ }
511
+
512
+ parseCharString(state, data, localSubrIndex, globalSubrIndex) {
506
513
  if (!data || state.callDepth > MAX_SUBR_NESTING) {
507
514
  return false;
508
515
  }
@@ -567,7 +574,7 @@ var CFFParser = function CFFParserClosure() {
567
574
 
568
575
  if (!subrsIndex) {
569
576
  validationCommand = CharstringValidationData[value];
570
- (0, _util.warn)('Missing subrsIndex for ' + validationCommand.id);
577
+ (0, _util.warn)("Missing subrsIndex for " + validationCommand.id);
571
578
  return false;
572
579
  }
573
580
 
@@ -583,7 +590,7 @@ var CFFParser = function CFFParserClosure() {
583
590
 
584
591
  if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
585
592
  validationCommand = CharstringValidationData[value];
586
- (0, _util.warn)('Out of bounds subrIndex for ' + validationCommand.id);
593
+ (0, _util.warn)("Out of bounds subrIndex for " + validationCommand.id);
587
594
  return false;
588
595
  }
589
596
 
@@ -612,14 +619,14 @@ var CFFParser = function CFFParserClosure() {
612
619
  if (value === 3 || value === 23) {
613
620
  state.hasVStems = true;
614
621
  } else if (state.hasVStems && (value === 1 || value === 18)) {
615
- (0, _util.warn)('CFF stem hints are in wrong order');
622
+ (0, _util.warn)("CFF stem hints are in wrong order");
616
623
  data[j - 1] = value === 1 ? 3 : 23;
617
624
  }
618
625
  }
619
626
 
620
- if ('min' in validationCommand) {
627
+ if ("min" in validationCommand) {
621
628
  if (!state.undefStack && stackSize < validationCommand.min) {
622
- (0, _util.warn)('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
629
+ (0, _util.warn)("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
623
630
  return false;
624
631
  }
625
632
  }
@@ -631,7 +638,7 @@ var CFFParser = function CFFParserClosure() {
631
638
  if (stackSize >= 2 && validationCommand.stem) {
632
639
  stackSize %= 2;
633
640
  } else if (stackSize > 1) {
634
- (0, _util.warn)('Found too many parameters for stack-clearing command');
641
+ (0, _util.warn)("Found too many parameters for stack-clearing command");
635
642
  }
636
643
 
637
644
  if (stackSize > 0 && stack[stackSize - 1] >= 0) {
@@ -639,8 +646,8 @@ var CFFParser = function CFFParserClosure() {
639
646
  }
640
647
  }
641
648
 
642
- if ('stackDelta' in validationCommand) {
643
- if ('stackFn' in validationCommand) {
649
+ if ("stackDelta" in validationCommand) {
650
+ if ("stackFn" in validationCommand) {
644
651
  validationCommand.stackFn(stack, stackSize);
645
652
  }
646
653
 
@@ -660,14 +667,16 @@ var CFFParser = function CFFParserClosure() {
660
667
 
661
668
  state.stackSize = stackSize;
662
669
  return true;
663
- },
664
- parseCharStrings: function parseCharStrings(_ref) {
665
- var charStrings = _ref.charStrings,
666
- localSubrIndex = _ref.localSubrIndex,
667
- globalSubrIndex = _ref.globalSubrIndex,
668
- fdSelect = _ref.fdSelect,
669
- fdArray = _ref.fdArray,
670
- privateDict = _ref.privateDict;
670
+ }
671
+
672
+ parseCharStrings({
673
+ charStrings,
674
+ localSubrIndex,
675
+ globalSubrIndex,
676
+ fdSelect,
677
+ fdArray,
678
+ privateDict
679
+ }) {
671
680
  var seacs = [];
672
681
  var widths = [];
673
682
  var count = charStrings.count;
@@ -693,12 +702,12 @@ var CFFParser = function CFFParserClosure() {
693
702
  var fdIndex = fdSelect.getFDIndex(i);
694
703
 
695
704
  if (fdIndex === -1) {
696
- (0, _util.warn)('Glyph index is not in fd select.');
705
+ (0, _util.warn)("Glyph index is not in fd select.");
697
706
  valid = false;
698
707
  }
699
708
 
700
709
  if (fdIndex >= fdArray.length) {
701
- (0, _util.warn)('Invalid fd index for glyph index.');
710
+ (0, _util.warn)("Invalid fd index for glyph index.");
702
711
  valid = false;
703
712
  }
704
713
 
@@ -715,10 +724,10 @@ var CFFParser = function CFFParserClosure() {
715
724
  }
716
725
 
717
726
  if (state.width !== null) {
718
- var nominalWidth = privateDictToUse.getByName('nominalWidthX');
727
+ const nominalWidth = privateDictToUse.getByName("nominalWidthX");
719
728
  widths[i] = nominalWidth + state.width;
720
729
  } else {
721
- var defaultWidth = privateDictToUse.getByName('defaultWidthX');
730
+ const defaultWidth = privateDictToUse.getByName("defaultWidthX");
722
731
  widths[i] = defaultWidth;
723
732
  }
724
733
 
@@ -732,26 +741,28 @@ var CFFParser = function CFFParserClosure() {
732
741
  }
733
742
 
734
743
  return {
735
- charStrings: charStrings,
736
- seacs: seacs,
737
- widths: widths
744
+ charStrings,
745
+ seacs,
746
+ widths
738
747
  };
739
- },
740
- emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
748
+ }
749
+
750
+ emptyPrivateDictionary(parentDict) {
741
751
  var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
742
752
  parentDict.setByKey(18, [0, 0]);
743
753
  parentDict.privateDict = privateDict;
744
- },
745
- parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
746
- if (!parentDict.hasName('Private')) {
754
+ }
755
+
756
+ parsePrivateDict(parentDict) {
757
+ if (!parentDict.hasName("Private")) {
747
758
  this.emptyPrivateDictionary(parentDict);
748
759
  return;
749
760
  }
750
761
 
751
- var privateOffset = parentDict.getByName('Private');
762
+ var privateOffset = parentDict.getByName("Private");
752
763
 
753
764
  if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
754
- parentDict.removeByName('Private');
765
+ parentDict.removeByName("Private");
755
766
  return;
756
767
  }
757
768
 
@@ -769,11 +780,11 @@ var CFFParser = function CFFParserClosure() {
769
780
  var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
770
781
  parentDict.privateDict = privateDict;
771
782
 
772
- if (!privateDict.getByName('Subrs')) {
783
+ if (!privateDict.getByName("Subrs")) {
773
784
  return;
774
785
  }
775
786
 
776
- var subrsOffset = privateDict.getByName('Subrs');
787
+ var subrsOffset = privateDict.getByName("Subrs");
777
788
  var relativeOffset = offset + subrsOffset;
778
789
 
779
790
  if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
@@ -783,8 +794,9 @@ var CFFParser = function CFFParserClosure() {
783
794
 
784
795
  var subrsIndex = this.parseIndex(relativeOffset);
785
796
  privateDict.subrsIndex = subrsIndex.obj;
786
- },
787
- parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
797
+ }
798
+
799
+ parseCharsets(pos, length, strings, cid) {
788
800
  if (pos === 0) {
789
801
  return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);
790
802
  } else if (pos === 1) {
@@ -796,7 +808,7 @@ var CFFParser = function CFFParserClosure() {
796
808
  var bytes = this.bytes;
797
809
  var start = pos;
798
810
  var format = bytes[pos++];
799
- var charset = ['.notdef'];
811
+ const charset = [cid ? 0 : ".notdef"];
800
812
  var id, count, i;
801
813
  length -= 1;
802
814
 
@@ -834,14 +846,15 @@ var CFFParser = function CFFParserClosure() {
834
846
  break;
835
847
 
836
848
  default:
837
- throw new _util.FormatError('Unknown charset format');
849
+ throw new _util.FormatError("Unknown charset format");
838
850
  }
839
851
 
840
852
  var end = pos;
841
853
  var raw = bytes.subarray(start, end);
842
854
  return new CFFCharset(false, format, charset, raw);
843
- },
844
- parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
855
+ }
856
+
857
+ parseEncoding(pos, properties, strings, charset) {
845
858
  var encoding = Object.create(null);
846
859
  var bytes = this.bytes;
847
860
  var predefined = false;
@@ -900,7 +913,7 @@ var CFFParser = function CFFParserClosure() {
900
913
  break;
901
914
 
902
915
  default:
903
- throw new _util.FormatError("Unknown encoding format: ".concat(format, " in CFF"));
916
+ throw new _util.FormatError(`Unknown encoding format: ${format} in CFF`);
904
917
  }
905
918
 
906
919
  var dataEnd = pos;
@@ -915,8 +928,9 @@ var CFFParser = function CFFParserClosure() {
915
928
 
916
929
  format = format & 0x7f;
917
930
  return new CFFEncoding(predefined, format, encoding, raw);
918
- },
919
- parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
931
+ }
932
+
933
+ parseFDSelect(pos, length) {
920
934
  var bytes = this.bytes;
921
935
  var format = bytes[pos++];
922
936
  var fdSelect = [];
@@ -938,7 +952,7 @@ var CFFParser = function CFFParserClosure() {
938
952
  var first = bytes[pos++] << 8 | bytes[pos++];
939
953
 
940
954
  if (i === 0 && first !== 0) {
941
- (0, _util.warn)('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
955
+ (0, _util.warn)("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
942
956
  first = 0;
943
957
  }
944
958
 
@@ -954,23 +968,25 @@ var CFFParser = function CFFParserClosure() {
954
968
  break;
955
969
 
956
970
  default:
957
- throw new _util.FormatError("parseFDSelect: Unknown format \"".concat(format, "\"."));
971
+ throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`);
958
972
  }
959
973
 
960
974
  if (fdSelect.length !== length) {
961
- throw new _util.FormatError('parseFDSelect: Invalid font data.');
975
+ throw new _util.FormatError("parseFDSelect: Invalid font data.");
962
976
  }
963
977
 
964
978
  return new CFFFDSelect(format, fdSelect);
965
979
  }
966
- };
980
+
981
+ }
982
+
967
983
  return CFFParser;
968
984
  }();
969
985
 
970
986
  exports.CFFParser = CFFParser;
971
987
 
972
- var CFF = function CFFClosure() {
973
- function CFF() {
988
+ class CFF {
989
+ constructor() {
974
990
  this.header = null;
975
991
  this.names = [];
976
992
  this.topDict = null;
@@ -984,124 +1000,120 @@ var CFF = function CFFClosure() {
984
1000
  this.isCIDFont = false;
985
1001
  }
986
1002
 
987
- CFF.prototype = {
988
- duplicateFirstGlyph: function CFF_duplicateFirstGlyph() {
989
- if (this.charStrings.count >= 65535) {
990
- (0, _util.warn)('Not enough space in charstrings to duplicate first glyph.');
991
- return;
992
- }
1003
+ duplicateFirstGlyph() {
1004
+ if (this.charStrings.count >= 65535) {
1005
+ (0, _util.warn)("Not enough space in charstrings to duplicate first glyph.");
1006
+ return;
1007
+ }
993
1008
 
994
- var glyphZero = this.charStrings.get(0);
995
- this.charStrings.add(glyphZero);
1009
+ var glyphZero = this.charStrings.get(0);
1010
+ this.charStrings.add(glyphZero);
996
1011
 
997
- if (this.isCIDFont) {
998
- this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
999
- }
1000
- },
1001
- hasGlyphId: function CFF_hasGlyphID(id) {
1002
- if (id < 0 || id >= this.charStrings.count) {
1003
- return false;
1004
- }
1012
+ if (this.isCIDFont) {
1013
+ this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
1014
+ }
1015
+ }
1005
1016
 
1006
- var glyph = this.charStrings.get(id);
1007
- return glyph.length > 0;
1017
+ hasGlyphId(id) {
1018
+ if (id < 0 || id >= this.charStrings.count) {
1019
+ return false;
1008
1020
  }
1009
- };
1010
- return CFF;
1011
- }();
1021
+
1022
+ var glyph = this.charStrings.get(id);
1023
+ return glyph.length > 0;
1024
+ }
1025
+
1026
+ }
1012
1027
 
1013
1028
  exports.CFF = CFF;
1014
1029
 
1015
- var CFFHeader = function CFFHeaderClosure() {
1016
- function CFFHeader(major, minor, hdrSize, offSize) {
1030
+ class CFFHeader {
1031
+ constructor(major, minor, hdrSize, offSize) {
1017
1032
  this.major = major;
1018
1033
  this.minor = minor;
1019
1034
  this.hdrSize = hdrSize;
1020
1035
  this.offSize = offSize;
1021
1036
  }
1022
1037
 
1023
- return CFFHeader;
1024
- }();
1038
+ }
1025
1039
 
1026
1040
  exports.CFFHeader = CFFHeader;
1027
1041
 
1028
- var CFFStrings = function CFFStringsClosure() {
1029
- function CFFStrings() {
1042
+ class CFFStrings {
1043
+ constructor() {
1030
1044
  this.strings = [];
1031
1045
  }
1032
1046
 
1033
- CFFStrings.prototype = {
1034
- get: function CFFStrings_get(index) {
1035
- if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
1036
- return CFFStandardStrings[index];
1037
- }
1038
-
1039
- if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
1040
- return this.strings[index - NUM_STANDARD_CFF_STRINGS];
1041
- }
1047
+ get(index) {
1048
+ if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
1049
+ return CFFStandardStrings[index];
1050
+ }
1042
1051
 
1043
- return CFFStandardStrings[0];
1044
- },
1045
- getSID: function CFFStrings_getSID(str) {
1046
- var index = CFFStandardStrings.indexOf(str);
1052
+ if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
1053
+ return this.strings[index - NUM_STANDARD_CFF_STRINGS];
1054
+ }
1047
1055
 
1048
- if (index !== -1) {
1049
- return index;
1050
- }
1056
+ return CFFStandardStrings[0];
1057
+ }
1051
1058
 
1052
- index = this.strings.indexOf(str);
1059
+ getSID(str) {
1060
+ let index = CFFStandardStrings.indexOf(str);
1053
1061
 
1054
- if (index !== -1) {
1055
- return index + NUM_STANDARD_CFF_STRINGS;
1056
- }
1062
+ if (index !== -1) {
1063
+ return index;
1064
+ }
1057
1065
 
1058
- return -1;
1059
- },
1060
- add: function CFFStrings_add(value) {
1061
- this.strings.push(value);
1062
- },
1066
+ index = this.strings.indexOf(str);
1063
1067
 
1064
- get count() {
1065
- return this.strings.length;
1068
+ if (index !== -1) {
1069
+ return index + NUM_STANDARD_CFF_STRINGS;
1066
1070
  }
1067
1071
 
1068
- };
1069
- return CFFStrings;
1070
- }();
1072
+ return -1;
1073
+ }
1074
+
1075
+ add(value) {
1076
+ this.strings.push(value);
1077
+ }
1078
+
1079
+ get count() {
1080
+ return this.strings.length;
1081
+ }
1082
+
1083
+ }
1071
1084
 
1072
1085
  exports.CFFStrings = CFFStrings;
1073
1086
 
1074
- var CFFIndex = function CFFIndexClosure() {
1075
- function CFFIndex() {
1087
+ class CFFIndex {
1088
+ constructor() {
1076
1089
  this.objects = [];
1077
1090
  this.length = 0;
1078
1091
  }
1079
1092
 
1080
- CFFIndex.prototype = {
1081
- add: function CFFIndex_add(data) {
1082
- this.length += data.length;
1083
- this.objects.push(data);
1084
- },
1085
- set: function CFFIndex_set(index, data) {
1086
- this.length += data.length - this.objects[index].length;
1087
- this.objects[index] = data;
1088
- },
1089
- get: function CFFIndex_get(index) {
1090
- return this.objects[index];
1091
- },
1092
-
1093
- get count() {
1094
- return this.objects.length;
1095
- }
1096
-
1097
- };
1098
- return CFFIndex;
1099
- }();
1093
+ add(data) {
1094
+ this.length += data.length;
1095
+ this.objects.push(data);
1096
+ }
1097
+
1098
+ set(index, data) {
1099
+ this.length += data.length - this.objects[index].length;
1100
+ this.objects[index] = data;
1101
+ }
1102
+
1103
+ get(index) {
1104
+ return this.objects[index];
1105
+ }
1106
+
1107
+ get count() {
1108
+ return this.objects.length;
1109
+ }
1110
+
1111
+ }
1100
1112
 
1101
1113
  exports.CFFIndex = CFFIndex;
1102
1114
 
1103
- var CFFDict = function CFFDictClosure() {
1104
- function CFFDict(tables, strings) {
1115
+ class CFFDict {
1116
+ constructor(tables, strings) {
1105
1117
  this.keyToNameMap = tables.keyToNameMap;
1106
1118
  this.nameToKeyMap = tables.nameToKeyMap;
1107
1119
  this.defaults = tables.defaults;
@@ -1112,63 +1124,65 @@ var CFFDict = function CFFDictClosure() {
1112
1124
  this.values = Object.create(null);
1113
1125
  }
1114
1126
 
1115
- CFFDict.prototype = {
1116
- setByKey: function CFFDict_setByKey(key, value) {
1117
- if (!(key in this.keyToNameMap)) {
1118
- return false;
1119
- }
1127
+ setByKey(key, value) {
1128
+ if (!(key in this.keyToNameMap)) {
1129
+ return false;
1130
+ }
1120
1131
 
1121
- var valueLength = value.length;
1132
+ var valueLength = value.length;
1122
1133
 
1123
- if (valueLength === 0) {
1134
+ if (valueLength === 0) {
1135
+ return true;
1136
+ }
1137
+
1138
+ for (var i = 0; i < valueLength; i++) {
1139
+ if (isNaN(value[i])) {
1140
+ (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
1124
1141
  return true;
1125
1142
  }
1143
+ }
1126
1144
 
1127
- for (var i = 0; i < valueLength; i++) {
1128
- if (isNaN(value[i])) {
1129
- (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
1130
- return true;
1131
- }
1132
- }
1145
+ var type = this.types[key];
1133
1146
 
1134
- var type = this.types[key];
1147
+ if (type === "num" || type === "sid" || type === "offset") {
1148
+ value = value[0];
1149
+ }
1135
1150
 
1136
- if (type === 'num' || type === 'sid' || type === 'offset') {
1137
- value = value[0];
1138
- }
1151
+ this.values[key] = value;
1152
+ return true;
1153
+ }
1139
1154
 
1140
- this.values[key] = value;
1141
- return true;
1142
- },
1143
- setByName: function CFFDict_setByName(name, value) {
1144
- if (!(name in this.nameToKeyMap)) {
1145
- throw new _util.FormatError("Invalid dictionary name \"".concat(name, "\""));
1146
- }
1155
+ setByName(name, value) {
1156
+ if (!(name in this.nameToKeyMap)) {
1157
+ throw new _util.FormatError(`Invalid dictionary name "${name}"`);
1158
+ }
1147
1159
 
1148
- this.values[this.nameToKeyMap[name]] = value;
1149
- },
1150
- hasName: function CFFDict_hasName(name) {
1151
- return this.nameToKeyMap[name] in this.values;
1152
- },
1153
- getByName: function CFFDict_getByName(name) {
1154
- if (!(name in this.nameToKeyMap)) {
1155
- throw new _util.FormatError("Invalid dictionary name ".concat(name, "\""));
1156
- }
1160
+ this.values[this.nameToKeyMap[name]] = value;
1161
+ }
1157
1162
 
1158
- var key = this.nameToKeyMap[name];
1163
+ hasName(name) {
1164
+ return this.nameToKeyMap[name] in this.values;
1165
+ }
1159
1166
 
1160
- if (!(key in this.values)) {
1161
- return this.defaults[key];
1162
- }
1167
+ getByName(name) {
1168
+ if (!(name in this.nameToKeyMap)) {
1169
+ throw new _util.FormatError(`Invalid dictionary name ${name}"`);
1170
+ }
1171
+
1172
+ var key = this.nameToKeyMap[name];
1163
1173
 
1164
- return this.values[key];
1165
- },
1166
- removeByName: function CFFDict_removeByName(name) {
1167
- delete this.values[this.nameToKeyMap[name]];
1174
+ if (!(key in this.values)) {
1175
+ return this.defaults[key];
1168
1176
  }
1169
- };
1170
1177
 
1171
- CFFDict.createTables = function CFFDict_createTables(layout) {
1178
+ return this.values[key];
1179
+ }
1180
+
1181
+ removeByName(name) {
1182
+ delete this.values[this.nameToKeyMap[name]];
1183
+ }
1184
+
1185
+ static createTables(layout) {
1172
1186
  var tables = {
1173
1187
  keyToNameMap: {},
1174
1188
  nameToKeyMap: {},
@@ -1190,44 +1204,47 @@ var CFFDict = function CFFDictClosure() {
1190
1204
  }
1191
1205
 
1192
1206
  return tables;
1193
- };
1207
+ }
1194
1208
 
1195
- return CFFDict;
1196
- }();
1209
+ }
1197
1210
 
1198
1211
  var CFFTopDict = function CFFTopDictClosure() {
1199
- var layout = [[[12, 30], 'ROS', ['sid', 'sid', 'num'], null], [[12, 20], 'SyntheticBase', 'num', null], [0, 'version', 'sid', null], [1, 'Notice', 'sid', null], [[12, 0], 'Copyright', 'sid', null], [2, 'FullName', 'sid', null], [3, 'FamilyName', 'sid', null], [4, 'Weight', 'sid', null], [[12, 1], 'isFixedPitch', 'num', 0], [[12, 2], 'ItalicAngle', 'num', 0], [[12, 3], 'UnderlinePosition', 'num', -100], [[12, 4], 'UnderlineThickness', 'num', 50], [[12, 5], 'PaintType', 'num', 0], [[12, 6], 'CharstringType', 'num', 2], [[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'], [0.001, 0, 0, 0.001, 0, 0]], [13, 'UniqueID', 'num', null], [5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]], [[12, 8], 'StrokeWidth', 'num', 0], [14, 'XUID', 'array', null], [15, 'charset', 'offset', 0], [16, 'Encoding', 'offset', 0], [17, 'CharStrings', 'offset', 0], [18, 'Private', ['offset', 'offset'], null], [[12, 21], 'PostScript', 'sid', null], [[12, 22], 'BaseFontName', 'sid', null], [[12, 23], 'BaseFontBlend', 'delta', null], [[12, 31], 'CIDFontVersion', 'num', 0], [[12, 32], 'CIDFontRevision', 'num', 0], [[12, 33], 'CIDFontType', 'num', 0], [[12, 34], 'CIDCount', 'num', 8720], [[12, 35], 'UIDBase', 'num', null], [[12, 37], 'FDSelect', 'offset', null], [[12, 36], 'FDArray', 'offset', null], [[12, 38], 'FontName', 'sid', null]];
1212
+ var layout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
1200
1213
  var tables = null;
1201
1214
 
1202
- function CFFTopDict(strings) {
1203
- if (tables === null) {
1204
- tables = CFFDict.createTables(layout);
1215
+ class CFFTopDict extends CFFDict {
1216
+ constructor(strings) {
1217
+ if (tables === null) {
1218
+ tables = CFFDict.createTables(layout);
1219
+ }
1220
+
1221
+ super(tables, strings);
1222
+ this.privateDict = null;
1205
1223
  }
1206
1224
 
1207
- CFFDict.call(this, tables, strings);
1208
- this.privateDict = null;
1209
1225
  }
1210
1226
 
1211
- CFFTopDict.prototype = Object.create(CFFDict.prototype);
1212
1227
  return CFFTopDict;
1213
1228
  }();
1214
1229
 
1215
1230
  exports.CFFTopDict = CFFTopDict;
1216
1231
 
1217
1232
  var CFFPrivateDict = function CFFPrivateDictClosure() {
1218
- var layout = [[6, 'BlueValues', 'delta', null], [7, 'OtherBlues', 'delta', null], [8, 'FamilyBlues', 'delta', null], [9, 'FamilyOtherBlues', 'delta', null], [[12, 9], 'BlueScale', 'num', 0.039625], [[12, 10], 'BlueShift', 'num', 7], [[12, 11], 'BlueFuzz', 'num', 1], [10, 'StdHW', 'num', null], [11, 'StdVW', 'num', null], [[12, 12], 'StemSnapH', 'delta', null], [[12, 13], 'StemSnapV', 'delta', null], [[12, 14], 'ForceBold', 'num', 0], [[12, 17], 'LanguageGroup', 'num', 0], [[12, 18], 'ExpansionFactor', 'num', 0.06], [[12, 19], 'initialRandomSeed', 'num', 0], [20, 'defaultWidthX', 'num', 0], [21, 'nominalWidthX', 'num', 0], [19, 'Subrs', 'offset', null]];
1233
+ var layout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", 0.039625], [[12, 10], "BlueShift", "num", 7], [[12, 11], "BlueFuzz", "num", 1], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", 0.06], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
1219
1234
  var tables = null;
1220
1235
 
1221
- function CFFPrivateDict(strings) {
1222
- if (tables === null) {
1223
- tables = CFFDict.createTables(layout);
1236
+ class CFFPrivateDict extends CFFDict {
1237
+ constructor(strings) {
1238
+ if (tables === null) {
1239
+ tables = CFFDict.createTables(layout);
1240
+ }
1241
+
1242
+ super(tables, strings);
1243
+ this.subrsIndex = null;
1224
1244
  }
1225
1245
 
1226
- CFFDict.call(this, tables, strings);
1227
- this.subrsIndex = null;
1228
1246
  }
1229
1247
 
1230
- CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
1231
1248
  return CFFPrivateDict;
1232
1249
  }();
1233
1250
 
@@ -1238,578 +1255,592 @@ var CFFCharsetPredefinedTypes = {
1238
1255
  EXPERT_SUBSET: 2
1239
1256
  };
1240
1257
 
1241
- var CFFCharset = function CFFCharsetClosure() {
1242
- function CFFCharset(predefined, format, charset, raw) {
1258
+ class CFFCharset {
1259
+ constructor(predefined, format, charset, raw) {
1243
1260
  this.predefined = predefined;
1244
1261
  this.format = format;
1245
1262
  this.charset = charset;
1246
1263
  this.raw = raw;
1247
1264
  }
1248
1265
 
1249
- return CFFCharset;
1250
- }();
1266
+ }
1251
1267
 
1252
1268
  exports.CFFCharset = CFFCharset;
1253
1269
 
1254
- var CFFEncoding = function CFFEncodingClosure() {
1255
- function CFFEncoding(predefined, format, encoding, raw) {
1270
+ class CFFEncoding {
1271
+ constructor(predefined, format, encoding, raw) {
1256
1272
  this.predefined = predefined;
1257
1273
  this.format = format;
1258
1274
  this.encoding = encoding;
1259
1275
  this.raw = raw;
1260
1276
  }
1261
1277
 
1262
- return CFFEncoding;
1263
- }();
1278
+ }
1264
1279
 
1265
- var CFFFDSelect = function CFFFDSelectClosure() {
1266
- function CFFFDSelect(format, fdSelect) {
1280
+ class CFFFDSelect {
1281
+ constructor(format, fdSelect) {
1267
1282
  this.format = format;
1268
1283
  this.fdSelect = fdSelect;
1269
1284
  }
1270
1285
 
1271
- CFFFDSelect.prototype = {
1272
- getFDIndex: function CFFFDSelect_get(glyphIndex) {
1273
- if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
1274
- return -1;
1275
- }
1276
-
1277
- return this.fdSelect[glyphIndex];
1286
+ getFDIndex(glyphIndex) {
1287
+ if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
1288
+ return -1;
1278
1289
  }
1279
- };
1280
- return CFFFDSelect;
1281
- }();
1290
+
1291
+ return this.fdSelect[glyphIndex];
1292
+ }
1293
+
1294
+ }
1282
1295
 
1283
1296
  exports.CFFFDSelect = CFFFDSelect;
1284
1297
 
1285
- var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
1286
- function CFFOffsetTracker() {
1298
+ class CFFOffsetTracker {
1299
+ constructor() {
1287
1300
  this.offsets = Object.create(null);
1288
1301
  }
1289
1302
 
1290
- CFFOffsetTracker.prototype = {
1291
- isTracking: function CFFOffsetTracker_isTracking(key) {
1292
- return key in this.offsets;
1293
- },
1294
- track: function CFFOffsetTracker_track(key, location) {
1295
- if (key in this.offsets) {
1296
- throw new _util.FormatError("Already tracking location of ".concat(key));
1297
- }
1303
+ isTracking(key) {
1304
+ return key in this.offsets;
1305
+ }
1298
1306
 
1299
- this.offsets[key] = location;
1300
- },
1301
- offset: function CFFOffsetTracker_offset(value) {
1302
- for (var key in this.offsets) {
1303
- this.offsets[key] += value;
1304
- }
1305
- },
1306
- setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
1307
- if (!(key in this.offsets)) {
1308
- throw new _util.FormatError("Not tracking location of ".concat(key));
1309
- }
1307
+ track(key, location) {
1308
+ if (key in this.offsets) {
1309
+ throw new _util.FormatError(`Already tracking location of ${key}`);
1310
+ }
1311
+
1312
+ this.offsets[key] = location;
1313
+ }
1314
+
1315
+ offset(value) {
1316
+ for (var key in this.offsets) {
1317
+ this.offsets[key] += value;
1318
+ }
1319
+ }
1310
1320
 
1311
- var data = output.data;
1312
- var dataOffset = this.offsets[key];
1313
- var size = 5;
1321
+ setEntryLocation(key, values, output) {
1322
+ if (!(key in this.offsets)) {
1323
+ throw new _util.FormatError(`Not tracking location of ${key}`);
1324
+ }
1314
1325
 
1315
- for (var i = 0, ii = values.length; i < ii; ++i) {
1316
- var offset0 = i * size + dataOffset;
1317
- var offset1 = offset0 + 1;
1318
- var offset2 = offset0 + 2;
1319
- var offset3 = offset0 + 3;
1320
- var offset4 = offset0 + 4;
1326
+ var data = output.data;
1327
+ var dataOffset = this.offsets[key];
1328
+ var size = 5;
1321
1329
 
1322
- if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
1323
- throw new _util.FormatError('writing to an offset that is not empty');
1324
- }
1330
+ for (var i = 0, ii = values.length; i < ii; ++i) {
1331
+ var offset0 = i * size + dataOffset;
1332
+ var offset1 = offset0 + 1;
1333
+ var offset2 = offset0 + 2;
1334
+ var offset3 = offset0 + 3;
1335
+ var offset4 = offset0 + 4;
1325
1336
 
1326
- var value = values[i];
1327
- data[offset0] = 0x1d;
1328
- data[offset1] = value >> 24 & 0xFF;
1329
- data[offset2] = value >> 16 & 0xFF;
1330
- data[offset3] = value >> 8 & 0xFF;
1331
- data[offset4] = value & 0xFF;
1337
+ if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
1338
+ throw new _util.FormatError("writing to an offset that is not empty");
1332
1339
  }
1340
+
1341
+ var value = values[i];
1342
+ data[offset0] = 0x1d;
1343
+ data[offset1] = value >> 24 & 0xff;
1344
+ data[offset2] = value >> 16 & 0xff;
1345
+ data[offset3] = value >> 8 & 0xff;
1346
+ data[offset4] = value & 0xff;
1333
1347
  }
1334
- };
1335
- return CFFOffsetTracker;
1336
- }();
1348
+ }
1337
1349
 
1338
- var CFFCompiler = function CFFCompilerClosure() {
1339
- function CFFCompiler(cff) {
1350
+ }
1351
+
1352
+ class CFFCompiler {
1353
+ constructor(cff) {
1340
1354
  this.cff = cff;
1341
1355
  }
1342
1356
 
1343
- CFFCompiler.prototype = {
1344
- compile: function CFFCompiler_compile() {
1345
- var cff = this.cff;
1346
- var output = {
1347
- data: [],
1348
- length: 0,
1349
- add: function CFFCompiler_add(data) {
1350
- this.data = this.data.concat(data);
1351
- this.length = this.data.length;
1357
+ compile() {
1358
+ var cff = this.cff;
1359
+ var output = {
1360
+ data: [],
1361
+ length: 0,
1362
+ add: function CFFCompiler_add(data) {
1363
+ this.data = this.data.concat(data);
1364
+ this.length = this.data.length;
1365
+ }
1366
+ };
1367
+ var header = this.compileHeader(cff.header);
1368
+ output.add(header);
1369
+ var nameIndex = this.compileNameIndex(cff.names);
1370
+ output.add(nameIndex);
1371
+
1372
+ if (cff.isCIDFont) {
1373
+ if (cff.topDict.hasName("FontMatrix")) {
1374
+ var base = cff.topDict.getByName("FontMatrix");
1375
+ cff.topDict.removeByName("FontMatrix");
1376
+
1377
+ for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
1378
+ var subDict = cff.fdArray[i];
1379
+ var matrix = base.slice(0);
1380
+
1381
+ if (subDict.hasName("FontMatrix")) {
1382
+ matrix = _util.Util.transform(matrix, subDict.getByName("FontMatrix"));
1383
+ }
1384
+
1385
+ subDict.setByName("FontMatrix", matrix);
1352
1386
  }
1353
- };
1354
- var header = this.compileHeader(cff.header);
1355
- output.add(header);
1356
- var nameIndex = this.compileNameIndex(cff.names);
1357
- output.add(nameIndex);
1387
+ }
1388
+ }
1358
1389
 
1359
- if (cff.isCIDFont) {
1360
- if (cff.topDict.hasName('FontMatrix')) {
1361
- var base = cff.topDict.getByName('FontMatrix');
1362
- cff.topDict.removeByName('FontMatrix');
1390
+ cff.topDict.setByName("charset", 0);
1391
+ var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
1392
+ output.add(compiled.output);
1393
+ var topDictTracker = compiled.trackers[0];
1394
+ var stringIndex = this.compileStringIndex(cff.strings.strings);
1395
+ output.add(stringIndex);
1396
+ var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
1397
+ output.add(globalSubrIndex);
1398
+
1399
+ if (cff.encoding && cff.topDict.hasName("Encoding")) {
1400
+ if (cff.encoding.predefined) {
1401
+ topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
1402
+ } else {
1403
+ var encoding = this.compileEncoding(cff.encoding);
1404
+ topDictTracker.setEntryLocation("Encoding", [output.length], output);
1405
+ output.add(encoding);
1406
+ }
1407
+ }
1363
1408
 
1364
- for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
1365
- var subDict = cff.fdArray[i];
1366
- var matrix = base.slice(0);
1409
+ var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
1410
+ topDictTracker.setEntryLocation("charset", [output.length], output);
1411
+ output.add(charset);
1412
+ var charStrings = this.compileCharStrings(cff.charStrings);
1413
+ topDictTracker.setEntryLocation("CharStrings", [output.length], output);
1414
+ output.add(charStrings);
1415
+
1416
+ if (cff.isCIDFont) {
1417
+ topDictTracker.setEntryLocation("FDSelect", [output.length], output);
1418
+ var fdSelect = this.compileFDSelect(cff.fdSelect);
1419
+ output.add(fdSelect);
1420
+ compiled = this.compileTopDicts(cff.fdArray, output.length, true);
1421
+ topDictTracker.setEntryLocation("FDArray", [output.length], output);
1422
+ output.add(compiled.output);
1423
+ var fontDictTrackers = compiled.trackers;
1424
+ this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
1425
+ }
1367
1426
 
1368
- if (subDict.hasName('FontMatrix')) {
1369
- matrix = _util.Util.transform(matrix, subDict.getByName('FontMatrix'));
1370
- }
1427
+ this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
1428
+ output.add([0]);
1429
+ return output.data;
1430
+ }
1371
1431
 
1372
- subDict.setByName('FontMatrix', matrix);
1373
- }
1374
- }
1375
- }
1432
+ encodeNumber(value) {
1433
+ if (Number.isInteger(value)) {
1434
+ return this.encodeInteger(value);
1435
+ }
1376
1436
 
1377
- cff.topDict.setByName('charset', 0);
1378
- var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
1379
- output.add(compiled.output);
1380
- var topDictTracker = compiled.trackers[0];
1381
- var stringIndex = this.compileStringIndex(cff.strings.strings);
1382
- output.add(stringIndex);
1383
- var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
1384
- output.add(globalSubrIndex);
1385
-
1386
- if (cff.encoding && cff.topDict.hasName('Encoding')) {
1387
- if (cff.encoding.predefined) {
1388
- topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
1389
- } else {
1390
- var encoding = this.compileEncoding(cff.encoding);
1391
- topDictTracker.setEntryLocation('Encoding', [output.length], output);
1392
- output.add(encoding);
1393
- }
1394
- }
1437
+ return this.encodeFloat(value);
1438
+ }
1395
1439
 
1396
- var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
1397
- topDictTracker.setEntryLocation('charset', [output.length], output);
1398
- output.add(charset);
1399
- var charStrings = this.compileCharStrings(cff.charStrings);
1400
- topDictTracker.setEntryLocation('CharStrings', [output.length], output);
1401
- output.add(charStrings);
1440
+ static get EncodeFloatRegExp() {
1441
+ return (0, _util.shadow)(this, "EncodeFloatRegExp", /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/);
1442
+ }
1402
1443
 
1403
- if (cff.isCIDFont) {
1404
- topDictTracker.setEntryLocation('FDSelect', [output.length], output);
1405
- var fdSelect = this.compileFDSelect(cff.fdSelect);
1406
- output.add(fdSelect);
1407
- compiled = this.compileTopDicts(cff.fdArray, output.length, true);
1408
- topDictTracker.setEntryLocation('FDArray', [output.length], output);
1409
- output.add(compiled.output);
1410
- var fontDictTrackers = compiled.trackers;
1411
- this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
1412
- }
1444
+ encodeFloat(num) {
1445
+ var value = num.toString();
1446
+ var m = CFFCompiler.EncodeFloatRegExp.exec(value);
1413
1447
 
1414
- this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
1415
- output.add([0]);
1416
- return output.data;
1417
- },
1418
- encodeNumber: function CFFCompiler_encodeNumber(value) {
1419
- if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
1420
- return this.encodeInteger(value);
1421
- }
1448
+ if (m) {
1449
+ var epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
1450
+ value = (Math.round(num * epsilon) / epsilon).toString();
1451
+ }
1422
1452
 
1423
- return this.encodeFloat(value);
1424
- },
1425
- encodeFloat: function CFFCompiler_encodeFloat(num) {
1426
- var value = num.toString();
1427
- var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
1453
+ var nibbles = "";
1454
+ var i, ii;
1428
1455
 
1429
- if (m) {
1430
- var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
1431
- value = (Math.round(num * epsilon) / epsilon).toString();
1456
+ for (i = 0, ii = value.length; i < ii; ++i) {
1457
+ var a = value[i];
1458
+
1459
+ if (a === "e") {
1460
+ nibbles += value[++i] === "-" ? "c" : "b";
1461
+ } else if (a === ".") {
1462
+ nibbles += "a";
1463
+ } else if (a === "-") {
1464
+ nibbles += "e";
1465
+ } else {
1466
+ nibbles += a;
1432
1467
  }
1468
+ }
1433
1469
 
1434
- var nibbles = '';
1435
- var i, ii;
1470
+ nibbles += nibbles.length & 1 ? "f" : "ff";
1471
+ var out = [30];
1436
1472
 
1437
- for (i = 0, ii = value.length; i < ii; ++i) {
1438
- var a = value[i];
1473
+ for (i = 0, ii = nibbles.length; i < ii; i += 2) {
1474
+ out.push(parseInt(nibbles.substring(i, i + 2), 16));
1475
+ }
1439
1476
 
1440
- if (a === 'e') {
1441
- nibbles += value[++i] === '-' ? 'c' : 'b';
1442
- } else if (a === '.') {
1443
- nibbles += 'a';
1444
- } else if (a === '-') {
1445
- nibbles += 'e';
1446
- } else {
1447
- nibbles += a;
1477
+ return out;
1478
+ }
1479
+
1480
+ encodeInteger(value) {
1481
+ var code;
1482
+
1483
+ if (value >= -107 && value <= 107) {
1484
+ code = [value + 139];
1485
+ } else if (value >= 108 && value <= 1131) {
1486
+ value = value - 108;
1487
+ code = [(value >> 8) + 247, value & 0xff];
1488
+ } else if (value >= -1131 && value <= -108) {
1489
+ value = -value - 108;
1490
+ code = [(value >> 8) + 251, value & 0xff];
1491
+ } else if (value >= -32768 && value <= 32767) {
1492
+ code = [0x1c, value >> 8 & 0xff, value & 0xff];
1493
+ } else {
1494
+ code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
1495
+ }
1496
+
1497
+ return code;
1498
+ }
1499
+
1500
+ compileHeader(header) {
1501
+ return [header.major, header.minor, header.hdrSize, header.offSize];
1502
+ }
1503
+
1504
+ compileNameIndex(names) {
1505
+ var nameIndex = new CFFIndex();
1506
+
1507
+ for (var i = 0, ii = names.length; i < ii; ++i) {
1508
+ var name = names[i];
1509
+ var length = Math.min(name.length, 127);
1510
+ var sanitizedName = new Array(length);
1511
+
1512
+ for (var j = 0; j < length; j++) {
1513
+ var char = name[j];
1514
+
1515
+ if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
1516
+ char = "_";
1448
1517
  }
1518
+
1519
+ sanitizedName[j] = char;
1449
1520
  }
1450
1521
 
1451
- nibbles += nibbles.length & 1 ? 'f' : 'ff';
1452
- var out = [30];
1522
+ sanitizedName = sanitizedName.join("");
1453
1523
 
1454
- for (i = 0, ii = nibbles.length; i < ii; i += 2) {
1455
- out.push(parseInt(nibbles.substring(i, i + 2), 16));
1524
+ if (sanitizedName === "") {
1525
+ sanitizedName = "Bad_Font_Name";
1456
1526
  }
1457
1527
 
1458
- return out;
1459
- },
1460
- encodeInteger: function CFFCompiler_encodeInteger(value) {
1461
- var code;
1462
-
1463
- if (value >= -107 && value <= 107) {
1464
- code = [value + 139];
1465
- } else if (value >= 108 && value <= 1131) {
1466
- value = value - 108;
1467
- code = [(value >> 8) + 247, value & 0xFF];
1468
- } else if (value >= -1131 && value <= -108) {
1469
- value = -value - 108;
1470
- code = [(value >> 8) + 251, value & 0xFF];
1471
- } else if (value >= -32768 && value <= 32767) {
1472
- code = [0x1c, value >> 8 & 0xFF, value & 0xFF];
1473
- } else {
1474
- code = [0x1d, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF];
1475
- }
1528
+ nameIndex.add((0, _util.stringToBytes)(sanitizedName));
1529
+ }
1476
1530
 
1477
- return code;
1478
- },
1479
- compileHeader: function CFFCompiler_compileHeader(header) {
1480
- return [header.major, header.minor, header.hdrSize, header.offSize];
1481
- },
1482
- compileNameIndex: function CFFCompiler_compileNameIndex(names) {
1483
- var nameIndex = new CFFIndex();
1531
+ return this.compileIndex(nameIndex);
1532
+ }
1484
1533
 
1485
- for (var i = 0, ii = names.length; i < ii; ++i) {
1486
- var name = names[i];
1487
- var length = Math.min(name.length, 127);
1488
- var sanitizedName = new Array(length);
1534
+ compileTopDicts(dicts, length, removeCidKeys) {
1535
+ var fontDictTrackers = [];
1536
+ var fdArrayIndex = new CFFIndex();
1489
1537
 
1490
- for (var j = 0; j < length; j++) {
1491
- var _char = name[j];
1538
+ for (var i = 0, ii = dicts.length; i < ii; ++i) {
1539
+ var fontDict = dicts[i];
1492
1540
 
1493
- if (_char < '!' || _char > '~' || _char === '[' || _char === ']' || _char === '(' || _char === ')' || _char === '{' || _char === '}' || _char === '<' || _char === '>' || _char === '/' || _char === '%') {
1494
- _char = '_';
1495
- }
1541
+ if (removeCidKeys) {
1542
+ fontDict.removeByName("CIDFontVersion");
1543
+ fontDict.removeByName("CIDFontRevision");
1544
+ fontDict.removeByName("CIDFontType");
1545
+ fontDict.removeByName("CIDCount");
1546
+ fontDict.removeByName("UIDBase");
1547
+ }
1496
1548
 
1497
- sanitizedName[j] = _char;
1498
- }
1549
+ var fontDictTracker = new CFFOffsetTracker();
1550
+ var fontDictData = this.compileDict(fontDict, fontDictTracker);
1551
+ fontDictTrackers.push(fontDictTracker);
1552
+ fdArrayIndex.add(fontDictData);
1553
+ fontDictTracker.offset(length);
1554
+ }
1499
1555
 
1500
- sanitizedName = sanitizedName.join('');
1556
+ fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
1557
+ return {
1558
+ trackers: fontDictTrackers,
1559
+ output: fdArrayIndex
1560
+ };
1561
+ }
1501
1562
 
1502
- if (sanitizedName === '') {
1503
- sanitizedName = 'Bad_Font_Name';
1504
- }
1563
+ compilePrivateDicts(dicts, trackers, output) {
1564
+ for (var i = 0, ii = dicts.length; i < ii; ++i) {
1565
+ var fontDict = dicts[i];
1566
+ var privateDict = fontDict.privateDict;
1505
1567
 
1506
- nameIndex.add((0, _util.stringToBytes)(sanitizedName));
1568
+ if (!privateDict || !fontDict.hasName("Private")) {
1569
+ throw new _util.FormatError("There must be a private dictionary.");
1507
1570
  }
1508
1571
 
1509
- return this.compileIndex(nameIndex);
1510
- },
1511
- compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
1512
- var fontDictTrackers = [];
1513
- var fdArrayIndex = new CFFIndex();
1514
-
1515
- for (var i = 0, ii = dicts.length; i < ii; ++i) {
1516
- var fontDict = dicts[i];
1517
-
1518
- if (removeCidKeys) {
1519
- fontDict.removeByName('CIDFontVersion');
1520
- fontDict.removeByName('CIDFontRevision');
1521
- fontDict.removeByName('CIDFontType');
1522
- fontDict.removeByName('CIDCount');
1523
- fontDict.removeByName('UIDBase');
1524
- }
1572
+ var privateDictTracker = new CFFOffsetTracker();
1573
+ var privateDictData = this.compileDict(privateDict, privateDictTracker);
1574
+ var outputLength = output.length;
1575
+ privateDictTracker.offset(outputLength);
1525
1576
 
1526
- var fontDictTracker = new CFFOffsetTracker();
1527
- var fontDictData = this.compileDict(fontDict, fontDictTracker);
1528
- fontDictTrackers.push(fontDictTracker);
1529
- fdArrayIndex.add(fontDictData);
1530
- fontDictTracker.offset(length);
1577
+ if (!privateDictData.length) {
1578
+ outputLength = 0;
1531
1579
  }
1532
1580
 
1533
- fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
1534
- return {
1535
- trackers: fontDictTrackers,
1536
- output: fdArrayIndex
1537
- };
1538
- },
1539
- compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
1540
- for (var i = 0, ii = dicts.length; i < ii; ++i) {
1541
- var fontDict = dicts[i];
1542
- var privateDict = fontDict.privateDict;
1543
-
1544
- if (!privateDict || !fontDict.hasName('Private')) {
1545
- throw new _util.FormatError('There must be a private dictionary.');
1546
- }
1581
+ trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
1582
+ output.add(privateDictData);
1547
1583
 
1548
- var privateDictTracker = new CFFOffsetTracker();
1549
- var privateDictData = this.compileDict(privateDict, privateDictTracker);
1550
- var outputLength = output.length;
1551
- privateDictTracker.offset(outputLength);
1584
+ if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
1585
+ var subrs = this.compileIndex(privateDict.subrsIndex);
1586
+ privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
1587
+ output.add(subrs);
1588
+ }
1589
+ }
1590
+ }
1552
1591
 
1553
- if (!privateDictData.length) {
1554
- outputLength = 0;
1555
- }
1592
+ compileDict(dict, offsetTracker) {
1593
+ var out = [];
1594
+ var order = dict.order;
1556
1595
 
1557
- trackers[i].setEntryLocation('Private', [privateDictData.length, outputLength], output);
1558
- output.add(privateDictData);
1596
+ for (var i = 0; i < order.length; ++i) {
1597
+ var key = order[i];
1559
1598
 
1560
- if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
1561
- var subrs = this.compileIndex(privateDict.subrsIndex);
1562
- privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
1563
- output.add(subrs);
1564
- }
1599
+ if (!(key in dict.values)) {
1600
+ continue;
1565
1601
  }
1566
- },
1567
- compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
1568
- var out = [];
1569
- var order = dict.order;
1570
1602
 
1571
- for (var i = 0; i < order.length; ++i) {
1572
- var key = order[i];
1603
+ var values = dict.values[key];
1604
+ var types = dict.types[key];
1573
1605
 
1574
- if (!(key in dict.values)) {
1575
- continue;
1576
- }
1606
+ if (!Array.isArray(types)) {
1607
+ types = [types];
1608
+ }
1577
1609
 
1578
- var values = dict.values[key];
1579
- var types = dict.types[key];
1610
+ if (!Array.isArray(values)) {
1611
+ values = [values];
1612
+ }
1580
1613
 
1581
- if (!Array.isArray(types)) {
1582
- types = [types];
1583
- }
1614
+ if (values.length === 0) {
1615
+ continue;
1616
+ }
1584
1617
 
1585
- if (!Array.isArray(values)) {
1586
- values = [values];
1587
- }
1618
+ for (var j = 0, jj = types.length; j < jj; ++j) {
1619
+ var type = types[j];
1620
+ var value = values[j];
1588
1621
 
1589
- if (values.length === 0) {
1590
- continue;
1591
- }
1622
+ switch (type) {
1623
+ case "num":
1624
+ case "sid":
1625
+ out = out.concat(this.encodeNumber(value));
1626
+ break;
1592
1627
 
1593
- for (var j = 0, jj = types.length; j < jj; ++j) {
1594
- var type = types[j];
1595
- var value = values[j];
1628
+ case "offset":
1629
+ var name = dict.keyToNameMap[key];
1596
1630
 
1597
- switch (type) {
1598
- case 'num':
1599
- case 'sid':
1600
- out = out.concat(this.encodeNumber(value));
1601
- break;
1631
+ if (!offsetTracker.isTracking(name)) {
1632
+ offsetTracker.track(name, out.length);
1633
+ }
1602
1634
 
1603
- case 'offset':
1604
- var name = dict.keyToNameMap[key];
1635
+ out = out.concat([0x1d, 0, 0, 0, 0]);
1636
+ break;
1605
1637
 
1606
- if (!offsetTracker.isTracking(name)) {
1607
- offsetTracker.track(name, out.length);
1608
- }
1638
+ case "array":
1639
+ case "delta":
1640
+ out = out.concat(this.encodeNumber(value));
1609
1641
 
1610
- out = out.concat([0x1d, 0, 0, 0, 0]);
1611
- break;
1642
+ for (var k = 1, kk = values.length; k < kk; ++k) {
1643
+ out = out.concat(this.encodeNumber(values[k]));
1644
+ }
1612
1645
 
1613
- case 'array':
1614
- case 'delta':
1615
- out = out.concat(this.encodeNumber(value));
1646
+ break;
1616
1647
 
1617
- for (var k = 1, kk = values.length; k < kk; ++k) {
1618
- out = out.concat(this.encodeNumber(values[k]));
1619
- }
1648
+ default:
1649
+ throw new _util.FormatError(`Unknown data type of ${type}`);
1650
+ }
1651
+ }
1620
1652
 
1621
- break;
1653
+ out = out.concat(dict.opcodes[key]);
1654
+ }
1622
1655
 
1623
- default:
1624
- throw new _util.FormatError("Unknown data type of ".concat(type));
1625
- }
1626
- }
1656
+ return out;
1657
+ }
1627
1658
 
1628
- out = out.concat(dict.opcodes[key]);
1629
- }
1659
+ compileStringIndex(strings) {
1660
+ var stringIndex = new CFFIndex();
1630
1661
 
1631
- return out;
1632
- },
1633
- compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
1634
- var stringIndex = new CFFIndex();
1662
+ for (var i = 0, ii = strings.length; i < ii; ++i) {
1663
+ stringIndex.add((0, _util.stringToBytes)(strings[i]));
1664
+ }
1635
1665
 
1636
- for (var i = 0, ii = strings.length; i < ii; ++i) {
1637
- stringIndex.add((0, _util.stringToBytes)(strings[i]));
1638
- }
1666
+ return this.compileIndex(stringIndex);
1667
+ }
1639
1668
 
1640
- return this.compileIndex(stringIndex);
1641
- },
1642
- compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
1643
- var globalSubrIndex = this.cff.globalSubrIndex;
1644
- this.out.writeByteArray(this.compileIndex(globalSubrIndex));
1645
- },
1646
- compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
1647
- var charStringsIndex = new CFFIndex();
1669
+ compileGlobalSubrIndex() {
1670
+ var globalSubrIndex = this.cff.globalSubrIndex;
1671
+ this.out.writeByteArray(this.compileIndex(globalSubrIndex));
1672
+ }
1648
1673
 
1649
- for (var i = 0; i < charStrings.count; i++) {
1650
- var glyph = charStrings.get(i);
1674
+ compileCharStrings(charStrings) {
1675
+ var charStringsIndex = new CFFIndex();
1651
1676
 
1652
- if (glyph.length === 0) {
1653
- charStringsIndex.add(new Uint8Array([0x8B, 0x0E]));
1654
- continue;
1655
- }
1677
+ for (var i = 0; i < charStrings.count; i++) {
1678
+ var glyph = charStrings.get(i);
1656
1679
 
1657
- charStringsIndex.add(glyph);
1680
+ if (glyph.length === 0) {
1681
+ charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
1682
+ continue;
1658
1683
  }
1659
1684
 
1660
- return this.compileIndex(charStringsIndex);
1661
- },
1662
- compileCharset: function CFFCompiler_compileCharset(charset, numGlyphs, strings, isCIDFont) {
1663
- var out;
1664
- var numGlyphsLessNotDef = numGlyphs - 1;
1685
+ charStringsIndex.add(glyph);
1686
+ }
1665
1687
 
1666
- if (isCIDFont) {
1667
- out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xFF, numGlyphsLessNotDef & 0xFF]);
1668
- } else {
1669
- var length = 1 + numGlyphsLessNotDef * 2;
1670
- out = new Uint8Array(length);
1671
- out[0] = 0;
1672
- var charsetIndex = 0;
1673
- var numCharsets = charset.charset.length;
1674
- var warned = false;
1675
-
1676
- for (var i = 1; i < out.length; i += 2) {
1677
- var sid = 0;
1678
-
1679
- if (charsetIndex < numCharsets) {
1680
- var name = charset.charset[charsetIndex++];
1681
- sid = strings.getSID(name);
1682
-
1683
- if (sid === -1) {
1684
- sid = 0;
1685
-
1686
- if (!warned) {
1687
- warned = true;
1688
- (0, _util.warn)("Couldn't find ".concat(name, " in CFF strings"));
1689
- }
1688
+ return this.compileIndex(charStringsIndex);
1689
+ }
1690
+
1691
+ compileCharset(charset, numGlyphs, strings, isCIDFont) {
1692
+ let out;
1693
+ const numGlyphsLessNotDef = numGlyphs - 1;
1694
+
1695
+ if (isCIDFont) {
1696
+ out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xff, numGlyphsLessNotDef & 0xff]);
1697
+ } else {
1698
+ const length = 1 + numGlyphsLessNotDef * 2;
1699
+ out = new Uint8Array(length);
1700
+ out[0] = 0;
1701
+ let charsetIndex = 0;
1702
+ const numCharsets = charset.charset.length;
1703
+ let warned = false;
1704
+
1705
+ for (let i = 1; i < out.length; i += 2) {
1706
+ let sid = 0;
1707
+
1708
+ if (charsetIndex < numCharsets) {
1709
+ const name = charset.charset[charsetIndex++];
1710
+ sid = strings.getSID(name);
1711
+
1712
+ if (sid === -1) {
1713
+ sid = 0;
1714
+
1715
+ if (!warned) {
1716
+ warned = true;
1717
+ (0, _util.warn)(`Couldn't find ${name} in CFF strings`);
1690
1718
  }
1691
1719
  }
1692
-
1693
- out[i] = sid >> 8 & 0xFF;
1694
- out[i + 1] = sid & 0xFF;
1695
1720
  }
1721
+
1722
+ out[i] = sid >> 8 & 0xff;
1723
+ out[i + 1] = sid & 0xff;
1696
1724
  }
1725
+ }
1697
1726
 
1698
- return this.compileTypedArray(out);
1699
- },
1700
- compileEncoding: function CFFCompiler_compileEncoding(encoding) {
1701
- return this.compileTypedArray(encoding.raw);
1702
- },
1703
- compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
1704
- var format = fdSelect.format;
1705
- var out, i;
1727
+ return this.compileTypedArray(out);
1728
+ }
1706
1729
 
1707
- switch (format) {
1708
- case 0:
1709
- out = new Uint8Array(1 + fdSelect.fdSelect.length);
1710
- out[0] = format;
1730
+ compileEncoding(encoding) {
1731
+ return this.compileTypedArray(encoding.raw);
1732
+ }
1711
1733
 
1712
- for (i = 0; i < fdSelect.fdSelect.length; i++) {
1713
- out[i + 1] = fdSelect.fdSelect[i];
1714
- }
1734
+ compileFDSelect(fdSelect) {
1735
+ const format = fdSelect.format;
1736
+ let out, i;
1715
1737
 
1716
- break;
1738
+ switch (format) {
1739
+ case 0:
1740
+ out = new Uint8Array(1 + fdSelect.fdSelect.length);
1741
+ out[0] = format;
1717
1742
 
1718
- case 3:
1719
- var start = 0;
1720
- var lastFD = fdSelect.fdSelect[0];
1721
- var ranges = [format, 0, 0, start >> 8 & 0xFF, start & 0xFF, lastFD];
1743
+ for (i = 0; i < fdSelect.fdSelect.length; i++) {
1744
+ out[i + 1] = fdSelect.fdSelect[i];
1745
+ }
1722
1746
 
1723
- for (i = 1; i < fdSelect.fdSelect.length; i++) {
1724
- var currentFD = fdSelect.fdSelect[i];
1747
+ break;
1725
1748
 
1726
- if (currentFD !== lastFD) {
1727
- ranges.push(i >> 8 & 0xFF, i & 0xFF, currentFD);
1728
- lastFD = currentFD;
1729
- }
1749
+ case 3:
1750
+ const start = 0;
1751
+ let lastFD = fdSelect.fdSelect[0];
1752
+ const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
1753
+
1754
+ for (i = 1; i < fdSelect.fdSelect.length; i++) {
1755
+ const currentFD = fdSelect.fdSelect[i];
1756
+
1757
+ if (currentFD !== lastFD) {
1758
+ ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
1759
+ lastFD = currentFD;
1730
1760
  }
1761
+ }
1731
1762
 
1732
- var numRanges = (ranges.length - 3) / 3;
1733
- ranges[1] = numRanges >> 8 & 0xFF;
1734
- ranges[2] = numRanges & 0xFF;
1735
- ranges.push(i >> 8 & 0xFF, i & 0xFF);
1736
- out = new Uint8Array(ranges);
1737
- break;
1738
- }
1763
+ const numRanges = (ranges.length - 3) / 3;
1764
+ ranges[1] = numRanges >> 8 & 0xff;
1765
+ ranges[2] = numRanges & 0xff;
1766
+ ranges.push(i >> 8 & 0xff, i & 0xff);
1767
+ out = new Uint8Array(ranges);
1768
+ break;
1769
+ }
1739
1770
 
1740
- return this.compileTypedArray(out);
1741
- },
1742
- compileTypedArray: function CFFCompiler_compileTypedArray(data) {
1743
- var out = [];
1771
+ return this.compileTypedArray(out);
1772
+ }
1744
1773
 
1745
- for (var i = 0, ii = data.length; i < ii; ++i) {
1746
- out[i] = data[i];
1747
- }
1774
+ compileTypedArray(data) {
1775
+ var out = [];
1748
1776
 
1749
- return out;
1750
- },
1751
- compileIndex: function CFFCompiler_compileIndex(index, trackers) {
1752
- trackers = trackers || [];
1753
- var objects = index.objects;
1754
- var count = objects.length;
1777
+ for (var i = 0, ii = data.length; i < ii; ++i) {
1778
+ out[i] = data[i];
1779
+ }
1755
1780
 
1756
- if (count === 0) {
1757
- return [0, 0, 0];
1758
- }
1781
+ return out;
1782
+ }
1759
1783
 
1760
- var data = [count >> 8 & 0xFF, count & 0xff];
1761
- var lastOffset = 1,
1762
- i;
1784
+ compileIndex(index, trackers = []) {
1785
+ var objects = index.objects;
1786
+ var count = objects.length;
1763
1787
 
1764
- for (i = 0; i < count; ++i) {
1765
- lastOffset += objects[i].length;
1766
- }
1788
+ if (count === 0) {
1789
+ return [0, 0, 0];
1790
+ }
1767
1791
 
1768
- var offsetSize;
1792
+ var data = [count >> 8 & 0xff, count & 0xff];
1793
+ var lastOffset = 1,
1794
+ i;
1769
1795
 
1770
- if (lastOffset < 0x100) {
1771
- offsetSize = 1;
1772
- } else if (lastOffset < 0x10000) {
1773
- offsetSize = 2;
1774
- } else if (lastOffset < 0x1000000) {
1775
- offsetSize = 3;
1776
- } else {
1777
- offsetSize = 4;
1778
- }
1796
+ for (i = 0; i < count; ++i) {
1797
+ lastOffset += objects[i].length;
1798
+ }
1779
1799
 
1780
- data.push(offsetSize);
1781
- var relativeOffset = 1;
1800
+ var offsetSize;
1782
1801
 
1783
- for (i = 0; i < count + 1; i++) {
1784
- if (offsetSize === 1) {
1785
- data.push(relativeOffset & 0xFF);
1786
- } else if (offsetSize === 2) {
1787
- data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
1788
- } else if (offsetSize === 3) {
1789
- data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
1790
- } else {
1791
- data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
1792
- }
1802
+ if (lastOffset < 0x100) {
1803
+ offsetSize = 1;
1804
+ } else if (lastOffset < 0x10000) {
1805
+ offsetSize = 2;
1806
+ } else if (lastOffset < 0x1000000) {
1807
+ offsetSize = 3;
1808
+ } else {
1809
+ offsetSize = 4;
1810
+ }
1793
1811
 
1794
- if (objects[i]) {
1795
- relativeOffset += objects[i].length;
1796
- }
1812
+ data.push(offsetSize);
1813
+ var relativeOffset = 1;
1814
+
1815
+ for (i = 0; i < count + 1; i++) {
1816
+ if (offsetSize === 1) {
1817
+ data.push(relativeOffset & 0xff);
1818
+ } else if (offsetSize === 2) {
1819
+ data.push(relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
1820
+ } else if (offsetSize === 3) {
1821
+ data.push(relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
1822
+ } else {
1823
+ data.push(relativeOffset >>> 24 & 0xff, relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
1797
1824
  }
1798
1825
 
1799
- for (i = 0; i < count; i++) {
1800
- if (trackers[i]) {
1801
- trackers[i].offset(data.length);
1802
- }
1826
+ if (objects[i]) {
1827
+ relativeOffset += objects[i].length;
1828
+ }
1829
+ }
1803
1830
 
1804
- for (var j = 0, jj = objects[i].length; j < jj; j++) {
1805
- data.push(objects[i][j]);
1806
- }
1831
+ for (i = 0; i < count; i++) {
1832
+ if (trackers[i]) {
1833
+ trackers[i].offset(data.length);
1807
1834
  }
1808
1835
 
1809
- return data;
1836
+ for (var j = 0, jj = objects[i].length; j < jj; j++) {
1837
+ data.push(objects[i][j]);
1838
+ }
1810
1839
  }
1811
- };
1812
- return CFFCompiler;
1813
- }();
1840
+
1841
+ return data;
1842
+ }
1843
+
1844
+ }
1814
1845
 
1815
1846
  exports.CFFCompiler = CFFCompiler;