pdfjs-dist 2.0.943 → 2.4.456

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 (192) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8286 -14230
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +25500 -26628
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25473 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +57878 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +407 -0
  29. package/es5/web/pdf_viewer.js +7757 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +2887 -4094
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +855 -778
  36. package/lib/core/arithmetic_decoder.js +325 -311
  37. package/lib/core/bidi.js +117 -50
  38. package/lib/core/ccitt.js +251 -89
  39. package/lib/core/ccitt_stream.js +26 -16
  40. package/lib/core/cff_parser.js +525 -197
  41. package/lib/core/charsets.js +6 -5
  42. package/lib/core/chunked_stream.js +541 -406
  43. package/lib/core/cmap.js +368 -253
  44. package/lib/core/colorspace.js +781 -800
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +609 -422
  47. package/lib/core/document.js +649 -481
  48. package/lib/core/encodings.js +33 -24
  49. package/lib/core/evaluator.js +1471 -736
  50. package/lib/core/font_renderer.js +289 -149
  51. package/lib/core/fonts.js +1067 -413
  52. package/lib/core/function.js +517 -287
  53. package/lib/core/glyphlist.js +4529 -4527
  54. package/lib/core/image.js +232 -114
  55. package/lib/core/image_utils.js +94 -0
  56. package/lib/core/jbig2.js +711 -342
  57. package/lib/core/jbig2_stream.js +31 -19
  58. package/lib/core/jpeg_stream.js +151 -26
  59. package/lib/core/jpg.js +433 -181
  60. package/lib/core/jpx.js +551 -143
  61. package/lib/core/jpx_stream.js +40 -28
  62. package/lib/core/metrics.js +2931 -2931
  63. package/lib/core/murmurhash3.js +104 -97
  64. package/lib/core/obj.js +1561 -1053
  65. package/lib/core/operator_list.js +192 -64
  66. package/lib/core/parser.js +1162 -864
  67. package/lib/core/pattern.js +224 -75
  68. package/lib/core/pdf_manager.js +154 -285
  69. package/lib/core/primitives.js +145 -69
  70. package/lib/core/ps_parser.js +212 -162
  71. package/lib/core/standard_fonts.js +245 -244
  72. package/lib/core/stream.js +353 -81
  73. package/lib/core/type1_parser.js +218 -68
  74. package/lib/core/unicode.js +1682 -1655
  75. package/lib/core/worker.js +233 -302
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +808 -862
  78. package/lib/display/api.js +1778 -1462
  79. package/lib/display/api_compatibility.js +14 -9
  80. package/lib/display/canvas.js +463 -140
  81. package/lib/display/content_disposition.js +86 -58
  82. package/lib/display/display_utils.js +524 -0
  83. package/lib/display/fetch_stream.js +202 -274
  84. package/lib/display/font_loader.js +311 -333
  85. package/lib/display/metadata.js +98 -88
  86. package/lib/display/network.js +343 -347
  87. package/lib/display/network_utils.js +46 -26
  88. package/lib/display/node_stream.js +326 -404
  89. package/lib/display/pattern_helper.js +168 -69
  90. package/lib/display/svg.js +1296 -885
  91. package/lib/display/text_layer.js +229 -103
  92. package/lib/display/transport_stream.js +290 -250
  93. package/lib/display/webgl.js +116 -83
  94. package/lib/display/worker_options.js +6 -5
  95. package/lib/display/xml_parser.js +358 -337
  96. package/lib/examples/node/domstubs.js +95 -39
  97. package/lib/pdf.js +49 -31
  98. package/lib/pdf.worker.js +7 -5
  99. package/lib/shared/compatibility.js +3 -145
  100. package/lib/shared/is_node.js +8 -7
  101. package/lib/shared/message_handler.js +367 -314
  102. package/lib/shared/util.js +421 -415
  103. package/lib/test/unit/annotation_spec.js +1570 -690
  104. package/lib/test/unit/api_spec.js +855 -493
  105. package/lib/test/unit/bidi_spec.js +12 -12
  106. package/lib/test/unit/cff_parser_spec.js +88 -61
  107. package/lib/test/unit/clitests_helper.js +9 -12
  108. package/lib/test/unit/cmap_spec.js +140 -88
  109. package/lib/test/unit/colorspace_spec.js +204 -152
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +194 -182
  112. package/lib/test/unit/custom_spec.js +50 -64
  113. package/lib/test/unit/display_svg_spec.js +53 -38
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +17 -22
  116. package/lib/test/unit/encodings_spec.js +15 -57
  117. package/lib/test/unit/evaluator_spec.js +90 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +219 -205
  120. package/lib/test/unit/jasmine-boot.js +68 -39
  121. package/lib/test/unit/message_handler_spec.js +187 -160
  122. package/lib/test/unit/metadata_spec.js +87 -34
  123. package/lib/test/unit/murmurhash3_spec.js +13 -13
  124. package/lib/test/unit/network_spec.js +26 -59
  125. package/lib/test/unit/network_utils_spec.js +187 -121
  126. package/lib/test/unit/node_stream_spec.js +98 -90
  127. package/lib/test/unit/parser_spec.js +173 -131
  128. package/lib/test/unit/pdf_find_controller_spec.js +148 -67
  129. package/lib/test/unit/pdf_find_utils_spec.js +35 -34
  130. package/lib/test/unit/pdf_history_spec.js +45 -33
  131. package/lib/test/unit/primitives_spec.js +161 -126
  132. package/lib/test/unit/stream_spec.js +22 -15
  133. package/lib/test/unit/test_utils.js +149 -98
  134. package/lib/test/unit/testreporter.js +36 -18
  135. package/lib/test/unit/type1_parser_spec.js +46 -44
  136. package/lib/test/unit/ui_utils_spec.js +388 -372
  137. package/lib/test/unit/unicode_spec.js +49 -46
  138. package/lib/test/unit/util_spec.js +144 -248
  139. package/lib/web/annotation_layer_builder.js +75 -95
  140. package/lib/web/app.js +1538 -1147
  141. package/lib/web/app_options.js +116 -104
  142. package/lib/web/base_viewer.js +950 -775
  143. package/lib/web/chromecom.js +217 -225
  144. package/lib/web/debugger.js +236 -148
  145. package/lib/web/download_manager.js +50 -50
  146. package/lib/web/firefox_print_service.js +51 -33
  147. package/lib/web/firefoxcom.js +225 -352
  148. package/lib/web/genericcom.js +30 -93
  149. package/lib/web/genericl10n.js +26 -143
  150. package/lib/web/grab_to_pan.js +57 -33
  151. package/lib/web/interfaces.js +105 -232
  152. package/lib/web/overlay_manager.js +73 -227
  153. package/lib/web/password_prompt.js +44 -62
  154. package/lib/web/pdf_attachment_viewer.js +118 -123
  155. package/lib/web/pdf_cursor_tools.js +89 -93
  156. package/lib/web/pdf_document_properties.js +242 -281
  157. package/lib/web/pdf_find_bar.js +157 -163
  158. package/lib/web/pdf_find_controller.js +598 -454
  159. package/lib/web/pdf_find_utils.js +32 -16
  160. package/lib/web/pdf_history.js +481 -355
  161. package/lib/web/pdf_link_service.js +355 -323
  162. package/lib/web/pdf_outline_viewer.js +167 -152
  163. package/lib/web/pdf_page_view.js +511 -457
  164. package/lib/web/pdf_presentation_mode.js +347 -335
  165. package/lib/web/pdf_print_service.js +133 -103
  166. package/lib/web/pdf_rendering_queue.js +98 -100
  167. package/lib/web/pdf_sidebar.js +323 -299
  168. package/lib/web/pdf_sidebar_resizer.js +107 -108
  169. package/lib/web/pdf_single_page_viewer.js +94 -146
  170. package/lib/web/pdf_thumbnail_view.js +319 -269
  171. package/lib/web/pdf_thumbnail_viewer.js +219 -199
  172. package/lib/web/pdf_viewer.component.js +111 -32
  173. package/lib/web/pdf_viewer.js +61 -101
  174. package/lib/web/preferences.js +87 -272
  175. package/lib/web/secondary_toolbar.js +207 -220
  176. package/lib/web/text_layer_builder.js +322 -322
  177. package/lib/web/toolbar.js +227 -180
  178. package/lib/web/ui_utils.js +476 -421
  179. package/lib/web/view_history.js +59 -208
  180. package/lib/web/viewer_compatibility.js +9 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +36 -22
  183. package/web/pdf_viewer.js +4407 -4516
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -441
  189. package/lib/shared/streams_polyfill.js +0 -39
  190. package/lib/shared/url_polyfill.js +0 -50
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
  192. package/lib/web/dom_events.js +0 -140
@@ -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 2018 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.
@@ -19,236 +19,241 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.CFFFDSelect = exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = undefined;
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
+ exports.CFFStandardStrings = CFFStandardStrings;
38
+ const NUM_STANDARD_CFF_STRINGS = 391;
39
+
37
40
  var CFFParser = function CFFParserClosure() {
38
41
  var CharstringValidationData = [null, {
39
- id: 'hstem',
42
+ id: "hstem",
40
43
  min: 2,
41
44
  stackClearing: true,
42
45
  stem: true
43
46
  }, null, {
44
- id: 'vstem',
47
+ id: "vstem",
45
48
  min: 2,
46
49
  stackClearing: true,
47
50
  stem: true
48
51
  }, {
49
- id: 'vmoveto',
52
+ id: "vmoveto",
50
53
  min: 1,
51
54
  stackClearing: true
52
55
  }, {
53
- id: 'rlineto',
56
+ id: "rlineto",
54
57
  min: 2,
55
58
  resetStack: true
56
59
  }, {
57
- id: 'hlineto',
60
+ id: "hlineto",
58
61
  min: 1,
59
62
  resetStack: true
60
63
  }, {
61
- id: 'vlineto',
64
+ id: "vlineto",
62
65
  min: 1,
63
66
  resetStack: true
64
67
  }, {
65
- id: 'rrcurveto',
68
+ id: "rrcurveto",
66
69
  min: 6,
67
70
  resetStack: true
68
71
  }, null, {
69
- id: 'callsubr',
72
+ id: "callsubr",
70
73
  min: 1,
71
74
  undefStack: true
72
75
  }, {
73
- id: 'return',
76
+ id: "return",
74
77
  min: 0,
75
78
  undefStack: true
76
79
  }, null, null, {
77
- id: 'endchar',
80
+ id: "endchar",
78
81
  min: 0,
79
82
  stackClearing: true
80
83
  }, null, null, null, {
81
- id: 'hstemhm',
84
+ id: "hstemhm",
82
85
  min: 2,
83
86
  stackClearing: true,
84
87
  stem: true
85
88
  }, {
86
- id: 'hintmask',
89
+ id: "hintmask",
87
90
  min: 0,
88
91
  stackClearing: true
89
92
  }, {
90
- id: 'cntrmask',
93
+ id: "cntrmask",
91
94
  min: 0,
92
95
  stackClearing: true
93
96
  }, {
94
- id: 'rmoveto',
97
+ id: "rmoveto",
95
98
  min: 2,
96
99
  stackClearing: true
97
100
  }, {
98
- id: 'hmoveto',
101
+ id: "hmoveto",
99
102
  min: 1,
100
103
  stackClearing: true
101
104
  }, {
102
- id: 'vstemhm',
105
+ id: "vstemhm",
103
106
  min: 2,
104
107
  stackClearing: true,
105
108
  stem: true
106
109
  }, {
107
- id: 'rcurveline',
110
+ id: "rcurveline",
108
111
  min: 8,
109
112
  resetStack: true
110
113
  }, {
111
- id: 'rlinecurve',
114
+ id: "rlinecurve",
112
115
  min: 8,
113
116
  resetStack: true
114
117
  }, {
115
- id: 'vvcurveto',
118
+ id: "vvcurveto",
116
119
  min: 4,
117
120
  resetStack: true
118
121
  }, {
119
- id: 'hhcurveto',
122
+ id: "hhcurveto",
120
123
  min: 4,
121
124
  resetStack: true
122
125
  }, null, {
123
- id: 'callgsubr',
126
+ id: "callgsubr",
124
127
  min: 1,
125
128
  undefStack: true
126
129
  }, {
127
- id: 'vhcurveto',
130
+ id: "vhcurveto",
128
131
  min: 4,
129
132
  resetStack: true
130
133
  }, {
131
- id: 'hvcurveto',
134
+ id: "hvcurveto",
132
135
  min: 4,
133
136
  resetStack: true
134
137
  }];
135
138
  var CharstringValidationData12 = [null, null, null, {
136
- id: 'and',
139
+ id: "and",
137
140
  min: 2,
138
141
  stackDelta: -1
139
142
  }, {
140
- id: 'or',
143
+ id: "or",
141
144
  min: 2,
142
145
  stackDelta: -1
143
146
  }, {
144
- id: 'not',
147
+ id: "not",
145
148
  min: 1,
146
149
  stackDelta: 0
147
150
  }, null, null, null, {
148
- id: 'abs',
151
+ id: "abs",
149
152
  min: 1,
150
153
  stackDelta: 0
151
154
  }, {
152
- id: 'add',
155
+ id: "add",
153
156
  min: 2,
154
157
  stackDelta: -1,
155
158
  stackFn: function stack_div(stack, index) {
156
159
  stack[index - 2] = stack[index - 2] + stack[index - 1];
157
160
  }
158
161
  }, {
159
- id: 'sub',
162
+ id: "sub",
160
163
  min: 2,
161
164
  stackDelta: -1,
162
165
  stackFn: function stack_div(stack, index) {
163
166
  stack[index - 2] = stack[index - 2] - stack[index - 1];
164
167
  }
165
168
  }, {
166
- id: 'div',
169
+ id: "div",
167
170
  min: 2,
168
171
  stackDelta: -1,
169
172
  stackFn: function stack_div(stack, index) {
170
173
  stack[index - 2] = stack[index - 2] / stack[index - 1];
171
174
  }
172
175
  }, null, {
173
- id: 'neg',
176
+ id: "neg",
174
177
  min: 1,
175
178
  stackDelta: 0,
176
179
  stackFn: function stack_div(stack, index) {
177
180
  stack[index - 1] = -stack[index - 1];
178
181
  }
179
182
  }, {
180
- id: 'eq',
183
+ id: "eq",
181
184
  min: 2,
182
185
  stackDelta: -1
183
186
  }, null, null, {
184
- id: 'drop',
187
+ id: "drop",
185
188
  min: 1,
186
189
  stackDelta: -1
187
190
  }, null, {
188
- id: 'put',
191
+ id: "put",
189
192
  min: 2,
190
193
  stackDelta: -2
191
194
  }, {
192
- id: 'get',
195
+ id: "get",
193
196
  min: 1,
194
197
  stackDelta: 0
195
198
  }, {
196
- id: 'ifelse',
199
+ id: "ifelse",
197
200
  min: 4,
198
201
  stackDelta: -3
199
202
  }, {
200
- id: 'random',
203
+ id: "random",
201
204
  min: 0,
202
205
  stackDelta: 1
203
206
  }, {
204
- id: 'mul',
207
+ id: "mul",
205
208
  min: 2,
206
209
  stackDelta: -1,
207
210
  stackFn: function stack_div(stack, index) {
208
211
  stack[index - 2] = stack[index - 2] * stack[index - 1];
209
212
  }
210
213
  }, null, {
211
- id: 'sqrt',
214
+ id: "sqrt",
212
215
  min: 1,
213
216
  stackDelta: 0
214
217
  }, {
215
- id: 'dup',
218
+ id: "dup",
216
219
  min: 1,
217
220
  stackDelta: 1
218
221
  }, {
219
- id: 'exch',
222
+ id: "exch",
220
223
  min: 2,
221
224
  stackDelta: 0
222
225
  }, {
223
- id: 'index',
226
+ id: "index",
224
227
  min: 2,
225
228
  stackDelta: 0
226
229
  }, {
227
- id: 'roll',
230
+ id: "roll",
228
231
  min: 3,
229
232
  stackDelta: -2
230
233
  }, null, null, null, {
231
- id: 'hflex',
234
+ id: "hflex",
232
235
  min: 7,
233
236
  resetStack: true
234
237
  }, {
235
- id: 'flex',
238
+ id: "flex",
236
239
  min: 13,
237
240
  resetStack: true
238
241
  }, {
239
- id: 'hflex1',
242
+ id: "hflex1",
240
243
  min: 9,
241
244
  resetStack: true
242
245
  }, {
243
- id: 'flex1',
246
+ id: "flex1",
244
247
  min: 11,
245
248
  resetStack: true
246
249
  }];
250
+
247
251
  function CFFParser(file, properties, seacAnalysisEnabled) {
248
252
  this.bytes = file.getBytes();
249
253
  this.properties = properties;
250
254
  this.seacAnalysisEnabled = !!seacAnalysisEnabled;
251
255
  }
256
+
252
257
  CFFParser.prototype = {
253
258
  parse: function CFFParser_parse() {
254
259
  var properties = this.properties;
@@ -267,35 +272,43 @@ var CFFParser = function CFFParserClosure() {
267
272
  cff.topDict = topDict;
268
273
  cff.globalSubrIndex = globalSubrIndex.obj;
269
274
  this.parsePrivateDict(cff.topDict);
270
- cff.isCIDFont = topDict.hasName('ROS');
271
- var charStringOffset = topDict.getByName('CharStrings');
275
+ cff.isCIDFont = topDict.hasName("ROS");
276
+ var charStringOffset = topDict.getByName("CharStrings");
272
277
  var charStringIndex = this.parseIndex(charStringOffset).obj;
273
- var fontMatrix = topDict.getByName('FontMatrix');
278
+ var fontMatrix = topDict.getByName("FontMatrix");
279
+
274
280
  if (fontMatrix) {
275
281
  properties.fontMatrix = fontMatrix;
276
282
  }
277
- var fontBBox = topDict.getByName('FontBBox');
283
+
284
+ var fontBBox = topDict.getByName("FontBBox");
285
+
278
286
  if (fontBBox) {
279
287
  properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
280
288
  properties.descent = Math.min(fontBBox[1], fontBBox[3]);
281
289
  properties.ascentScaled = true;
282
290
  }
291
+
283
292
  var charset, encoding;
293
+
284
294
  if (cff.isCIDFont) {
285
- var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
295
+ var fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
296
+
286
297
  for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
287
298
  var dictRaw = fdArrayIndex.get(i);
288
299
  var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
289
300
  this.parsePrivateDict(fontDict);
290
301
  cff.fdArray.push(fontDict);
291
302
  }
303
+
292
304
  encoding = null;
293
- charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
294
- 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);
295
307
  } else {
296
- charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
297
- 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);
298
310
  }
311
+
299
312
  cff.charset = charset;
300
313
  cff.encoding = encoding;
301
314
  var charStringsAndSeacs = this.parseCharStrings({
@@ -315,17 +328,21 @@ var CFFParser = function CFFParserClosure() {
315
328
  var bytes = this.bytes;
316
329
  var bytesLength = bytes.length;
317
330
  var offset = 0;
331
+
318
332
  while (offset < bytesLength && bytes[offset] !== 1) {
319
333
  ++offset;
320
334
  }
335
+
321
336
  if (offset >= bytesLength) {
322
- throw new _util.FormatError('Invalid CFF header');
337
+ throw new _util.FormatError("Invalid CFF header");
323
338
  }
339
+
324
340
  if (offset !== 0) {
325
- (0, _util.info)('cff data is shifted');
341
+ (0, _util.info)("cff data is shifted");
326
342
  bytes = bytes.subarray(offset);
327
343
  this.bytes = bytes;
328
344
  }
345
+
329
346
  var major = bytes[0];
330
347
  var minor = bytes[1];
331
348
  var hdrSize = bytes[2];
@@ -338,8 +355,10 @@ var CFFParser = function CFFParserClosure() {
338
355
  },
339
356
  parseDict: function CFFParser_parseDict(dict) {
340
357
  var pos = 0;
358
+
341
359
  function parseOperand() {
342
360
  var value = dict[pos++];
361
+
343
362
  if (value === 30) {
344
363
  return parseFloatOperand();
345
364
  } else if (value === 28) {
@@ -359,39 +378,51 @@ var CFFParser = function CFFParserClosure() {
359
378
  } else if (value >= 251 && value <= 254) {
360
379
  return -((value - 251) * 256) - dict[pos++] - 108;
361
380
  }
381
+
362
382
  (0, _util.warn)('CFFParser_parseDict: "' + value + '" is a reserved command.');
363
383
  return NaN;
364
384
  }
385
+
365
386
  function parseFloatOperand() {
366
- var str = '';
387
+ var str = "";
367
388
  var eof = 15;
368
- var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'E', 'E-', null, '-'];
389
+ const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
369
390
  var length = dict.length;
391
+
370
392
  while (pos < length) {
371
393
  var b = dict[pos++];
372
394
  var b1 = b >> 4;
373
395
  var b2 = b & 15;
396
+
374
397
  if (b1 === eof) {
375
398
  break;
376
399
  }
400
+
377
401
  str += lookup[b1];
402
+
378
403
  if (b2 === eof) {
379
404
  break;
380
405
  }
406
+
381
407
  str += lookup[b2];
382
408
  }
409
+
383
410
  return parseFloat(str);
384
411
  }
412
+
385
413
  var operands = [];
386
414
  var entries = [];
387
415
  pos = 0;
388
416
  var end = dict.length;
417
+
389
418
  while (pos < end) {
390
419
  var b = dict[pos];
420
+
391
421
  if (b <= 21) {
392
422
  if (b === 12) {
393
423
  b = b << 8 | dict[++pos];
394
424
  }
425
+
395
426
  entries.push([b, operands]);
396
427
  operands = [];
397
428
  ++pos;
@@ -399,6 +430,7 @@ var CFFParser = function CFFParserClosure() {
399
430
  operands.push(parseOperand());
400
431
  }
401
432
  }
433
+
402
434
  return entries;
403
435
  },
404
436
  parseIndex: function CFFParser_parseIndex(pos) {
@@ -408,24 +440,31 @@ var CFFParser = function CFFParserClosure() {
408
440
  var offsets = [];
409
441
  var end = pos;
410
442
  var i, ii;
443
+
411
444
  if (count !== 0) {
412
445
  var offsetSize = bytes[pos++];
413
446
  var startPos = pos + (count + 1) * offsetSize - 1;
447
+
414
448
  for (i = 0, ii = count + 1; i < ii; ++i) {
415
449
  var offset = 0;
450
+
416
451
  for (var j = 0; j < offsetSize; ++j) {
417
452
  offset <<= 8;
418
453
  offset += bytes[pos++];
419
454
  }
455
+
420
456
  offsets.push(startPos + offset);
421
457
  }
458
+
422
459
  end = offsets[count];
423
460
  }
461
+
424
462
  for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
425
463
  var offsetStart = offsets[i];
426
464
  var offsetEnd = offsets[i + 1];
427
465
  cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
428
466
  }
467
+
429
468
  return {
430
469
  obj: cffIndex,
431
470
  endPos: end
@@ -433,42 +472,52 @@ var CFFParser = function CFFParserClosure() {
433
472
  },
434
473
  parseNameIndex: function CFFParser_parseNameIndex(index) {
435
474
  var names = [];
475
+
436
476
  for (var i = 0, ii = index.count; i < ii; ++i) {
437
477
  var name = index.get(i);
438
478
  names.push((0, _util.bytesToString)(name));
439
479
  }
480
+
440
481
  return names;
441
482
  },
442
483
  parseStringIndex: function CFFParser_parseStringIndex(index) {
443
484
  var strings = new CFFStrings();
485
+
444
486
  for (var i = 0, ii = index.count; i < ii; ++i) {
445
487
  var data = index.get(i);
446
488
  strings.add((0, _util.bytesToString)(data));
447
489
  }
490
+
448
491
  return strings;
449
492
  },
450
493
  createDict: function CFFParser_createDict(Type, dict, strings) {
451
494
  var cffDict = new Type(strings);
495
+
452
496
  for (var i = 0, ii = dict.length; i < ii; ++i) {
453
497
  var pair = dict[i];
454
498
  var key = pair[0];
455
499
  var value = pair[1];
456
500
  cffDict.setByKey(key, value);
457
501
  }
502
+
458
503
  return cffDict;
459
504
  },
460
505
  parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
461
506
  if (!data || state.callDepth > MAX_SUBR_NESTING) {
462
507
  return false;
463
508
  }
509
+
464
510
  var stackSize = state.stackSize;
465
511
  var stack = state.stack;
466
512
  var length = data.length;
513
+
467
514
  for (var j = 0; j < length;) {
468
515
  var value = data[j++];
469
516
  var validationCommand = null;
517
+
470
518
  if (value === 12) {
471
519
  var q = data[j++];
520
+
472
521
  if (q === 0) {
473
522
  data[j - 2] = 139;
474
523
  data[j - 1] = 22;
@@ -483,11 +532,13 @@ var CFFParser = function CFFParserClosure() {
483
532
  } else if (value === 14) {
484
533
  if (stackSize >= 4) {
485
534
  stackSize -= 4;
535
+
486
536
  if (this.seacAnalysisEnabled) {
487
537
  state.seac = stack.slice(stackSize, stackSize + 4);
488
538
  return false;
489
539
  }
490
540
  }
541
+
491
542
  validationCommand = CharstringValidationData[value];
492
543
  } else if (value >= 32 && value <= 246) {
493
544
  stack[stackSize] = value - 139;
@@ -507,34 +558,43 @@ var CFFParser = function CFFParserClosure() {
507
558
  validationCommand = CharstringValidationData[value];
508
559
  } else if (value === 10 || value === 29) {
509
560
  var subrsIndex;
561
+
510
562
  if (value === 10) {
511
563
  subrsIndex = localSubrIndex;
512
564
  } else {
513
565
  subrsIndex = globalSubrIndex;
514
566
  }
567
+
515
568
  if (!subrsIndex) {
516
569
  validationCommand = CharstringValidationData[value];
517
- (0, _util.warn)('Missing subrsIndex for ' + validationCommand.id);
570
+ (0, _util.warn)("Missing subrsIndex for " + validationCommand.id);
518
571
  return false;
519
572
  }
573
+
520
574
  var bias = 32768;
575
+
521
576
  if (subrsIndex.count < 1240) {
522
577
  bias = 107;
523
578
  } else if (subrsIndex.count < 33900) {
524
579
  bias = 1131;
525
580
  }
581
+
526
582
  var subrNumber = stack[--stackSize] + bias;
583
+
527
584
  if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
528
585
  validationCommand = CharstringValidationData[value];
529
- (0, _util.warn)('Out of bounds subrIndex for ' + validationCommand.id);
586
+ (0, _util.warn)("Out of bounds subrIndex for " + validationCommand.id);
530
587
  return false;
531
588
  }
589
+
532
590
  state.stackSize = stackSize;
533
591
  state.callDepth++;
534
592
  var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
593
+
535
594
  if (!valid) {
536
595
  return false;
537
596
  }
597
+
538
598
  state.callDepth--;
539
599
  stackSize = state.stackSize;
540
600
  continue;
@@ -544,32 +604,46 @@ var CFFParser = function CFFParserClosure() {
544
604
  } else {
545
605
  validationCommand = CharstringValidationData[value];
546
606
  }
607
+
547
608
  if (validationCommand) {
548
609
  if (validationCommand.stem) {
549
610
  state.hints += stackSize >> 1;
611
+
612
+ if (value === 3 || value === 23) {
613
+ state.hasVStems = true;
614
+ } else if (state.hasVStems && (value === 1 || value === 18)) {
615
+ (0, _util.warn)("CFF stem hints are in wrong order");
616
+ data[j - 1] = value === 1 ? 3 : 23;
617
+ }
550
618
  }
551
- if ('min' in validationCommand) {
619
+
620
+ if ("min" in validationCommand) {
552
621
  if (!state.undefStack && stackSize < validationCommand.min) {
553
- (0, _util.warn)('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
622
+ (0, _util.warn)("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
554
623
  return false;
555
624
  }
556
625
  }
626
+
557
627
  if (state.firstStackClearing && validationCommand.stackClearing) {
558
628
  state.firstStackClearing = false;
559
629
  stackSize -= validationCommand.min;
630
+
560
631
  if (stackSize >= 2 && validationCommand.stem) {
561
632
  stackSize %= 2;
562
633
  } else if (stackSize > 1) {
563
- (0, _util.warn)('Found too many parameters for stack-clearing command');
634
+ (0, _util.warn)("Found too many parameters for stack-clearing command");
564
635
  }
636
+
565
637
  if (stackSize > 0 && stack[stackSize - 1] >= 0) {
566
638
  state.width = stack[stackSize - 1];
567
639
  }
568
640
  }
569
- if ('stackDelta' in validationCommand) {
570
- if ('stackFn' in validationCommand) {
641
+
642
+ if ("stackDelta" in validationCommand) {
643
+ if ("stackFn" in validationCommand) {
571
644
  validationCommand.stackFn(stack, stackSize);
572
645
  }
646
+
573
647
  stackSize += validationCommand.stackDelta;
574
648
  } else if (validationCommand.stackClearing) {
575
649
  stackSize = 0;
@@ -583,20 +657,23 @@ var CFFParser = function CFFParserClosure() {
583
657
  }
584
658
  }
585
659
  }
660
+
586
661
  state.stackSize = stackSize;
587
662
  return true;
588
663
  },
589
- parseCharStrings: function parseCharStrings(_ref) {
590
- var charStrings = _ref.charStrings,
591
- localSubrIndex = _ref.localSubrIndex,
592
- globalSubrIndex = _ref.globalSubrIndex,
593
- fdSelect = _ref.fdSelect,
594
- fdArray = _ref.fdArray,
595
- privateDict = _ref.privateDict;
596
664
 
665
+ parseCharStrings({
666
+ charStrings,
667
+ localSubrIndex,
668
+ globalSubrIndex,
669
+ fdSelect,
670
+ fdArray,
671
+ privateDict
672
+ }) {
597
673
  var seacs = [];
598
674
  var widths = [];
599
675
  var count = charStrings.count;
676
+
600
677
  for (var i = 0; i < count; i++) {
601
678
  var charstring = charStrings.get(i);
602
679
  var state = {
@@ -607,21 +684,26 @@ var CFFParser = function CFFParserClosure() {
607
684
  hints: 0,
608
685
  firstStackClearing: true,
609
686
  seac: null,
610
- width: null
687
+ width: null,
688
+ hasVStems: false
611
689
  };
612
690
  var valid = true;
613
691
  var localSubrToUse = null;
614
692
  var privateDictToUse = privateDict;
693
+
615
694
  if (fdSelect && fdArray.length) {
616
695
  var fdIndex = fdSelect.getFDIndex(i);
696
+
617
697
  if (fdIndex === -1) {
618
- (0, _util.warn)('Glyph index is not in fd select.');
698
+ (0, _util.warn)("Glyph index is not in fd select.");
619
699
  valid = false;
620
700
  }
701
+
621
702
  if (fdIndex >= fdArray.length) {
622
- (0, _util.warn)('Invalid fd index for glyph index.');
703
+ (0, _util.warn)("Invalid fd index for glyph index.");
623
704
  valid = false;
624
705
  }
706
+
625
707
  if (valid) {
626
708
  privateDictToUse = fdArray[fdIndex].privateDict;
627
709
  localSubrToUse = privateDictToUse.subrsIndex;
@@ -629,27 +711,32 @@ var CFFParser = function CFFParserClosure() {
629
711
  } else if (localSubrIndex) {
630
712
  localSubrToUse = localSubrIndex;
631
713
  }
714
+
632
715
  if (valid) {
633
716
  valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
634
717
  }
718
+
635
719
  if (state.width !== null) {
636
- var nominalWidth = privateDictToUse.getByName('nominalWidthX');
720
+ const nominalWidth = privateDictToUse.getByName("nominalWidthX");
637
721
  widths[i] = nominalWidth + state.width;
638
722
  } else {
639
- var defaultWidth = privateDictToUse.getByName('defaultWidthX');
723
+ const defaultWidth = privateDictToUse.getByName("defaultWidthX");
640
724
  widths[i] = defaultWidth;
641
725
  }
726
+
642
727
  if (state.seac !== null) {
643
728
  seacs[i] = state.seac;
644
729
  }
730
+
645
731
  if (!valid) {
646
732
  charStrings.set(i, new Uint8Array([14]));
647
733
  }
648
734
  }
735
+
649
736
  return {
650
- charStrings: charStrings,
651
- seacs: seacs,
652
- widths: widths
737
+ charStrings,
738
+ seacs,
739
+ widths
653
740
  };
654
741
  },
655
742
 
@@ -659,35 +746,44 @@ var CFFParser = function CFFParserClosure() {
659
746
  parentDict.privateDict = privateDict;
660
747
  },
661
748
  parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
662
- if (!parentDict.hasName('Private')) {
749
+ if (!parentDict.hasName("Private")) {
663
750
  this.emptyPrivateDictionary(parentDict);
664
751
  return;
665
752
  }
666
- var privateOffset = parentDict.getByName('Private');
753
+
754
+ var privateOffset = parentDict.getByName("Private");
755
+
667
756
  if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
668
- parentDict.removeByName('Private');
757
+ parentDict.removeByName("Private");
669
758
  return;
670
759
  }
760
+
671
761
  var size = privateOffset[0];
672
762
  var offset = privateOffset[1];
763
+
673
764
  if (size === 0 || offset >= this.bytes.length) {
674
765
  this.emptyPrivateDictionary(parentDict);
675
766
  return;
676
767
  }
768
+
677
769
  var privateDictEnd = offset + size;
678
770
  var dictData = this.bytes.subarray(offset, privateDictEnd);
679
771
  var dict = this.parseDict(dictData);
680
772
  var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
681
773
  parentDict.privateDict = privateDict;
682
- if (!privateDict.getByName('Subrs')) {
774
+
775
+ if (!privateDict.getByName("Subrs")) {
683
776
  return;
684
777
  }
685
- var subrsOffset = privateDict.getByName('Subrs');
778
+
779
+ var subrsOffset = privateDict.getByName("Subrs");
686
780
  var relativeOffset = offset + subrsOffset;
781
+
687
782
  if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
688
783
  this.emptyPrivateDictionary(parentDict);
689
784
  return;
690
785
  }
786
+
691
787
  var subrsIndex = this.parseIndex(relativeOffset);
692
788
  privateDict.subrsIndex = subrsIndex.obj;
693
789
  },
@@ -699,40 +795,51 @@ var CFFParser = function CFFParserClosure() {
699
795
  } else if (pos === 2) {
700
796
  return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);
701
797
  }
798
+
702
799
  var bytes = this.bytes;
703
800
  var start = pos;
704
801
  var format = bytes[pos++];
705
- var charset = ['.notdef'];
802
+ var charset = [".notdef"];
706
803
  var id, count, i;
707
804
  length -= 1;
805
+
708
806
  switch (format) {
709
807
  case 0:
710
808
  for (i = 0; i < length; i++) {
711
809
  id = bytes[pos++] << 8 | bytes[pos++];
712
810
  charset.push(cid ? id : strings.get(id));
713
811
  }
812
+
714
813
  break;
814
+
715
815
  case 1:
716
816
  while (charset.length <= length) {
717
817
  id = bytes[pos++] << 8 | bytes[pos++];
718
818
  count = bytes[pos++];
819
+
719
820
  for (i = 0; i <= count; i++) {
720
821
  charset.push(cid ? id++ : strings.get(id++));
721
822
  }
722
823
  }
824
+
723
825
  break;
826
+
724
827
  case 2:
725
828
  while (charset.length <= length) {
726
829
  id = bytes[pos++] << 8 | bytes[pos++];
727
830
  count = bytes[pos++] << 8 | bytes[pos++];
831
+
728
832
  for (i = 0; i <= count; i++) {
729
833
  charset.push(cid ? id++ : strings.get(id++));
730
834
  }
731
835
  }
836
+
732
837
  break;
838
+
733
839
  default:
734
- throw new _util.FormatError('Unknown charset format');
840
+ throw new _util.FormatError("Unknown charset format");
735
841
  }
842
+
736
843
  var end = pos;
737
844
  var raw = bytes.subarray(start, end);
738
845
  return new CFFCharset(false, format, charset, raw);
@@ -743,20 +850,25 @@ var CFFParser = function CFFParserClosure() {
743
850
  var predefined = false;
744
851
  var format, i, ii;
745
852
  var raw = null;
853
+
746
854
  function readSupplement() {
747
855
  var supplementsCount = bytes[pos++];
856
+
748
857
  for (i = 0; i < supplementsCount; i++) {
749
858
  var code = bytes[pos++];
750
859
  var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
751
860
  encoding[code] = charset.indexOf(strings.get(sid));
752
861
  }
753
862
  }
863
+
754
864
  if (pos === 0 || pos === 1) {
755
865
  predefined = true;
756
866
  format = pos;
757
867
  var baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
868
+
758
869
  for (i = 0, ii = charset.length; i < ii; i++) {
759
870
  var index = baseEncoding.indexOf(charset[i]);
871
+
760
872
  if (index !== -1) {
761
873
  encoding[index] = i;
762
874
  }
@@ -764,34 +876,46 @@ var CFFParser = function CFFParserClosure() {
764
876
  } else {
765
877
  var dataStart = pos;
766
878
  format = bytes[pos++];
879
+
767
880
  switch (format & 0x7f) {
768
881
  case 0:
769
882
  var glyphsCount = bytes[pos++];
883
+
770
884
  for (i = 1; i <= glyphsCount; i++) {
771
885
  encoding[bytes[pos++]] = i;
772
886
  }
887
+
773
888
  break;
889
+
774
890
  case 1:
775
891
  var rangesCount = bytes[pos++];
776
892
  var gid = 1;
893
+
777
894
  for (i = 0; i < rangesCount; i++) {
778
895
  var start = bytes[pos++];
779
896
  var left = bytes[pos++];
897
+
780
898
  for (var j = start; j <= start + left; j++) {
781
899
  encoding[j] = gid++;
782
900
  }
783
901
  }
902
+
784
903
  break;
904
+
785
905
  default:
786
- throw new _util.FormatError('Unknown encoding format: ' + format + ' in CFF');
906
+ throw new _util.FormatError(`Unknown encoding format: ${format} in CFF`);
787
907
  }
908
+
788
909
  var dataEnd = pos;
910
+
789
911
  if (format & 0x80) {
790
912
  bytes[dataStart] &= 0x7f;
791
913
  readSupplement();
792
914
  }
915
+
793
916
  raw = bytes.subarray(dataStart, dataEnd);
794
917
  }
918
+
795
919
  format = format & 0x7f;
796
920
  return new CFFEncoding(predefined, format, encoding, raw);
797
921
  },
@@ -800,40 +924,54 @@ var CFFParser = function CFFParserClosure() {
800
924
  var format = bytes[pos++];
801
925
  var fdSelect = [];
802
926
  var i;
927
+
803
928
  switch (format) {
804
929
  case 0:
805
930
  for (i = 0; i < length; ++i) {
806
931
  var id = bytes[pos++];
807
932
  fdSelect.push(id);
808
933
  }
934
+
809
935
  break;
936
+
810
937
  case 3:
811
938
  var rangesCount = bytes[pos++] << 8 | bytes[pos++];
939
+
812
940
  for (i = 0; i < rangesCount; ++i) {
813
941
  var first = bytes[pos++] << 8 | bytes[pos++];
942
+
814
943
  if (i === 0 && first !== 0) {
815
- (0, _util.warn)('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
944
+ (0, _util.warn)("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
816
945
  first = 0;
817
946
  }
947
+
818
948
  var fdIndex = bytes[pos++];
819
949
  var next = bytes[pos] << 8 | bytes[pos + 1];
950
+
820
951
  for (var j = first; j < next; ++j) {
821
952
  fdSelect.push(fdIndex);
822
953
  }
823
954
  }
955
+
824
956
  pos += 2;
825
957
  break;
958
+
826
959
  default:
827
- throw new _util.FormatError('parseFDSelect: Unknown format "' + format + '".');
960
+ throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`);
828
961
  }
962
+
829
963
  if (fdSelect.length !== length) {
830
- throw new _util.FormatError('parseFDSelect: Invalid font data.');
964
+ throw new _util.FormatError("parseFDSelect: Invalid font data.");
831
965
  }
966
+
832
967
  return new CFFFDSelect(format, fdSelect);
833
968
  }
834
969
  };
835
970
  return CFFParser;
836
971
  }();
972
+
973
+ exports.CFFParser = CFFParser;
974
+
837
975
  var CFF = function CFFClosure() {
838
976
  function CFF() {
839
977
  this.header = null;
@@ -848,14 +986,17 @@ var CFF = function CFFClosure() {
848
986
  this.fdSelect = null;
849
987
  this.isCIDFont = false;
850
988
  }
989
+
851
990
  CFF.prototype = {
852
991
  duplicateFirstGlyph: function CFF_duplicateFirstGlyph() {
853
992
  if (this.charStrings.count >= 65535) {
854
- (0, _util.warn)('Not enough space in charstrings to duplicate first glyph.');
993
+ (0, _util.warn)("Not enough space in charstrings to duplicate first glyph.");
855
994
  return;
856
995
  }
996
+
857
997
  var glyphZero = this.charStrings.get(0);
858
998
  this.charStrings.add(glyphZero);
999
+
859
1000
  if (this.isCIDFont) {
860
1001
  this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
861
1002
  }
@@ -864,12 +1005,16 @@ var CFF = function CFFClosure() {
864
1005
  if (id < 0 || id >= this.charStrings.count) {
865
1006
  return false;
866
1007
  }
1008
+
867
1009
  var glyph = this.charStrings.get(id);
868
1010
  return glyph.length > 0;
869
1011
  }
870
1012
  };
871
1013
  return CFF;
872
1014
  }();
1015
+
1016
+ exports.CFF = CFF;
1017
+
873
1018
  var CFFHeader = function CFFHeaderClosure() {
874
1019
  function CFFHeader(major, minor, hdrSize, offSize) {
875
1020
  this.major = major;
@@ -877,36 +1022,64 @@ var CFFHeader = function CFFHeaderClosure() {
877
1022
  this.hdrSize = hdrSize;
878
1023
  this.offSize = offSize;
879
1024
  }
1025
+
880
1026
  return CFFHeader;
881
1027
  }();
1028
+
1029
+ exports.CFFHeader = CFFHeader;
1030
+
882
1031
  var CFFStrings = function CFFStringsClosure() {
883
1032
  function CFFStrings() {
884
1033
  this.strings = [];
885
1034
  }
1035
+
886
1036
  CFFStrings.prototype = {
887
1037
  get: function CFFStrings_get(index) {
888
- if (index >= 0 && index <= 390) {
1038
+ if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
889
1039
  return CFFStandardStrings[index];
890
1040
  }
891
- if (index - 391 <= this.strings.length) {
892
- return this.strings[index - 391];
1041
+
1042
+ if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
1043
+ return this.strings[index - NUM_STANDARD_CFF_STRINGS];
893
1044
  }
1045
+
894
1046
  return CFFStandardStrings[0];
895
1047
  },
1048
+ getSID: function CFFStrings_getSID(str) {
1049
+ let index = CFFStandardStrings.indexOf(str);
1050
+
1051
+ if (index !== -1) {
1052
+ return index;
1053
+ }
1054
+
1055
+ index = this.strings.indexOf(str);
1056
+
1057
+ if (index !== -1) {
1058
+ return index + NUM_STANDARD_CFF_STRINGS;
1059
+ }
1060
+
1061
+ return -1;
1062
+ },
896
1063
  add: function CFFStrings_add(value) {
897
1064
  this.strings.push(value);
898
1065
  },
1066
+
899
1067
  get count() {
900
1068
  return this.strings.length;
901
1069
  }
1070
+
902
1071
  };
903
1072
  return CFFStrings;
904
1073
  }();
1074
+
1075
+ exports.CFFStrings = CFFStrings;
1076
+
905
1077
  var CFFIndex = function CFFIndexClosure() {
906
1078
  function CFFIndex() {
907
1079
  this.objects = [];
908
1080
  this.length = 0;
909
1081
  }
1082
+
910
1083
  CFFIndex.prototype = {
911
1084
  add: function CFFIndex_add(data) {
912
1085
  this.length += data.length;
@@ -919,12 +1092,17 @@ var CFFIndex = function CFFIndexClosure() {
919
1092
  get: function CFFIndex_get(index) {
920
1093
  return this.objects[index];
921
1094
  },
1095
+
922
1096
  get count() {
923
1097
  return this.objects.length;
924
1098
  }
1099
+
925
1100
  };
926
1101
  return CFFIndex;
927
1102
  }();
1103
+
1104
+ exports.CFFIndex = CFFIndex;
1105
+
928
1106
  var CFFDict = function CFFDictClosure() {
929
1107
  function CFFDict(tables, strings) {
930
1108
  this.keyToNameMap = tables.keyToNameMap;
@@ -936,32 +1114,40 @@ var CFFDict = function CFFDictClosure() {
936
1114
  this.strings = strings;
937
1115
  this.values = Object.create(null);
938
1116
  }
1117
+
939
1118
  CFFDict.prototype = {
940
1119
  setByKey: function CFFDict_setByKey(key, value) {
941
1120
  if (!(key in this.keyToNameMap)) {
942
1121
  return false;
943
1122
  }
1123
+
944
1124
  var valueLength = value.length;
1125
+
945
1126
  if (valueLength === 0) {
946
1127
  return true;
947
1128
  }
1129
+
948
1130
  for (var i = 0; i < valueLength; i++) {
949
1131
  if (isNaN(value[i])) {
950
1132
  (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
951
1133
  return true;
952
1134
  }
953
1135
  }
1136
+
954
1137
  var type = this.types[key];
955
- if (type === 'num' || type === 'sid' || type === 'offset') {
1138
+
1139
+ if (type === "num" || type === "sid" || type === "offset") {
956
1140
  value = value[0];
957
1141
  }
1142
+
958
1143
  this.values[key] = value;
959
1144
  return true;
960
1145
  },
961
1146
  setByName: function CFFDict_setByName(name, value) {
962
1147
  if (!(name in this.nameToKeyMap)) {
963
- throw new _util.FormatError('Invalid dictionary name "' + name + '"');
1148
+ throw new _util.FormatError(`Invalid dictionary name "${name}"`);
964
1149
  }
1150
+
965
1151
  this.values[this.nameToKeyMap[name]] = value;
966
1152
  },
967
1153
  hasName: function CFFDict_hasName(name) {
@@ -969,18 +1155,22 @@ var CFFDict = function CFFDictClosure() {
969
1155
  },
970
1156
  getByName: function CFFDict_getByName(name) {
971
1157
  if (!(name in this.nameToKeyMap)) {
972
- throw new _util.FormatError('Invalid dictionary name ' + name + '"');
1158
+ throw new _util.FormatError(`Invalid dictionary name ${name}"`);
973
1159
  }
1160
+
974
1161
  var key = this.nameToKeyMap[name];
1162
+
975
1163
  if (!(key in this.values)) {
976
1164
  return this.defaults[key];
977
1165
  }
1166
+
978
1167
  return this.values[key];
979
1168
  },
980
1169
  removeByName: function CFFDict_removeByName(name) {
981
1170
  delete this.values[this.nameToKeyMap[name]];
982
1171
  }
983
1172
  };
1173
+
984
1174
  CFFDict.createTables = function CFFDict_createTables(layout) {
985
1175
  var tables = {
986
1176
  keyToNameMap: {},
@@ -990,6 +1180,7 @@ var CFFDict = function CFFDictClosure() {
990
1180
  opcodes: {},
991
1181
  order: []
992
1182
  };
1183
+
993
1184
  for (var i = 0, ii = layout.length; i < ii; ++i) {
994
1185
  var entry = layout[i];
995
1186
  var key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
@@ -1000,41 +1191,56 @@ var CFFDict = function CFFDictClosure() {
1000
1191
  tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
1001
1192
  tables.order.push(key);
1002
1193
  }
1194
+
1003
1195
  return tables;
1004
1196
  };
1197
+
1005
1198
  return CFFDict;
1006
1199
  }();
1200
+
1007
1201
  var CFFTopDict = function CFFTopDictClosure() {
1008
- 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]];
1202
+ 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]];
1009
1203
  var tables = null;
1204
+
1010
1205
  function CFFTopDict(strings) {
1011
1206
  if (tables === null) {
1012
1207
  tables = CFFDict.createTables(layout);
1013
1208
  }
1209
+
1014
1210
  CFFDict.call(this, tables, strings);
1015
1211
  this.privateDict = null;
1016
1212
  }
1213
+
1017
1214
  CFFTopDict.prototype = Object.create(CFFDict.prototype);
1018
1215
  return CFFTopDict;
1019
1216
  }();
1217
+
1218
+ exports.CFFTopDict = CFFTopDict;
1219
+
1020
1220
  var CFFPrivateDict = function CFFPrivateDictClosure() {
1021
- 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]];
1221
+ 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]];
1022
1222
  var tables = null;
1223
+
1023
1224
  function CFFPrivateDict(strings) {
1024
1225
  if (tables === null) {
1025
1226
  tables = CFFDict.createTables(layout);
1026
1227
  }
1228
+
1027
1229
  CFFDict.call(this, tables, strings);
1028
1230
  this.subrsIndex = null;
1029
1231
  }
1232
+
1030
1233
  CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
1031
1234
  return CFFPrivateDict;
1032
1235
  }();
1236
+
1237
+ exports.CFFPrivateDict = CFFPrivateDict;
1033
1238
  var CFFCharsetPredefinedTypes = {
1034
1239
  ISO_ADOBE: 0,
1035
1240
  EXPERT: 1,
1036
1241
  EXPERT_SUBSET: 2
1037
1242
  };
1243
+
1038
1244
  var CFFCharset = function CFFCharsetClosure() {
1039
1245
  function CFFCharset(predefined, format, charset, raw) {
1040
1246
  this.predefined = predefined;
@@ -1042,8 +1248,12 @@ var CFFCharset = function CFFCharsetClosure() {
1042
1248
  this.charset = charset;
1043
1249
  this.raw = raw;
1044
1250
  }
1251
+
1045
1252
  return CFFCharset;
1046
1253
  }();
1254
+
1255
+ exports.CFFCharset = CFFCharset;
1256
+
1047
1257
  var CFFEncoding = function CFFEncodingClosure() {
1048
1258
  function CFFEncoding(predefined, format, encoding, raw) {
1049
1259
  this.predefined = predefined;
@@ -1051,35 +1261,44 @@ var CFFEncoding = function CFFEncodingClosure() {
1051
1261
  this.encoding = encoding;
1052
1262
  this.raw = raw;
1053
1263
  }
1264
+
1054
1265
  return CFFEncoding;
1055
1266
  }();
1267
+
1056
1268
  var CFFFDSelect = function CFFFDSelectClosure() {
1057
1269
  function CFFFDSelect(format, fdSelect) {
1058
1270
  this.format = format;
1059
1271
  this.fdSelect = fdSelect;
1060
1272
  }
1273
+
1061
1274
  CFFFDSelect.prototype = {
1062
1275
  getFDIndex: function CFFFDSelect_get(glyphIndex) {
1063
1276
  if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
1064
1277
  return -1;
1065
1278
  }
1279
+
1066
1280
  return this.fdSelect[glyphIndex];
1067
1281
  }
1068
1282
  };
1069
1283
  return CFFFDSelect;
1070
1284
  }();
1285
+
1286
+ exports.CFFFDSelect = CFFFDSelect;
1287
+
1071
1288
  var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
1072
1289
  function CFFOffsetTracker() {
1073
1290
  this.offsets = Object.create(null);
1074
1291
  }
1292
+
1075
1293
  CFFOffsetTracker.prototype = {
1076
1294
  isTracking: function CFFOffsetTracker_isTracking(key) {
1077
1295
  return key in this.offsets;
1078
1296
  },
1079
1297
  track: function CFFOffsetTracker_track(key, location) {
1080
1298
  if (key in this.offsets) {
1081
- throw new _util.FormatError('Already tracking location of ' + key);
1299
+ throw new _util.FormatError(`Already tracking location of ${key}`);
1082
1300
  }
1301
+
1083
1302
  this.offsets[key] = location;
1084
1303
  },
1085
1304
  offset: function CFFOffsetTracker_offset(value) {
@@ -1089,35 +1308,41 @@ var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
1089
1308
  },
1090
1309
  setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
1091
1310
  if (!(key in this.offsets)) {
1092
- throw new _util.FormatError('Not tracking location of ' + key);
1311
+ throw new _util.FormatError(`Not tracking location of ${key}`);
1093
1312
  }
1313
+
1094
1314
  var data = output.data;
1095
1315
  var dataOffset = this.offsets[key];
1096
1316
  var size = 5;
1317
+
1097
1318
  for (var i = 0, ii = values.length; i < ii; ++i) {
1098
1319
  var offset0 = i * size + dataOffset;
1099
1320
  var offset1 = offset0 + 1;
1100
1321
  var offset2 = offset0 + 2;
1101
1322
  var offset3 = offset0 + 3;
1102
1323
  var offset4 = offset0 + 4;
1324
+
1103
1325
  if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
1104
- throw new _util.FormatError('writing to an offset that is not empty');
1326
+ throw new _util.FormatError("writing to an offset that is not empty");
1105
1327
  }
1328
+
1106
1329
  var value = values[i];
1107
1330
  data[offset0] = 0x1d;
1108
- data[offset1] = value >> 24 & 0xFF;
1109
- data[offset2] = value >> 16 & 0xFF;
1110
- data[offset3] = value >> 8 & 0xFF;
1111
- data[offset4] = value & 0xFF;
1331
+ data[offset1] = value >> 24 & 0xff;
1332
+ data[offset2] = value >> 16 & 0xff;
1333
+ data[offset3] = value >> 8 & 0xff;
1334
+ data[offset4] = value & 0xff;
1112
1335
  }
1113
1336
  }
1114
1337
  };
1115
1338
  return CFFOffsetTracker;
1116
1339
  }();
1340
+
1117
1341
  var CFFCompiler = function CFFCompilerClosure() {
1118
1342
  function CFFCompiler(cff) {
1119
1343
  this.cff = cff;
1120
1344
  }
1345
+
1121
1346
  CFFCompiler.prototype = {
1122
1347
  compile: function CFFCompiler_compile() {
1123
1348
  var cff = this.cff;
@@ -1133,21 +1358,26 @@ var CFFCompiler = function CFFCompilerClosure() {
1133
1358
  output.add(header);
1134
1359
  var nameIndex = this.compileNameIndex(cff.names);
1135
1360
  output.add(nameIndex);
1361
+
1136
1362
  if (cff.isCIDFont) {
1137
- if (cff.topDict.hasName('FontMatrix')) {
1138
- var base = cff.topDict.getByName('FontMatrix');
1139
- cff.topDict.removeByName('FontMatrix');
1363
+ if (cff.topDict.hasName("FontMatrix")) {
1364
+ var base = cff.topDict.getByName("FontMatrix");
1365
+ cff.topDict.removeByName("FontMatrix");
1366
+
1140
1367
  for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
1141
1368
  var subDict = cff.fdArray[i];
1142
1369
  var matrix = base.slice(0);
1143
- if (subDict.hasName('FontMatrix')) {
1144
- matrix = _util.Util.transform(matrix, subDict.getByName('FontMatrix'));
1370
+
1371
+ if (subDict.hasName("FontMatrix")) {
1372
+ matrix = _util.Util.transform(matrix, subDict.getByName("FontMatrix"));
1145
1373
  }
1146
- subDict.setByName('FontMatrix', matrix);
1374
+
1375
+ subDict.setByName("FontMatrix", matrix);
1147
1376
  }
1148
1377
  }
1149
1378
  }
1150
- cff.topDict.setByName('charset', 0);
1379
+
1380
+ cff.topDict.setByName("charset", 0);
1151
1381
  var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
1152
1382
  output.add(compiled.output);
1153
1383
  var topDictTracker = compiled.trackers[0];
@@ -1155,31 +1385,35 @@ var CFFCompiler = function CFFCompilerClosure() {
1155
1385
  output.add(stringIndex);
1156
1386
  var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
1157
1387
  output.add(globalSubrIndex);
1158
- if (cff.encoding && cff.topDict.hasName('Encoding')) {
1388
+
1389
+ if (cff.encoding && cff.topDict.hasName("Encoding")) {
1159
1390
  if (cff.encoding.predefined) {
1160
- topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
1391
+ topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
1161
1392
  } else {
1162
1393
  var encoding = this.compileEncoding(cff.encoding);
1163
- topDictTracker.setEntryLocation('Encoding', [output.length], output);
1394
+ topDictTracker.setEntryLocation("Encoding", [output.length], output);
1164
1395
  output.add(encoding);
1165
1396
  }
1166
1397
  }
1167
- var charset = this.compileCharset(cff.charset);
1168
- topDictTracker.setEntryLocation('charset', [output.length], output);
1398
+
1399
+ var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
1400
+ topDictTracker.setEntryLocation("charset", [output.length], output);
1169
1401
  output.add(charset);
1170
1402
  var charStrings = this.compileCharStrings(cff.charStrings);
1171
- topDictTracker.setEntryLocation('CharStrings', [output.length], output);
1403
+ topDictTracker.setEntryLocation("CharStrings", [output.length], output);
1172
1404
  output.add(charStrings);
1405
+
1173
1406
  if (cff.isCIDFont) {
1174
- topDictTracker.setEntryLocation('FDSelect', [output.length], output);
1407
+ topDictTracker.setEntryLocation("FDSelect", [output.length], output);
1175
1408
  var fdSelect = this.compileFDSelect(cff.fdSelect);
1176
1409
  output.add(fdSelect);
1177
1410
  compiled = this.compileTopDicts(cff.fdArray, output.length, true);
1178
- topDictTracker.setEntryLocation('FDArray', [output.length], output);
1411
+ topDictTracker.setEntryLocation("FDArray", [output.length], output);
1179
1412
  output.add(compiled.output);
1180
1413
  var fontDictTrackers = compiled.trackers;
1181
1414
  this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
1182
1415
  }
1416
+
1183
1417
  this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
1184
1418
  output.add([0]);
1185
1419
  return output.data;
@@ -1188,51 +1422,61 @@ var CFFCompiler = function CFFCompilerClosure() {
1188
1422
  if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
1189
1423
  return this.encodeInteger(value);
1190
1424
  }
1425
+
1191
1426
  return this.encodeFloat(value);
1192
1427
  },
1193
1428
  encodeFloat: function CFFCompiler_encodeFloat(num) {
1194
1429
  var value = num.toString();
1195
1430
  var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
1431
+
1196
1432
  if (m) {
1197
- var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
1433
+ var epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
1198
1434
  value = (Math.round(num * epsilon) / epsilon).toString();
1199
1435
  }
1200
- var nibbles = '';
1436
+
1437
+ var nibbles = "";
1201
1438
  var i, ii;
1439
+
1202
1440
  for (i = 0, ii = value.length; i < ii; ++i) {
1203
1441
  var a = value[i];
1204
- if (a === 'e') {
1205
- nibbles += value[++i] === '-' ? 'c' : 'b';
1206
- } else if (a === '.') {
1207
- nibbles += 'a';
1208
- } else if (a === '-') {
1209
- nibbles += 'e';
1442
+
1443
+ if (a === "e") {
1444
+ nibbles += value[++i] === "-" ? "c" : "b";
1445
+ } else if (a === ".") {
1446
+ nibbles += "a";
1447
+ } else if (a === "-") {
1448
+ nibbles += "e";
1210
1449
  } else {
1211
1450
  nibbles += a;
1212
1451
  }
1213
1452
  }
1214
- nibbles += nibbles.length & 1 ? 'f' : 'ff';
1453
+
1454
+ nibbles += nibbles.length & 1 ? "f" : "ff";
1215
1455
  var out = [30];
1456
+
1216
1457
  for (i = 0, ii = nibbles.length; i < ii; i += 2) {
1217
1458
  out.push(parseInt(nibbles.substring(i, i + 2), 16));
1218
1459
  }
1460
+
1219
1461
  return out;
1220
1462
  },
1221
1463
  encodeInteger: function CFFCompiler_encodeInteger(value) {
1222
1464
  var code;
1465
+
1223
1466
  if (value >= -107 && value <= 107) {
1224
1467
  code = [value + 139];
1225
1468
  } else if (value >= 108 && value <= 1131) {
1226
1469
  value = value - 108;
1227
- code = [(value >> 8) + 247, value & 0xFF];
1470
+ code = [(value >> 8) + 247, value & 0xff];
1228
1471
  } else if (value >= -1131 && value <= -108) {
1229
1472
  value = -value - 108;
1230
- code = [(value >> 8) + 251, value & 0xFF];
1473
+ code = [(value >> 8) + 251, value & 0xff];
1231
1474
  } else if (value >= -32768 && value <= 32767) {
1232
- code = [0x1c, value >> 8 & 0xFF, value & 0xFF];
1475
+ code = [0x1c, value >> 8 & 0xff, value & 0xff];
1233
1476
  } else {
1234
- code = [0x1d, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF];
1477
+ code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
1235
1478
  }
1479
+
1236
1480
  return code;
1237
1481
  },
1238
1482
  compileHeader: function CFFCompiler_compileHeader(header) {
@@ -1240,43 +1484,55 @@ var CFFCompiler = function CFFCompilerClosure() {
1240
1484
  },
1241
1485
  compileNameIndex: function CFFCompiler_compileNameIndex(names) {
1242
1486
  var nameIndex = new CFFIndex();
1487
+
1243
1488
  for (var i = 0, ii = names.length; i < ii; ++i) {
1244
1489
  var name = names[i];
1245
1490
  var length = Math.min(name.length, 127);
1246
1491
  var sanitizedName = new Array(length);
1492
+
1247
1493
  for (var j = 0; j < length; j++) {
1248
1494
  var char = name[j];
1249
- if (char < '!' || char > '~' || char === '[' || char === ']' || char === '(' || char === ')' || char === '{' || char === '}' || char === '<' || char === '>' || char === '/' || char === '%') {
1250
- char = '_';
1495
+
1496
+ if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
1497
+ char = "_";
1251
1498
  }
1499
+
1252
1500
  sanitizedName[j] = char;
1253
1501
  }
1254
- sanitizedName = sanitizedName.join('');
1255
- if (sanitizedName === '') {
1256
- sanitizedName = 'Bad_Font_Name';
1502
+
1503
+ sanitizedName = sanitizedName.join("");
1504
+
1505
+ if (sanitizedName === "") {
1506
+ sanitizedName = "Bad_Font_Name";
1257
1507
  }
1508
+
1258
1509
  nameIndex.add((0, _util.stringToBytes)(sanitizedName));
1259
1510
  }
1511
+
1260
1512
  return this.compileIndex(nameIndex);
1261
1513
  },
1262
1514
  compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
1263
1515
  var fontDictTrackers = [];
1264
1516
  var fdArrayIndex = new CFFIndex();
1517
+
1265
1518
  for (var i = 0, ii = dicts.length; i < ii; ++i) {
1266
1519
  var fontDict = dicts[i];
1520
+
1267
1521
  if (removeCidKeys) {
1268
- fontDict.removeByName('CIDFontVersion');
1269
- fontDict.removeByName('CIDFontRevision');
1270
- fontDict.removeByName('CIDFontType');
1271
- fontDict.removeByName('CIDCount');
1272
- fontDict.removeByName('UIDBase');
1522
+ fontDict.removeByName("CIDFontVersion");
1523
+ fontDict.removeByName("CIDFontRevision");
1524
+ fontDict.removeByName("CIDFontType");
1525
+ fontDict.removeByName("CIDCount");
1526
+ fontDict.removeByName("UIDBase");
1273
1527
  }
1528
+
1274
1529
  var fontDictTracker = new CFFOffsetTracker();
1275
1530
  var fontDictData = this.compileDict(fontDict, fontDictTracker);
1276
1531
  fontDictTrackers.push(fontDictTracker);
1277
1532
  fdArrayIndex.add(fontDictData);
1278
1533
  fontDictTracker.offset(length);
1279
1534
  }
1535
+
1280
1536
  fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
1281
1537
  return {
1282
1538
  trackers: fontDictTrackers,
@@ -1287,21 +1543,26 @@ var CFFCompiler = function CFFCompilerClosure() {
1287
1543
  for (var i = 0, ii = dicts.length; i < ii; ++i) {
1288
1544
  var fontDict = dicts[i];
1289
1545
  var privateDict = fontDict.privateDict;
1290
- if (!privateDict || !fontDict.hasName('Private')) {
1291
- throw new _util.FormatError('There must be a private dictionary.');
1546
+
1547
+ if (!privateDict || !fontDict.hasName("Private")) {
1548
+ throw new _util.FormatError("There must be a private dictionary.");
1292
1549
  }
1550
+
1293
1551
  var privateDictTracker = new CFFOffsetTracker();
1294
1552
  var privateDictData = this.compileDict(privateDict, privateDictTracker);
1295
1553
  var outputLength = output.length;
1296
1554
  privateDictTracker.offset(outputLength);
1555
+
1297
1556
  if (!privateDictData.length) {
1298
1557
  outputLength = 0;
1299
1558
  }
1300
- trackers[i].setEntryLocation('Private', [privateDictData.length, outputLength], output);
1559
+
1560
+ trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
1301
1561
  output.add(privateDictData);
1302
- if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
1562
+
1563
+ if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
1303
1564
  var subrs = this.compileIndex(privateDict.subrsIndex);
1304
- privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
1565
+ privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
1305
1566
  output.add(subrs);
1306
1567
  }
1307
1568
  }
@@ -1309,57 +1570,76 @@ var CFFCompiler = function CFFCompilerClosure() {
1309
1570
  compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
1310
1571
  var out = [];
1311
1572
  var order = dict.order;
1573
+
1312
1574
  for (var i = 0; i < order.length; ++i) {
1313
1575
  var key = order[i];
1576
+
1314
1577
  if (!(key in dict.values)) {
1315
1578
  continue;
1316
1579
  }
1580
+
1317
1581
  var values = dict.values[key];
1318
1582
  var types = dict.types[key];
1583
+
1319
1584
  if (!Array.isArray(types)) {
1320
1585
  types = [types];
1321
1586
  }
1587
+
1322
1588
  if (!Array.isArray(values)) {
1323
1589
  values = [values];
1324
1590
  }
1591
+
1325
1592
  if (values.length === 0) {
1326
1593
  continue;
1327
1594
  }
1595
+
1328
1596
  for (var j = 0, jj = types.length; j < jj; ++j) {
1329
1597
  var type = types[j];
1330
1598
  var value = values[j];
1599
+
1331
1600
  switch (type) {
1332
- case 'num':
1333
- case 'sid':
1601
+ case "num":
1602
+ case "sid":
1334
1603
  out = out.concat(this.encodeNumber(value));
1335
1604
  break;
1336
- case 'offset':
1605
+
1606
+ case "offset":
1337
1607
  var name = dict.keyToNameMap[key];
1608
+
1338
1609
  if (!offsetTracker.isTracking(name)) {
1339
1610
  offsetTracker.track(name, out.length);
1340
1611
  }
1612
+
1341
1613
  out = out.concat([0x1d, 0, 0, 0, 0]);
1342
1614
  break;
1343
- case 'array':
1344
- case 'delta':
1615
+
1616
+ case "array":
1617
+ case "delta":
1345
1618
  out = out.concat(this.encodeNumber(value));
1619
+
1346
1620
  for (var k = 1, kk = values.length; k < kk; ++k) {
1347
1621
  out = out.concat(this.encodeNumber(values[k]));
1348
1622
  }
1623
+
1349
1624
  break;
1625
+
1350
1626
  default:
1351
- throw new _util.FormatError('Unknown data type of ' + type);
1627
+ throw new _util.FormatError(`Unknown data type of ${type}`);
1352
1628
  }
1353
1629
  }
1630
+
1354
1631
  out = out.concat(dict.opcodes[key]);
1355
1632
  }
1633
+
1356
1634
  return out;
1357
1635
  },
1358
1636
  compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
1359
1637
  var stringIndex = new CFFIndex();
1638
+
1360
1639
  for (var i = 0, ii = strings.length; i < ii; ++i) {
1361
1640
  stringIndex.add((0, _util.stringToBytes)(strings[i]));
1362
1641
  }
1642
+
1363
1643
  return this.compileIndex(stringIndex);
1364
1644
  },
1365
1645
  compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
@@ -1368,77 +1648,128 @@ var CFFCompiler = function CFFCompilerClosure() {
1368
1648
  },
1369
1649
  compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
1370
1650
  var charStringsIndex = new CFFIndex();
1651
+
1371
1652
  for (var i = 0; i < charStrings.count; i++) {
1372
1653
  var glyph = charStrings.get(i);
1654
+
1373
1655
  if (glyph.length === 0) {
1374
- charStringsIndex.add(new Uint8Array([0x8B, 0x0E]));
1656
+ charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
1375
1657
  continue;
1376
1658
  }
1659
+
1377
1660
  charStringsIndex.add(glyph);
1378
1661
  }
1662
+
1379
1663
  return this.compileIndex(charStringsIndex);
1380
1664
  },
1381
- compileCharset: function CFFCompiler_compileCharset(charset) {
1382
- var length = 1 + (this.cff.charStrings.count - 1) * 2;
1383
- var out = new Uint8Array(length);
1665
+ compileCharset: function CFFCompiler_compileCharset(charset, numGlyphs, strings, isCIDFont) {
1666
+ let out;
1667
+ const numGlyphsLessNotDef = numGlyphs - 1;
1668
+
1669
+ if (isCIDFont) {
1670
+ out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xff, numGlyphsLessNotDef & 0xff]);
1671
+ } else {
1672
+ const length = 1 + numGlyphsLessNotDef * 2;
1673
+ out = new Uint8Array(length);
1674
+ out[0] = 0;
1675
+ let charsetIndex = 0;
1676
+ const numCharsets = charset.charset.length;
1677
+ let warned = false;
1678
+
1679
+ for (let i = 1; i < out.length; i += 2) {
1680
+ let sid = 0;
1681
+
1682
+ if (charsetIndex < numCharsets) {
1683
+ const name = charset.charset[charsetIndex++];
1684
+ sid = strings.getSID(name);
1685
+
1686
+ if (sid === -1) {
1687
+ sid = 0;
1688
+
1689
+ if (!warned) {
1690
+ warned = true;
1691
+ (0, _util.warn)(`Couldn't find ${name} in CFF strings`);
1692
+ }
1693
+ }
1694
+ }
1695
+
1696
+ out[i] = sid >> 8 & 0xff;
1697
+ out[i + 1] = sid & 0xff;
1698
+ }
1699
+ }
1700
+
1384
1701
  return this.compileTypedArray(out);
1385
1702
  },
1386
1703
  compileEncoding: function CFFCompiler_compileEncoding(encoding) {
1387
1704
  return this.compileTypedArray(encoding.raw);
1388
1705
  },
1389
1706
  compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
1390
- var format = fdSelect.format;
1391
- var out = void 0,
1392
- i = void 0;
1707
+ const format = fdSelect.format;
1708
+ let out, i;
1709
+
1393
1710
  switch (format) {
1394
1711
  case 0:
1395
1712
  out = new Uint8Array(1 + fdSelect.fdSelect.length);
1396
1713
  out[0] = format;
1714
+
1397
1715
  for (i = 0; i < fdSelect.fdSelect.length; i++) {
1398
1716
  out[i + 1] = fdSelect.fdSelect[i];
1399
1717
  }
1718
+
1400
1719
  break;
1720
+
1401
1721
  case 3:
1402
- var start = 0;
1403
- var lastFD = fdSelect.fdSelect[0];
1404
- var ranges = [format, 0, 0, start >> 8 & 0xFF, start & 0xFF, lastFD];
1722
+ const start = 0;
1723
+ let lastFD = fdSelect.fdSelect[0];
1724
+ const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
1725
+
1405
1726
  for (i = 1; i < fdSelect.fdSelect.length; i++) {
1406
- var currentFD = fdSelect.fdSelect[i];
1727
+ const currentFD = fdSelect.fdSelect[i];
1728
+
1407
1729
  if (currentFD !== lastFD) {
1408
- ranges.push(i >> 8 & 0xFF, i & 0xFF, currentFD);
1730
+ ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
1409
1731
  lastFD = currentFD;
1410
1732
  }
1411
1733
  }
1412
- var numRanges = (ranges.length - 3) / 3;
1413
- ranges[1] = numRanges >> 8 & 0xFF;
1414
- ranges[2] = numRanges & 0xFF;
1415
- ranges.push(i >> 8 & 0xFF, i & 0xFF);
1734
+
1735
+ const numRanges = (ranges.length - 3) / 3;
1736
+ ranges[1] = numRanges >> 8 & 0xff;
1737
+ ranges[2] = numRanges & 0xff;
1738
+ ranges.push(i >> 8 & 0xff, i & 0xff);
1416
1739
  out = new Uint8Array(ranges);
1417
1740
  break;
1418
1741
  }
1742
+
1419
1743
  return this.compileTypedArray(out);
1420
1744
  },
1421
1745
  compileTypedArray: function CFFCompiler_compileTypedArray(data) {
1422
1746
  var out = [];
1747
+
1423
1748
  for (var i = 0, ii = data.length; i < ii; ++i) {
1424
1749
  out[i] = data[i];
1425
1750
  }
1751
+
1426
1752
  return out;
1427
1753
  },
1428
1754
  compileIndex: function CFFCompiler_compileIndex(index, trackers) {
1429
1755
  trackers = trackers || [];
1430
1756
  var objects = index.objects;
1431
1757
  var count = objects.length;
1758
+
1432
1759
  if (count === 0) {
1433
1760
  return [0, 0, 0];
1434
1761
  }
1435
- var data = [count >> 8 & 0xFF, count & 0xff];
1762
+
1763
+ var data = [count >> 8 & 0xff, count & 0xff];
1436
1764
  var lastOffset = 1,
1437
1765
  i;
1766
+
1438
1767
  for (i = 0; i < count; ++i) {
1439
1768
  lastOffset += objects[i].length;
1440
1769
  }
1770
+
1441
1771
  var offsetSize;
1772
+
1442
1773
  if (lastOffset < 0x100) {
1443
1774
  offsetSize = 1;
1444
1775
  } else if (lastOffset < 0x10000) {
@@ -1448,43 +1779,40 @@ var CFFCompiler = function CFFCompilerClosure() {
1448
1779
  } else {
1449
1780
  offsetSize = 4;
1450
1781
  }
1782
+
1451
1783
  data.push(offsetSize);
1452
1784
  var relativeOffset = 1;
1785
+
1453
1786
  for (i = 0; i < count + 1; i++) {
1454
1787
  if (offsetSize === 1) {
1455
- data.push(relativeOffset & 0xFF);
1788
+ data.push(relativeOffset & 0xff);
1456
1789
  } else if (offsetSize === 2) {
1457
- data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
1790
+ data.push(relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
1458
1791
  } else if (offsetSize === 3) {
1459
- data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
1792
+ data.push(relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
1460
1793
  } else {
1461
- data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
1794
+ data.push(relativeOffset >>> 24 & 0xff, relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
1462
1795
  }
1796
+
1463
1797
  if (objects[i]) {
1464
1798
  relativeOffset += objects[i].length;
1465
1799
  }
1466
1800
  }
1801
+
1467
1802
  for (i = 0; i < count; i++) {
1468
1803
  if (trackers[i]) {
1469
1804
  trackers[i].offset(data.length);
1470
1805
  }
1806
+
1471
1807
  for (var j = 0, jj = objects[i].length; j < jj; j++) {
1472
1808
  data.push(objects[i][j]);
1473
1809
  }
1474
1810
  }
1811
+
1475
1812
  return data;
1476
1813
  }
1477
1814
  };
1478
1815
  return CFFCompiler;
1479
1816
  }();
1480
- exports.CFFStandardStrings = CFFStandardStrings;
1481
- exports.CFFParser = CFFParser;
1482
- exports.CFF = CFF;
1483
- exports.CFFHeader = CFFHeader;
1484
- exports.CFFStrings = CFFStrings;
1485
- exports.CFFIndex = CFFIndex;
1486
- exports.CFFCharset = CFFCharset;
1487
- exports.CFFTopDict = CFFTopDict;
1488
- exports.CFFPrivateDict = CFFPrivateDict;
1489
- exports.CFFCompiler = CFFCompiler;
1490
- exports.CFFFDSelect = CFFFDSelect;
1817
+
1818
+ exports.CFFCompiler = CFFCompiler;