@syncfusion/ej2-pdf 1.0.23 → 23.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (518) hide show
  1. package/.eslintrc.json +260 -0
  2. package/.gitleaksignore +1 -0
  3. package/CHANGELOG.md +28 -0
  4. package/README.md +17 -0
  5. package/dist/ej2-pdf.umd.min.js +4 -14
  6. package/dist/ej2-pdf.umd.min.js.map +1 -11
  7. package/dist/es6/ej2-pdf.es2015.js +48372 -0
  8. package/dist/es6/ej2-pdf.es2015.js.map +1 -0
  9. package/dist/es6/ej2-pdf.es5.js +50250 -0
  10. package/dist/es6/ej2-pdf.es5.js.map +1 -0
  11. package/dist/global/ej2-pdf.min.js +11 -0
  12. package/dist/global/ej2-pdf.min.js.map +1 -0
  13. package/dist/global/index.d.ts +14 -0
  14. package/index.js +4 -8
  15. package/license +10 -3
  16. package/package.json +58 -16
  17. package/pdf.d.ts +4 -0
  18. package/pdf.js +4 -0
  19. package/src/global.js +1 -0
  20. package/src/index.d.ts +45 -98
  21. package/src/index.js +45 -96
  22. package/src/pdf/core/annotations/annotation-collection.d.ts +289 -0
  23. package/src/pdf/core/annotations/annotation-collection.js +755 -0
  24. package/src/pdf/core/annotations/annotation.d.ts +5865 -0
  25. package/src/pdf/core/annotations/annotation.js +14195 -0
  26. package/src/pdf/core/annotations/index.d.ts +4 -0
  27. package/src/pdf/core/annotations/index.js +4 -0
  28. package/src/pdf/core/annotations/pdf-appearance.d.ts +102 -0
  29. package/src/pdf/core/annotations/pdf-appearance.js +124 -0
  30. package/src/pdf/core/annotations/pdf-paddings.d.ts +8 -0
  31. package/src/pdf/core/annotations/pdf-paddings.js +22 -0
  32. package/src/pdf/core/base-stream.d.ts +86 -0
  33. package/src/pdf/core/base-stream.js +332 -0
  34. package/src/pdf/core/content-parser.d.ts +38 -0
  35. package/src/pdf/core/content-parser.js +359 -0
  36. package/src/pdf/core/decode-stream.d.ts +21 -0
  37. package/src/pdf/core/decode-stream.js +120 -0
  38. package/src/pdf/core/decrypt-stream.d.ts +11 -0
  39. package/src/pdf/core/decrypt-stream.js +53 -0
  40. package/src/pdf/core/enumerator.d.ts +1668 -0
  41. package/src/pdf/core/enumerator.js +1717 -0
  42. package/src/pdf/core/flate-stream.d.ts +13 -0
  43. package/src/pdf/core/flate-stream.js +329 -0
  44. package/src/pdf/core/fonts/index.d.ts +7 -0
  45. package/{dist/es6/implementation/graphics → src/pdf/core}/fonts/index.js +3 -4
  46. package/src/pdf/core/fonts/pdf-font-metrics.d.ts +66 -0
  47. package/src/pdf/core/fonts/pdf-font-metrics.js +192 -0
  48. package/src/pdf/core/fonts/pdf-standard-font.d.ts +1023 -0
  49. package/src/pdf/core/fonts/pdf-standard-font.js +1682 -0
  50. package/src/pdf/core/fonts/pdf-string-format.d.ts +236 -0
  51. package/src/pdf/core/fonts/pdf-string-format.js +213 -0
  52. package/src/pdf/core/fonts/string-layouter.d.ts +68 -0
  53. package/src/pdf/core/fonts/string-layouter.js +437 -0
  54. package/src/pdf/core/fonts/ttf-reader.d.ts +167 -0
  55. package/src/pdf/core/fonts/ttf-reader.js +1150 -0
  56. package/src/pdf/core/fonts/ttf-table.d.ts +132 -0
  57. package/src/pdf/core/fonts/ttf-table.js +74 -0
  58. package/src/pdf/core/fonts/unicode-true-type-font.d.ts +50 -0
  59. package/src/pdf/core/fonts/unicode-true-type-font.js +289 -0
  60. package/src/pdf/core/form/field.d.ts +3011 -0
  61. package/src/pdf/core/form/field.js +6828 -0
  62. package/src/pdf/core/form/form.d.ts +279 -0
  63. package/src/pdf/core/form/form.js +782 -0
  64. package/src/pdf/core/form/index.d.ts +2 -0
  65. package/src/pdf/core/form/index.js +2 -0
  66. package/src/pdf/core/graphics/images/image-decoder.d.ts +38 -0
  67. package/src/pdf/core/graphics/images/image-decoder.js +227 -0
  68. package/src/{implementation → pdf/core}/graphics/images/index.d.ts +0 -5
  69. package/{dist/es6/implementation → src/pdf/core}/graphics/images/index.js +0 -1
  70. package/src/pdf/core/graphics/images/pdf-bitmap.d.ts +73 -0
  71. package/src/pdf/core/graphics/images/pdf-bitmap.js +68 -0
  72. package/src/pdf/core/graphics/images/pdf-image.d.ts +201 -0
  73. package/src/pdf/core/graphics/images/pdf-image.js +201 -0
  74. package/src/pdf/core/graphics/index.d.ts +10 -0
  75. package/src/pdf/core/graphics/index.js +10 -0
  76. package/src/pdf/core/graphics/pdf-graphics.d.ts +956 -0
  77. package/src/pdf/core/graphics/pdf-graphics.js +1860 -0
  78. package/src/pdf/core/graphics/pdf-path.d.ts +34 -0
  79. package/src/pdf/core/graphics/pdf-path.js +177 -0
  80. package/src/pdf/core/graphics/pdf-stream-writer.d.ts +56 -0
  81. package/src/pdf/core/graphics/pdf-stream-writer.js +231 -0
  82. package/src/pdf/core/graphics/pdf-template.d.ts +79 -0
  83. package/src/pdf/core/graphics/pdf-template.js +100 -0
  84. package/src/pdf/core/graphics/rightToLeft/bidirectional.d.ts +69 -0
  85. package/src/pdf/core/graphics/rightToLeft/bidirectional.js +831 -0
  86. package/src/pdf/core/graphics/rightToLeft/index.d.ts +3 -0
  87. package/src/pdf/core/graphics/rightToLeft/index.js +3 -0
  88. package/src/pdf/core/graphics/rightToLeft/text-renderer.d.ts +13 -0
  89. package/src/pdf/core/graphics/rightToLeft/text-renderer.js +116 -0
  90. package/src/pdf/core/graphics/rightToLeft/text-shape.d.ts +48 -0
  91. package/src/pdf/core/graphics/rightToLeft/text-shape.js +289 -0
  92. package/src/pdf/core/import-export/fdf-document.d.ts +37 -0
  93. package/src/pdf/core/import-export/fdf-document.js +667 -0
  94. package/src/pdf/core/import-export/index.d.ts +5 -0
  95. package/src/pdf/core/import-export/index.js +5 -0
  96. package/src/pdf/core/import-export/json-document.d.ts +47 -0
  97. package/src/pdf/core/import-export/json-document.js +1547 -0
  98. package/src/pdf/core/import-export/xfdf-document.d.ts +146 -0
  99. package/src/pdf/core/import-export/xfdf-document.js +2920 -0
  100. package/src/pdf/core/import-export/xml-document.d.ts +14 -0
  101. package/src/pdf/core/import-export/xml-document.js +166 -0
  102. package/src/pdf/core/import-export/xml-writer.d.ts +69 -0
  103. package/src/pdf/core/import-export/xml-writer.js +494 -0
  104. package/src/pdf/core/pdf-catalog.d.ts +18 -0
  105. package/src/pdf/core/pdf-catalog.js +166 -0
  106. package/src/pdf/core/pdf-cross-reference.d.ts +80 -0
  107. package/src/pdf/core/pdf-cross-reference.js +1049 -0
  108. package/src/pdf/core/pdf-document.d.ts +821 -0
  109. package/src/pdf/core/pdf-document.js +1022 -0
  110. package/src/pdf/core/pdf-file-structure.d.ts +54 -0
  111. package/src/pdf/core/pdf-file-structure.js +65 -0
  112. package/src/pdf/core/pdf-outline.d.ts +362 -0
  113. package/src/pdf/core/pdf-outline.js +860 -0
  114. package/src/pdf/core/pdf-page.d.ts +589 -0
  115. package/src/pdf/core/pdf-page.js +1049 -0
  116. package/src/pdf/core/pdf-parser.d.ts +62 -0
  117. package/src/pdf/core/pdf-parser.js +1035 -0
  118. package/src/pdf/core/pdf-primitives.d.ts +87 -0
  119. package/src/pdf/core/pdf-primitives.js +305 -0
  120. package/src/pdf/core/predictor-stream.d.ts +15 -0
  121. package/src/pdf/core/predictor-stream.js +214 -0
  122. package/src/pdf/core/security/encryptor.d.ts +140 -0
  123. package/src/pdf/core/security/encryptor.js +1616 -0
  124. package/src/pdf/core/security/index.d.ts +1 -0
  125. package/src/pdf/core/security/index.js +1 -0
  126. package/src/pdf/core/utils.d.ts +686 -0
  127. package/src/pdf/core/utils.js +3625 -0
  128. package/src/pdf/index.d.ts +44 -0
  129. package/src/pdf/index.js +44 -0
  130. package/tslint.json +111 -0
  131. package/ReadMe.md +0 -13
  132. package/dist/es6/implementation/actions/action.js +0 -44
  133. package/dist/es6/implementation/actions/index.js +0 -2
  134. package/dist/es6/implementation/actions/uri-action.js +0 -38
  135. package/dist/es6/implementation/annotations/action-link-annotation.js +0 -29
  136. package/dist/es6/implementation/annotations/annotation-collection.js +0 -93
  137. package/dist/es6/implementation/annotations/annotation.js +0 -156
  138. package/dist/es6/implementation/annotations/document-link-annotation.js +0 -48
  139. package/dist/es6/implementation/annotations/index.js +0 -7
  140. package/dist/es6/implementation/annotations/link-annotation.js +0 -31
  141. package/dist/es6/implementation/annotations/pdf-text-web-link.js +0 -178
  142. package/dist/es6/implementation/annotations/uri-annotation.js +0 -64
  143. package/dist/es6/implementation/collections/dictionary.js +0 -71
  144. package/dist/es6/implementation/collections/index.js +0 -3
  145. package/dist/es6/implementation/collections/object-object-pair/dictionary.js +0 -84
  146. package/dist/es6/implementation/collections/object-object-pair/index.js +0 -1
  147. package/dist/es6/implementation/collections/utils.js +0 -8
  148. package/dist/es6/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -17
  149. package/dist/es6/implementation/document/automatic-fields/automatic-field-info.js +0 -68
  150. package/dist/es6/implementation/document/automatic-fields/automatic-field.js +0 -145
  151. package/dist/es6/implementation/document/automatic-fields/composite-field.js +0 -61
  152. package/dist/es6/implementation/document/automatic-fields/index.js +0 -7
  153. package/dist/es6/implementation/document/automatic-fields/multiple-value-field.js +0 -36
  154. package/dist/es6/implementation/document/automatic-fields/page-count-field.js +0 -53
  155. package/dist/es6/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -91
  156. package/dist/es6/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
  157. package/dist/es6/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -34
  158. package/dist/es6/implementation/document/automatic-fields/single-value-field.js +0 -47
  159. package/dist/es6/implementation/document/index.js +0 -11
  160. package/dist/es6/implementation/document/pdf-catalog.js +0 -38
  161. package/dist/es6/implementation/document/pdf-document-base.js +0 -71
  162. package/dist/es6/implementation/document/pdf-document-template.js +0 -204
  163. package/dist/es6/implementation/document/pdf-document.js +0 -175
  164. package/dist/es6/implementation/drawing/index.js +0 -1
  165. package/dist/es6/implementation/drawing/pdf-drawing.js +0 -80
  166. package/dist/es6/implementation/general/enum.js +0 -6
  167. package/dist/es6/implementation/general/index.js +0 -3
  168. package/dist/es6/implementation/general/pdf-cache-collection.js +0 -24
  169. package/dist/es6/implementation/general/pdf-collection.js +0 -26
  170. package/dist/es6/implementation/general/pdf-destination.js +0 -107
  171. package/dist/es6/implementation/graphics/brushes/index.js +0 -2
  172. package/dist/es6/implementation/graphics/brushes/pdf-brush.js +0 -6
  173. package/dist/es6/implementation/graphics/brushes/pdf-solid-brush.js +0 -53
  174. package/dist/es6/implementation/graphics/constants.js +0 -11
  175. package/dist/es6/implementation/graphics/enum.js +0 -100
  176. package/dist/es6/implementation/graphics/figures/base/element-layouter.js +0 -154
  177. package/dist/es6/implementation/graphics/figures/base/graphics-element.js +0 -18
  178. package/dist/es6/implementation/graphics/figures/base/index.js +0 -3
  179. package/dist/es6/implementation/graphics/figures/base/pdf-shape-element.js +0 -32
  180. package/dist/es6/implementation/graphics/figures/base/shape-layouter.js +0 -55
  181. package/dist/es6/implementation/graphics/figures/base/text-layouter.js +0 -123
  182. package/dist/es6/implementation/graphics/figures/enum.js +0 -11
  183. package/dist/es6/implementation/graphics/figures/index.js +0 -5
  184. package/dist/es6/implementation/graphics/figures/layout-element.js +0 -41
  185. package/dist/es6/implementation/graphics/figures/pdf-template.js +0 -110
  186. package/dist/es6/implementation/graphics/figures/text-element.js +0 -298
  187. package/dist/es6/implementation/graphics/fonts/enum.js +0 -45
  188. package/dist/es6/implementation/graphics/fonts/pdf-font-metrics.js +0 -122
  189. package/dist/es6/implementation/graphics/fonts/pdf-font.js +0 -159
  190. package/dist/es6/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -357
  191. package/dist/es6/implementation/graphics/fonts/pdf-standard-font.js +0 -124
  192. package/dist/es6/implementation/graphics/fonts/pdf-string-format.js +0 -239
  193. package/dist/es6/implementation/graphics/fonts/string-layouter.js +0 -335
  194. package/dist/es6/implementation/graphics/fonts/string-tokenizer.js +0 -162
  195. package/dist/es6/implementation/graphics/images/byte-array.js +0 -82
  196. package/dist/es6/implementation/graphics/images/image-decoder.js +0 -167
  197. package/dist/es6/implementation/graphics/images/pdf-bitmap.js +0 -41
  198. package/dist/es6/implementation/graphics/images/pdf-image.js +0 -68
  199. package/dist/es6/implementation/graphics/index.js +0 -20
  200. package/dist/es6/implementation/graphics/pdf-color.js +0 -205
  201. package/dist/es6/implementation/graphics/pdf-graphics.js +0 -1034
  202. package/dist/es6/implementation/graphics/pdf-margins.js +0 -75
  203. package/dist/es6/implementation/graphics/pdf-pen.js +0 -180
  204. package/dist/es6/implementation/graphics/pdf-resources.js +0 -223
  205. package/dist/es6/implementation/graphics/pdf-transformation-matrix.js +0 -134
  206. package/dist/es6/implementation/graphics/pdf-transparency.js +0 -22
  207. package/dist/es6/implementation/graphics/unit-convertor.js +0 -33
  208. package/dist/es6/implementation/index.js +0 -85
  209. package/dist/es6/implementation/input-output/cross-table.js +0 -6
  210. package/dist/es6/implementation/input-output/enum.js +0 -5
  211. package/dist/es6/implementation/input-output/index.js +0 -8
  212. package/dist/es6/implementation/input-output/pdf-cross-table.js +0 -346
  213. package/dist/es6/implementation/input-output/pdf-dictionary-properties.js +0 -60
  214. package/dist/es6/implementation/input-output/pdf-main-object-collection.js +0 -115
  215. package/dist/es6/implementation/input-output/pdf-operators.js +0 -75
  216. package/dist/es6/implementation/input-output/pdf-stream-writer.js +0 -364
  217. package/dist/es6/implementation/input-output/pdf-writer.js +0 -44
  218. package/dist/es6/implementation/pages/enum.js +0 -51
  219. package/dist/es6/implementation/pages/index.js +0 -13
  220. package/dist/es6/implementation/pages/page-added-event-arguments.js +0 -19
  221. package/dist/es6/implementation/pages/pdf-document-page-collection.js +0 -120
  222. package/dist/es6/implementation/pages/pdf-page-base.js +0 -104
  223. package/dist/es6/implementation/pages/pdf-page-layer-collection.js +0 -115
  224. package/dist/es6/implementation/pages/pdf-page-layer.js +0 -160
  225. package/dist/es6/implementation/pages/pdf-page-settings.js +0 -126
  226. package/dist/es6/implementation/pages/pdf-page-size.js +0 -36
  227. package/dist/es6/implementation/pages/pdf-page-template-element.js +0 -510
  228. package/dist/es6/implementation/pages/pdf-page.js +0 -130
  229. package/dist/es6/implementation/pages/pdf-section-collection.js +0 -95
  230. package/dist/es6/implementation/pages/pdf-section-page-collection.js +0 -30
  231. package/dist/es6/implementation/pages/pdf-section-templates.js +0 -71
  232. package/dist/es6/implementation/pages/pdf-section.js +0 -388
  233. package/dist/es6/implementation/primitives/index.js +0 -8
  234. package/dist/es6/implementation/primitives/pdf-array.js +0 -199
  235. package/dist/es6/implementation/primitives/pdf-boolean.js +0 -66
  236. package/dist/es6/implementation/primitives/pdf-dictionary.js +0 -220
  237. package/dist/es6/implementation/primitives/pdf-name.js +0 -102
  238. package/dist/es6/implementation/primitives/pdf-number.js +0 -94
  239. package/dist/es6/implementation/primitives/pdf-reference.js +0 -195
  240. package/dist/es6/implementation/primitives/pdf-stream.js +0 -149
  241. package/dist/es6/implementation/primitives/pdf-string.js +0 -143
  242. package/dist/es6/implementation/structured-elements/grid/index.js +0 -1
  243. package/dist/es6/implementation/structured-elements/grid/pdf-grid-cell.js +0 -512
  244. package/dist/es6/implementation/structured-elements/grid/pdf-grid-column.js +0 -125
  245. package/dist/es6/implementation/structured-elements/grid/pdf-grid-row.js +0 -244
  246. package/dist/es6/implementation/structured-elements/grid/pdf-grid.js +0 -989
  247. package/dist/es6/implementation/structured-elements/grid/styles/index.js +0 -2
  248. package/dist/es6/implementation/structured-elements/grid/styles/pdf-borders.js +0 -145
  249. package/dist/es6/implementation/structured-elements/grid/styles/style.js +0 -267
  250. package/dist/es6/implementation/structured-elements/index.js +0 -1
  251. package/dist/es6/implementation/structured-elements/tables/light-tables/enum.js +0 -5
  252. package/dist/es6/index.js +0 -89
  253. package/dist/es6/interfaces/i-pdf-cache.js +0 -1
  254. package/dist/es6/interfaces/i-pdf-changable.js +0 -1
  255. package/dist/es6/interfaces/i-pdf-primitives.js +0 -1
  256. package/dist/es6/interfaces/i-pdf-wrapper.js +0 -1
  257. package/dist/es6/interfaces/i-pdf-writer.js +0 -1
  258. package/dist/es6/interfaces/index.js +0 -1
  259. package/dist/global/ej2-pdf-export.js +0 -15979
  260. package/implementation.d.ts +0 -4
  261. package/implementation.js +0 -8
  262. package/interfaces.d.ts +0 -4
  263. package/interfaces.js +0 -4
  264. package/src/implementation/actions/action.d.ts +0 -50
  265. package/src/implementation/actions/action.js +0 -44
  266. package/src/implementation/actions/index.d.ts +0 -6
  267. package/src/implementation/actions/index.js +0 -9
  268. package/src/implementation/actions/uri-action.d.ts +0 -33
  269. package/src/implementation/actions/uri-action.js +0 -39
  270. package/src/implementation/annotations/action-link-annotation.d.ts +0 -30
  271. package/src/implementation/annotations/action-link-annotation.js +0 -32
  272. package/src/implementation/annotations/annotation-collection.d.ts +0 -77
  273. package/src/implementation/annotations/annotation-collection.js +0 -91
  274. package/src/implementation/annotations/annotation.d.ts +0 -152
  275. package/src/implementation/annotations/annotation.js +0 -146
  276. package/src/implementation/annotations/document-link-annotation.d.ts +0 -89
  277. package/src/implementation/annotations/document-link-annotation.js +0 -51
  278. package/src/implementation/annotations/index.d.ts +0 -11
  279. package/src/implementation/annotations/index.js +0 -14
  280. package/src/implementation/annotations/link-annotation.d.ts +0 -23
  281. package/src/implementation/annotations/link-annotation.js +0 -33
  282. package/src/implementation/annotations/pdf-text-web-link.d.ts +0 -118
  283. package/src/implementation/annotations/pdf-text-web-link.js +0 -173
  284. package/src/implementation/annotations/uri-annotation.d.ts +0 -48
  285. package/src/implementation/annotations/uri-annotation.js +0 -65
  286. package/src/implementation/collections/dictionary.d.ts +0 -76
  287. package/src/implementation/collections/dictionary.js +0 -74
  288. package/src/implementation/collections/index.d.ts +0 -7
  289. package/src/implementation/collections/index.js +0 -10
  290. package/src/implementation/collections/object-object-pair/dictionary.d.ts +0 -62
  291. package/src/implementation/collections/object-object-pair/dictionary.js +0 -88
  292. package/src/implementation/collections/object-object-pair/index.d.ts +0 -5
  293. package/src/implementation/collections/object-object-pair/index.js +0 -8
  294. package/src/implementation/collections/utils.d.ts +0 -27
  295. package/src/implementation/collections/utils.js +0 -13
  296. package/src/implementation/document/automatic-fields/automatic-field-info-collection.d.ts +0 -31
  297. package/src/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -21
  298. package/src/implementation/document/automatic-fields/automatic-field-info.d.ts +0 -67
  299. package/src/implementation/document/automatic-fields/automatic-field-info.js +0 -70
  300. package/src/implementation/document/automatic-fields/automatic-field.d.ts +0 -41
  301. package/src/implementation/document/automatic-fields/automatic-field.js +0 -143
  302. package/src/implementation/document/automatic-fields/composite-field.d.ts +0 -46
  303. package/src/implementation/document/automatic-fields/composite-field.js +0 -64
  304. package/src/implementation/document/automatic-fields/index.d.ts +0 -11
  305. package/src/implementation/document/automatic-fields/index.js +0 -14
  306. package/src/implementation/document/automatic-fields/multiple-value-field.d.ts +0 -18
  307. package/src/implementation/document/automatic-fields/multiple-value-field.js +0 -35
  308. package/src/implementation/document/automatic-fields/page-count-field.d.ts +0 -44
  309. package/src/implementation/document/automatic-fields/page-count-field.js +0 -53
  310. package/src/implementation/document/automatic-fields/pdf-numbers-convertor.d.ts +0 -53
  311. package/src/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -94
  312. package/src/implementation/document/automatic-fields/pdf-page-number-field.d.ts +0 -51
  313. package/src/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
  314. package/src/implementation/document/automatic-fields/pdf-template-value-pair.d.ts +0 -38
  315. package/src/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -38
  316. package/src/implementation/document/automatic-fields/single-value-field.d.ts +0 -15
  317. package/src/implementation/document/automatic-fields/single-value-field.js +0 -46
  318. package/src/implementation/document/index.d.ts +0 -15
  319. package/src/implementation/document/index.js +0 -18
  320. package/src/implementation/document/pdf-catalog.d.ts +0 -32
  321. package/src/implementation/document/pdf-catalog.js +0 -38
  322. package/src/implementation/document/pdf-document-base.d.ts +0 -117
  323. package/src/implementation/document/pdf-document-base.js +0 -72
  324. package/src/implementation/document/pdf-document-template.d.ts +0 -166
  325. package/src/implementation/document/pdf-document-template.js +0 -207
  326. package/src/implementation/document/pdf-document.d.ts +0 -206
  327. package/src/implementation/document/pdf-document.js +0 -166
  328. package/src/implementation/drawing/index.d.ts +0 -5
  329. package/src/implementation/drawing/index.js +0 -8
  330. package/src/implementation/drawing/pdf-drawing.d.ts +0 -93
  331. package/src/implementation/drawing/pdf-drawing.js +0 -84
  332. package/src/implementation/general/enum.d.ts +0 -21
  333. package/src/implementation/general/enum.js +0 -10
  334. package/src/implementation/general/index.d.ts +0 -7
  335. package/src/implementation/general/index.js +0 -10
  336. package/src/implementation/general/pdf-cache-collection.d.ts +0 -33
  337. package/src/implementation/general/pdf-cache-collection.js +0 -27
  338. package/src/implementation/general/pdf-collection.d.ts +0 -26
  339. package/src/implementation/general/pdf-collection.js +0 -30
  340. package/src/implementation/general/pdf-destination.d.ts +0 -103
  341. package/src/implementation/general/pdf-destination.js +0 -103
  342. package/src/implementation/graphics/brushes/index.d.ts +0 -6
  343. package/src/implementation/graphics/brushes/index.js +0 -9
  344. package/src/implementation/graphics/brushes/pdf-brush.d.ts +0 -55
  345. package/src/implementation/graphics/brushes/pdf-brush.js +0 -10
  346. package/src/implementation/graphics/brushes/pdf-solid-brush.d.ts +0 -77
  347. package/src/implementation/graphics/brushes/pdf-solid-brush.js +0 -54
  348. package/src/implementation/graphics/constants.d.ts +0 -31
  349. package/src/implementation/graphics/constants.js +0 -15
  350. package/src/implementation/graphics/enum.d.ts +0 -392
  351. package/src/implementation/graphics/enum.js +0 -104
  352. package/src/implementation/graphics/figures/base/element-layouter.d.ts +0 -160
  353. package/src/implementation/graphics/figures/base/element-layouter.js +0 -156
  354. package/src/implementation/graphics/figures/base/graphics-element.d.ts +0 -16
  355. package/src/implementation/graphics/figures/base/graphics-element.js +0 -22
  356. package/src/implementation/graphics/figures/base/index.d.ts +0 -7
  357. package/src/implementation/graphics/figures/base/index.js +0 -10
  358. package/src/implementation/graphics/figures/base/pdf-shape-element.d.ts +0 -28
  359. package/src/implementation/graphics/figures/base/pdf-shape-element.js +0 -34
  360. package/src/implementation/graphics/figures/base/shape-layouter.d.ts +0 -80
  361. package/src/implementation/graphics/figures/base/shape-layouter.js +0 -57
  362. package/src/implementation/graphics/figures/base/text-layouter.d.ts +0 -107
  363. package/src/implementation/graphics/figures/base/text-layouter.js +0 -121
  364. package/src/implementation/graphics/figures/enum.d.ts +0 -37
  365. package/src/implementation/graphics/figures/enum.js +0 -15
  366. package/src/implementation/graphics/figures/index.d.ts +0 -9
  367. package/src/implementation/graphics/figures/index.js +0 -12
  368. package/src/implementation/graphics/figures/layout-element.d.ts +0 -57
  369. package/src/implementation/graphics/figures/layout-element.js +0 -43
  370. package/src/implementation/graphics/figures/pdf-template.d.ts +0 -113
  371. package/src/implementation/graphics/figures/pdf-template.js +0 -106
  372. package/src/implementation/graphics/figures/text-element.d.ts +0 -213
  373. package/src/implementation/graphics/figures/text-element.js +0 -289
  374. package/src/implementation/graphics/fonts/enum.d.ts +0 -179
  375. package/src/implementation/graphics/fonts/enum.js +0 -49
  376. package/src/implementation/graphics/fonts/index.d.ts +0 -12
  377. package/src/implementation/graphics/fonts/index.js +0 -15
  378. package/src/implementation/graphics/fonts/pdf-font-metrics.d.ts +0 -160
  379. package/src/implementation/graphics/fonts/pdf-font-metrics.js +0 -123
  380. package/src/implementation/graphics/fonts/pdf-font.d.ts +0 -187
  381. package/src/implementation/graphics/fonts/pdf-font.js +0 -158
  382. package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.d.ts +0 -301
  383. package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -359
  384. package/src/implementation/graphics/fonts/pdf-standard-font.d.ts +0 -143
  385. package/src/implementation/graphics/fonts/pdf-standard-font.js +0 -121
  386. package/src/implementation/graphics/fonts/pdf-string-format.d.ts +0 -319
  387. package/src/implementation/graphics/fonts/pdf-string-format.js +0 -241
  388. package/src/implementation/graphics/fonts/string-layouter.d.ts +0 -255
  389. package/src/implementation/graphics/fonts/string-layouter.js +0 -336
  390. package/src/implementation/graphics/fonts/string-tokenizer.d.ts +0 -107
  391. package/src/implementation/graphics/fonts/string-tokenizer.js +0 -166
  392. package/src/implementation/graphics/images/byte-array.d.ts +0 -68
  393. package/src/implementation/graphics/images/byte-array.js +0 -86
  394. package/src/implementation/graphics/images/image-decoder.d.ts +0 -227
  395. package/src/implementation/graphics/images/image-decoder.js +0 -164
  396. package/src/implementation/graphics/images/index.js +0 -11
  397. package/src/implementation/graphics/images/pdf-bitmap.d.ts +0 -90
  398. package/src/implementation/graphics/images/pdf-bitmap.js +0 -41
  399. package/src/implementation/graphics/images/pdf-image.d.ts +0 -88
  400. package/src/implementation/graphics/images/pdf-image.js +0 -69
  401. package/src/implementation/graphics/index.d.ts +0 -24
  402. package/src/implementation/graphics/index.js +0 -27
  403. package/src/implementation/graphics/pdf-color.d.ts +0 -170
  404. package/src/implementation/graphics/pdf-color.js +0 -204
  405. package/src/implementation/graphics/pdf-graphics.d.ts +0 -1085
  406. package/src/implementation/graphics/pdf-graphics.js +0 -1017
  407. package/src/implementation/graphics/pdf-margins.d.ts +0 -82
  408. package/src/implementation/graphics/pdf-margins.js +0 -79
  409. package/src/implementation/graphics/pdf-pen.d.ts +0 -237
  410. package/src/implementation/graphics/pdf-pen.js +0 -181
  411. package/src/implementation/graphics/pdf-resources.d.ts +0 -147
  412. package/src/implementation/graphics/pdf-resources.js +0 -215
  413. package/src/implementation/graphics/pdf-transformation-matrix.d.ts +0 -143
  414. package/src/implementation/graphics/pdf-transformation-matrix.js +0 -136
  415. package/src/implementation/graphics/pdf-transparency.d.ts +0 -34
  416. package/src/implementation/graphics/pdf-transparency.js +0 -22
  417. package/src/implementation/graphics/unit-convertor.d.ts +0 -72
  418. package/src/implementation/graphics/unit-convertor.js +0 -37
  419. package/src/implementation/index.d.ts +0 -89
  420. package/src/implementation/index.js +0 -92
  421. package/src/implementation/input-output/cross-table.d.ts +0 -21
  422. package/src/implementation/input-output/cross-table.js +0 -10
  423. package/src/implementation/input-output/enum.d.ts +0 -16
  424. package/src/implementation/input-output/enum.js +0 -9
  425. package/src/implementation/input-output/index.d.ts +0 -12
  426. package/src/implementation/input-output/index.js +0 -15
  427. package/src/implementation/input-output/pdf-cross-table.d.ts +0 -249
  428. package/src/implementation/input-output/pdf-cross-table.js +0 -340
  429. package/src/implementation/input-output/pdf-dictionary-properties.d.ts +0 -283
  430. package/src/implementation/input-output/pdf-dictionary-properties.js +0 -64
  431. package/src/implementation/input-output/pdf-main-object-collection.d.ts +0 -120
  432. package/src/implementation/input-output/pdf-main-object-collection.js +0 -117
  433. package/src/implementation/input-output/pdf-operators.d.ts +0 -352
  434. package/src/implementation/input-output/pdf-operators.js +0 -79
  435. package/src/implementation/input-output/pdf-stream-writer.d.ts +0 -314
  436. package/src/implementation/input-output/pdf-stream-writer.js +0 -363
  437. package/src/implementation/input-output/pdf-writer.d.ts +0 -68
  438. package/src/implementation/input-output/pdf-writer.js +0 -48
  439. package/src/implementation/pages/enum.d.ts +0 -201
  440. package/src/implementation/pages/enum.js +0 -55
  441. package/src/implementation/pages/index.d.ts +0 -17
  442. package/src/implementation/pages/index.js +0 -20
  443. package/src/implementation/pages/page-added-event-arguments.d.ts +0 -30
  444. package/src/implementation/pages/page-added-event-arguments.js +0 -23
  445. package/src/implementation/pages/pdf-document-page-collection.d.ts +0 -92
  446. package/src/implementation/pages/pdf-document-page-collection.js +0 -121
  447. package/src/implementation/pages/pdf-page-base.d.ts +0 -121
  448. package/src/implementation/pages/pdf-page-base.js +0 -104
  449. package/src/implementation/pages/pdf-page-layer-collection.d.ts +0 -99
  450. package/src/implementation/pages/pdf-page-layer-collection.js +0 -113
  451. package/src/implementation/pages/pdf-page-layer.d.ts +0 -160
  452. package/src/implementation/pages/pdf-page-layer.js +0 -159
  453. package/src/implementation/pages/pdf-page-settings.d.ts +0 -111
  454. package/src/implementation/pages/pdf-page-settings.js +0 -126
  455. package/src/implementation/pages/pdf-page-size.d.ts +0 -159
  456. package/src/implementation/pages/pdf-page-size.js +0 -39
  457. package/src/implementation/pages/pdf-page-template-element.d.ts +0 -230
  458. package/src/implementation/pages/pdf-page-template-element.js +0 -509
  459. package/src/implementation/pages/pdf-page.d.ts +0 -153
  460. package/src/implementation/pages/pdf-page.js +0 -127
  461. package/src/implementation/pages/pdf-section-collection.d.ts +0 -109
  462. package/src/implementation/pages/pdf-section-collection.js +0 -91
  463. package/src/implementation/pages/pdf-section-page-collection.d.ts +0 -41
  464. package/src/implementation/pages/pdf-section-page-collection.js +0 -34
  465. package/src/implementation/pages/pdf-section-templates.d.ts +0 -64
  466. package/src/implementation/pages/pdf-section-templates.js +0 -74
  467. package/src/implementation/pages/pdf-section.d.ts +0 -319
  468. package/src/implementation/pages/pdf-section.js +0 -379
  469. package/src/implementation/primitives/index.d.ts +0 -12
  470. package/src/implementation/primitives/index.js +0 -15
  471. package/src/implementation/primitives/pdf-array.d.ts +0 -186
  472. package/src/implementation/primitives/pdf-array.js +0 -201
  473. package/src/implementation/primitives/pdf-boolean.d.ts +0 -84
  474. package/src/implementation/primitives/pdf-boolean.js +0 -70
  475. package/src/implementation/primitives/pdf-dictionary.d.ts +0 -311
  476. package/src/implementation/primitives/pdf-dictionary.js +0 -220
  477. package/src/implementation/primitives/pdf-name.d.ts +0 -121
  478. package/src/implementation/primitives/pdf-name.js +0 -106
  479. package/src/implementation/primitives/pdf-number.d.ts +0 -104
  480. package/src/implementation/primitives/pdf-number.js +0 -98
  481. package/src/implementation/primitives/pdf-reference.d.ts +0 -222
  482. package/src/implementation/primitives/pdf-reference.js +0 -192
  483. package/src/implementation/primitives/pdf-stream.d.ts +0 -111
  484. package/src/implementation/primitives/pdf-stream.js +0 -146
  485. package/src/implementation/primitives/pdf-string.d.ts +0 -212
  486. package/src/implementation/primitives/pdf-string.js +0 -147
  487. package/src/implementation/structured-elements/grid/index.d.ts +0 -0
  488. package/src/implementation/structured-elements/grid/index.js +0 -1
  489. package/src/implementation/structured-elements/grid/pdf-grid-cell.d.ts +0 -248
  490. package/src/implementation/structured-elements/grid/pdf-grid-cell.js +0 -504
  491. package/src/implementation/structured-elements/grid/pdf-grid-column.d.ts +0 -108
  492. package/src/implementation/structured-elements/grid/pdf-grid-column.js +0 -127
  493. package/src/implementation/structured-elements/grid/pdf-grid-row.d.ts +0 -207
  494. package/src/implementation/structured-elements/grid/pdf-grid-row.js +0 -246
  495. package/src/implementation/structured-elements/grid/pdf-grid.d.ts +0 -678
  496. package/src/implementation/structured-elements/grid/pdf-grid.js +0 -982
  497. package/src/implementation/structured-elements/grid/styles/index.d.ts +0 -5
  498. package/src/implementation/structured-elements/grid/styles/index.js +0 -9
  499. package/src/implementation/structured-elements/grid/styles/pdf-borders.d.ts +0 -126
  500. package/src/implementation/structured-elements/grid/styles/pdf-borders.js +0 -146
  501. package/src/implementation/structured-elements/grid/styles/style.d.ts +0 -250
  502. package/src/implementation/structured-elements/grid/styles/style.js +0 -269
  503. package/src/implementation/structured-elements/index.d.ts +0 -0
  504. package/src/implementation/structured-elements/index.js +0 -1
  505. package/src/implementation/structured-elements/tables/light-tables/enum.d.ts +0 -16
  506. package/src/implementation/structured-elements/tables/light-tables/enum.js +0 -9
  507. package/src/interfaces/i-pdf-cache.d.ts +0 -23
  508. package/src/interfaces/i-pdf-cache.js +0 -4
  509. package/src/interfaces/i-pdf-changable.d.ts +0 -17
  510. package/src/interfaces/i-pdf-changable.js +0 -4
  511. package/src/interfaces/i-pdf-primitives.d.ts +0 -45
  512. package/src/interfaces/i-pdf-primitives.js +0 -4
  513. package/src/interfaces/i-pdf-wrapper.d.ts +0 -13
  514. package/src/interfaces/i-pdf-wrapper.js +0 -4
  515. package/src/interfaces/i-pdf-writer.d.ts +0 -29
  516. package/src/interfaces/i-pdf-writer.js +0 -4
  517. package/src/interfaces/index.d.ts +0 -9
  518. package/src/interfaces/index.js +0 -4
@@ -0,0 +1,1150 @@
1
+ import { _TrueTypeTableInfo, _TrueTypeHorizontalHeaderTable, _TrueTypeNameTable, _TrueTypeHeadTable, _TrueTypeOS2Table, _TrueTypePostTable, _TrueTypeCmapSubTable, _TrueTypeCmapTable, _TrueTypeAppleCmapSubTable, _TrueTypeMicrosoftCmapSubTable, _TrueTypeTrimmedCmapSubTable } from './ttf-table';
2
+ import { Dictionary } from '../pdf-primitives';
3
+ import { _StringTokenizer } from './string-layouter';
4
+ import { _TrueTypeCmapFormat, _TrueTypeCmapEncoding, _TrueTypePlatformID, _TrueTypeMicrosoftEncodingID, _TrueTypeMacintoshEncodingID, _TrueTypeCompositeGlyphFlag } from '../../core/enumerator';
5
+ var _TrueTypeReader = /** @class */ (function () {
6
+ function _TrueTypeReader(fontData) {
7
+ this._int32Size = 4;
8
+ this._isFont = false;
9
+ this._isMacTtf = false;
10
+ this._isMacFont = false;
11
+ this._missedGlyphs = 0;
12
+ this._tableNames = ['cvt ', 'fpgm', 'glyf', 'head', 'hhea', 'hmtx', 'loca', 'maxp', 'prep'];
13
+ this._entrySelectors = [0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4];
14
+ this._fontData = fontData;
15
+ this._initialize();
16
+ }
17
+ Object.defineProperty(_TrueTypeReader.prototype, "macintosh", {
18
+ get: function () {
19
+ if (this._macintoshDictionary === null || typeof this._macintoshDictionary === 'undefined') {
20
+ this._macintoshDictionary = new Dictionary();
21
+ }
22
+ return this._macintoshDictionary;
23
+ },
24
+ enumerable: true,
25
+ configurable: true
26
+ });
27
+ Object.defineProperty(_TrueTypeReader.prototype, "_microsoft", {
28
+ get: function () {
29
+ if (this._microsoftDictionary === null || typeof this._microsoftDictionary === 'undefined') {
30
+ this._microsoftDictionary = new Dictionary();
31
+ }
32
+ return this._microsoftDictionary;
33
+ },
34
+ enumerable: true,
35
+ configurable: true
36
+ });
37
+ Object.defineProperty(_TrueTypeReader.prototype, "_macintoshGlyphs", {
38
+ get: function () {
39
+ if (this._internalMacintoshGlyphs === null || typeof this._internalMacintoshGlyphs === 'undefined') {
40
+ this._internalMacintoshGlyphs = new Dictionary();
41
+ }
42
+ return this._internalMacintoshGlyphs;
43
+ },
44
+ enumerable: true,
45
+ configurable: true
46
+ });
47
+ Object.defineProperty(_TrueTypeReader.prototype, "_microsoftGlyphs", {
48
+ get: function () {
49
+ if (this._internalMicrosoftGlyphs === null || typeof this._internalMicrosoftGlyphs === 'undefined') {
50
+ this._internalMicrosoftGlyphs = new Dictionary();
51
+ }
52
+ return this._internalMicrosoftGlyphs;
53
+ },
54
+ enumerable: true,
55
+ configurable: true
56
+ });
57
+ _TrueTypeReader.prototype._initialize = function () {
58
+ if (typeof this._metrics === 'undefined' || this._metrics === null) {
59
+ this._metrics = new _TrueTypeMetrics();
60
+ }
61
+ this._readFontDictionary();
62
+ var nameTable = this._readNameTable();
63
+ var headTable = this._readHeadTable();
64
+ this._initializeFontName(nameTable);
65
+ this._metrics._macStyle = headTable._macStyle;
66
+ };
67
+ _TrueTypeReader.prototype._readFontDictionary = function () {
68
+ this._offset = 0;
69
+ this._check();
70
+ var table = this._readInt16(this._offset);
71
+ this._readInt16(this._offset);
72
+ this._readInt16(this._offset);
73
+ this._readInt16(this._offset);
74
+ if (typeof this._tableDirectory === 'undefined' || this._tableDirectory === null) {
75
+ this._tableDirectory = new Dictionary();
76
+ }
77
+ for (var i = 0; i < table; ++i) {
78
+ var table_1 = new _TrueTypeTableInfo();
79
+ var tableKey = this._readString(this._int32Size);
80
+ table_1._checksum = this._readInt32(this._offset);
81
+ table_1._offset = this._readInt32(this._offset);
82
+ table_1._length = this._readInt32(this._offset);
83
+ this._tableDirectory.setValue(tableKey, table_1);
84
+ }
85
+ this._lowestPosition = this._offset;
86
+ if (!this._isFont) {
87
+ this._fixOffsets();
88
+ }
89
+ };
90
+ _TrueTypeReader.prototype._fixOffsets = function () {
91
+ var minOffset = Number.MAX_VALUE;
92
+ var tableKeys = this._tableDirectory.keys();
93
+ for (var i = 0; i < tableKeys.length; i++) {
94
+ var value = this._tableDirectory.getValue(tableKeys[Number.parseInt(i.toString(), 10)]);
95
+ var offset = value._offset;
96
+ if (minOffset > offset) {
97
+ minOffset = offset;
98
+ if (minOffset <= this._lowestPosition) {
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ var shift = minOffset - this._lowestPosition;
104
+ if (shift !== 0) {
105
+ var table = new Dictionary();
106
+ for (var i = 0; i < tableKeys.length; i++) {
107
+ var value = this._tableDirectory.getValue(tableKeys[Number.parseInt(i.toString(), 10)]);
108
+ value._offset -= shift;
109
+ table.setValue(tableKeys[Number.parseInt(i.toString(), 10)], value);
110
+ }
111
+ this._tableDirectory = table;
112
+ }
113
+ };
114
+ _TrueTypeReader.prototype._check = function () {
115
+ var version = this._readInt32(this._offset);
116
+ this._isMacTtf = (version === 0x74727565) ? true : false;
117
+ if (version !== 0x10000 && version !== 0x74727565 && version !== 0x4f54544f) {
118
+ this._isFont = true;
119
+ this._offset = 0;
120
+ var fontTag = this._readString(4);
121
+ if (fontTag !== 'ttcf') {
122
+ throw new Error('Can not read TTF font data');
123
+ }
124
+ this._offset += 4;
125
+ var ttcIdentificationNumber = this._readInt32(this._offset);
126
+ if (ttcIdentificationNumber < 0) {
127
+ throw new Error('Can not read TTF font data');
128
+ }
129
+ this._offset = this._readInt32(this._offset);
130
+ version = this._readInt32(this._offset);
131
+ }
132
+ return version;
133
+ };
134
+ _TrueTypeReader.prototype._readNameTable = function () {
135
+ var tableInfo = this._getTable('name');
136
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
137
+ this._offset = tableInfo._offset;
138
+ }
139
+ var table = new _TrueTypeNameTable();
140
+ table._formatSelector = this._readUInt16(this._offset);
141
+ table._recordsCount = this._readUInt16(this._offset);
142
+ table._offset = this._readUInt16(this._offset);
143
+ table._nameRecords = [];
144
+ var recordSize = 12;
145
+ var position = this._offset;
146
+ for (var i = 0; i < table._recordsCount; i++) {
147
+ this._offset = position;
148
+ var record = new _TrueTypeNameRecord();
149
+ record._platformID = this._readUInt16(this._offset);
150
+ record._encodingID = this._readUInt16(this._offset);
151
+ record._languageID = this._readUInt16(this._offset);
152
+ record._nameID = this._readUInt16(this._offset);
153
+ record._length = this._readUInt16(this._offset);
154
+ record._offset = this._readUInt16(this._offset);
155
+ this._offset = tableInfo._offset + table._offset + record._offset;
156
+ var unicode = (record._platformID === 0 || record._platformID === 3);
157
+ record._name = this._readString(record._length, unicode);
158
+ table._nameRecords[Number.parseInt(i.toString(), 10)] = record;
159
+ position += recordSize;
160
+ }
161
+ return table;
162
+ };
163
+ _TrueTypeReader.prototype._readHeadTable = function () {
164
+ var tableInfo = this._getTable('head');
165
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
166
+ this._offset = tableInfo._offset;
167
+ }
168
+ var table = new _TrueTypeHeadTable();
169
+ table._version = this._readFixed(this._offset);
170
+ table._fontRevision = this._readFixed(this._offset);
171
+ table._checkSumAdjustment = this._readUInt32(this._offset);
172
+ table._magicNumber = this._readUInt32(this._offset);
173
+ table._flags = this._readUInt16(this._offset);
174
+ table._unitsPerEm = this._readUInt16(this._offset);
175
+ table._created = this._readInt64(this._offset);
176
+ table._modified = this._readInt64(this._offset);
177
+ table._xMin = this._readInt16(this._offset);
178
+ table._yMin = this._readInt16(this._offset);
179
+ table._xMax = this._readInt16(this._offset);
180
+ table._yMax = this._readInt16(this._offset);
181
+ table._macStyle = this._readUInt16(this._offset);
182
+ table._lowestReadableSize = this._readUInt16(this._offset);
183
+ table._fontDirectionHint = this._readInt16(this._offset);
184
+ table._indexToLocalFormat = this._readInt16(this._offset);
185
+ table._glyphDataFormat = this._readInt16(this._offset);
186
+ return table;
187
+ };
188
+ _TrueTypeReader.prototype._readHorizontalHeaderTable = function () {
189
+ var tableInfo = this._getTable('hhea');
190
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
191
+ this._offset = tableInfo._offset;
192
+ }
193
+ var table = new _TrueTypeHorizontalHeaderTable();
194
+ table._version = this._readFixed(this._offset);
195
+ table._ascender = this._readInt16(this._offset);
196
+ table._descender = this._readInt16(this._offset);
197
+ table._lineGap = this._readInt16(this._offset);
198
+ table._advanceWidthMax = this._readUInt16(this._offset);
199
+ table._minLeftSideBearing = this._readInt16(this._offset);
200
+ table._minRightSideBearing = this._readInt16(this._offset);
201
+ table._xMaxExtent = this._readInt16(this._offset);
202
+ table._caretSlopeRise = this._readInt16(this._offset);
203
+ table._caretSlopeRun = this._readInt16(this._offset);
204
+ this._offset += 10;
205
+ table._metricDataFormat = this._readInt16(this._offset);
206
+ table._numberOfHMetrics = this._readUInt16(this._offset);
207
+ return table;
208
+ };
209
+ _TrueTypeReader.prototype._readOS2Table = function () {
210
+ var tableInfo = this._getTable('OS/2');
211
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
212
+ this._offset = tableInfo._offset;
213
+ }
214
+ var table = new _TrueTypeOS2Table();
215
+ table._version = this._readUInt16(this._offset);
216
+ table._xAvgCharWidth = this._readInt16(this._offset);
217
+ table._usWeightClass = this._readUInt16(this._offset);
218
+ table._usWidthClass = this._readUInt16(this._offset);
219
+ table._fsType = this._readInt16(this._offset);
220
+ table._ySubscriptXSize = this._readInt16(this._offset);
221
+ table._ySubscriptYSize = this._readInt16(this._offset);
222
+ table._ySubscriptXOffset = this._readInt16(this._offset);
223
+ table._ySubscriptYOffset = this._readInt16(this._offset);
224
+ table._ySuperscriptXSize = this._readInt16(this._offset);
225
+ table._ySuperscriptYSize = this._readInt16(this._offset);
226
+ table._ySuperscriptXOffset = this._readInt16(this._offset);
227
+ table._ySuperscriptYOffset = this._readInt16(this._offset);
228
+ table._yStrikeoutSize = this._readInt16(this._offset);
229
+ table._yStrikeoutPosition = this._readInt16(this._offset);
230
+ table._sFamilyClass = this._readInt16(this._offset);
231
+ table._panose = this._readBytes(10);
232
+ table._ulUnicodeRange1 = this._readUInt32(this._offset);
233
+ table._ulUnicodeRange2 = this._readUInt32(this._offset);
234
+ table._ulUnicodeRange3 = this._readUInt32(this._offset);
235
+ table._ulUnicodeRange4 = this._readUInt32(this._offset);
236
+ table._vendorIdentifier = this._readBytes(4);
237
+ table._fsSelection = this._readUInt16(this._offset);
238
+ table._usFirstCharIndex = this._readUInt16(this._offset);
239
+ table._usLastCharIndex = this._readUInt16(this._offset);
240
+ table._sTypoAscender = this._readInt16(this._offset);
241
+ table._sTypoDescender = this._readInt16(this._offset);
242
+ table._sTypoLineGap = this._readInt16(this._offset);
243
+ table._usWinAscent = this._readUInt16(this._offset);
244
+ table._usWinDescent = this._readUInt16(this._offset);
245
+ table._ulCodePageRange1 = this._readUInt32(this._offset);
246
+ table._ulCodePageRange2 = this._readUInt32(this._offset);
247
+ if (table._version > 1) {
248
+ table._sxHeight = this._readInt16(this._offset);
249
+ table._sCapHeight = this._readInt16(this._offset);
250
+ table._usDefaultChar = this._readUInt16(this._offset);
251
+ table._usBreakChar = this._readUInt16(this._offset);
252
+ table._usMaxContext = this._readUInt16(this._offset);
253
+ }
254
+ else {
255
+ table._sxHeight = 0;
256
+ table._sCapHeight = 0;
257
+ table._usDefaultChar = 0;
258
+ table._usBreakChar = 0;
259
+ table._usMaxContext = 0;
260
+ }
261
+ return table;
262
+ };
263
+ _TrueTypeReader.prototype._readPostTable = function () {
264
+ var tableInfo = this._getTable('post');
265
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
266
+ this._offset = tableInfo._offset;
267
+ }
268
+ var table = new _TrueTypePostTable();
269
+ table._formatType = this._readFixed(this._offset);
270
+ table._italicAngle = this._readFixed(this._offset);
271
+ table._underlinePosition = this._readInt16(this._offset);
272
+ table._underlineThickness = this._readInt16(this._offset);
273
+ table._isFixedPitch = this._readUInt32(this._offset);
274
+ table._minType42 = this._readUInt32(this._offset);
275
+ table._maxType42 = this._readUInt32(this._offset);
276
+ table._minType1 = this._readUInt32(this._offset);
277
+ table._maxType1 = this._readUInt32(this._offset);
278
+ return table;
279
+ };
280
+ _TrueTypeReader.prototype._readWidthTable = function (glyphCount, unitsPerEm) {
281
+ var tableInfo = this._getTable('hmtx');
282
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
283
+ this._offset = tableInfo._offset;
284
+ }
285
+ var width = [];
286
+ for (var i = 0; i < glyphCount; i++) {
287
+ var glyph = new _TrueTypeLongHorMetric();
288
+ glyph._advanceWidth = this._readUInt16(this._offset);
289
+ glyph._lsb = this._readInt16(this._offset);
290
+ var glyphWidth = glyph._advanceWidth * 1000 / unitsPerEm;
291
+ width.push(Math.floor(glyphWidth));
292
+ }
293
+ return width;
294
+ };
295
+ _TrueTypeReader.prototype._readCmapTable = function () {
296
+ var tableInfo = this._getTable('cmap');
297
+ if (typeof tableInfo._offset !== 'undefined' && tableInfo._offset !== null) {
298
+ this._offset = tableInfo._offset;
299
+ }
300
+ var table = new _TrueTypeCmapTable();
301
+ table._version = this._readUInt16(this._offset);
302
+ table._tablesCount = this._readUInt16(this._offset);
303
+ var position = this._offset;
304
+ var subTables = [];
305
+ for (var i = 0; i < table._tablesCount; i++) {
306
+ this._offset = position;
307
+ var subTable = new _TrueTypeCmapSubTable();
308
+ subTable._platformID = this._readUInt16(this._offset);
309
+ subTable._encodingID = this._readUInt16(this._offset);
310
+ subTable._offset = this._readUInt32(this._offset);
311
+ position = this._offset;
312
+ this._readCmapSubTable(subTable);
313
+ subTables[Number.parseInt(i.toString(), 10)] = subTable;
314
+ }
315
+ return subTables;
316
+ };
317
+ _TrueTypeReader.prototype._readCmapSubTable = function (subTable) {
318
+ var tableInfo = this._getTable('cmap');
319
+ this._offset = tableInfo._offset + subTable._offset;
320
+ var format = this._readUInt16(this._offset);
321
+ var encoding = this._getCmapEncoding(subTable._platformID, subTable._encodingID);
322
+ if (encoding !== _TrueTypeCmapEncoding.unknown) {
323
+ switch (format) {
324
+ case _TrueTypeCmapFormat.apple:
325
+ this._readAppleCmapTable(subTable, encoding);
326
+ break;
327
+ case _TrueTypeCmapFormat.microsoft:
328
+ this._readMicrosoftCmapTable(subTable, encoding);
329
+ break;
330
+ case _TrueTypeCmapFormat.trimmed:
331
+ this._readTrimmedCmapTable(subTable, encoding);
332
+ break;
333
+ }
334
+ }
335
+ };
336
+ _TrueTypeReader.prototype._readAppleCmapTable = function (subTable, encoding) {
337
+ var tableInfo = this._getTable('cmap');
338
+ this._offset = tableInfo._offset + subTable._offset;
339
+ var table = new _TrueTypeAppleCmapSubTable();
340
+ table._format = this._readUInt16(this._offset);
341
+ table._length = this._readUInt16(this._offset);
342
+ table._version = this._readUInt16(this._offset);
343
+ if (this._maxMacIndex === null || typeof this._maxMacIndex === 'undefined') {
344
+ this._maxMacIndex = 0;
345
+ }
346
+ for (var i = 0; i < 256; ++i) {
347
+ var glyphInfo = new _TrueTypeGlyph();
348
+ glyphInfo._index = this._readByte(this._offset);
349
+ glyphInfo._width = this._getWidth(glyphInfo._index);
350
+ glyphInfo._charCode = i;
351
+ this.macintosh.setValue(i, glyphInfo);
352
+ this._addGlyph(glyphInfo, encoding);
353
+ this._maxMacIndex = Math.max(i, this._maxMacIndex);
354
+ }
355
+ };
356
+ _TrueTypeReader.prototype._readMicrosoftCmapTable = function (subTable, encoding) {
357
+ var tableInfo = this._getTable('cmap');
358
+ this._offset = tableInfo._offset + subTable._offset;
359
+ var collection = (encoding === _TrueTypeCmapEncoding.unicode) ? this._microsoft
360
+ : this.macintosh;
361
+ var table = new _TrueTypeMicrosoftCmapSubTable();
362
+ table._format = this._readUInt16(this._offset);
363
+ table._length = this._readUInt16(this._offset);
364
+ table._version = this._readUInt16(this._offset);
365
+ table._segCountX2 = this._readUInt16(this._offset);
366
+ table._searchRange = this._readUInt16(this._offset);
367
+ table._entrySelector = this._readUInt16(this._offset);
368
+ table._rangeShift = this._readUInt16(this._offset);
369
+ var segCount = table._segCountX2 / 2;
370
+ table._endCount = this._readUShortArray(segCount);
371
+ table._reservedPad = this._readUInt16(this._offset);
372
+ table._startCount = this._readUShortArray(segCount);
373
+ table._idDelta = this._readUShortArray(segCount);
374
+ table._idRangeOffset = this._readUShortArray(segCount);
375
+ var length = (table._length / 2 - 8) - (segCount * 4);
376
+ table._glyphID = this._readUShortArray(length);
377
+ var codeOffset = 0;
378
+ var index = 0;
379
+ for (var j = 0; j < segCount; j++) {
380
+ for (var k = table._startCount[Number.parseInt(j.toString(), 10)]; k <=
381
+ table._endCount[Number.parseInt(j.toString(), 10)] && k !== 65535; k++) {
382
+ if (table._idRangeOffset[Number.parseInt(j.toString(), 10)] === 0) {
383
+ codeOffset = (k + table._idDelta[Number.parseInt(j.toString(), 10)]) & 65535;
384
+ }
385
+ else {
386
+ index = j + table._idRangeOffset[Number.parseInt(j.toString(), 10)] / 2 - segCount +
387
+ k - table._startCount[Number.parseInt(j.toString(), 10)];
388
+ if (index >= table._glyphID.length) {
389
+ continue;
390
+ }
391
+ codeOffset = (table._glyphID[Number.parseInt(index.toString(), 10)] +
392
+ table._idDelta[Number.parseInt(j.toString(), 10)]) & 65535;
393
+ }
394
+ var glyph = new _TrueTypeGlyph();
395
+ glyph._index = codeOffset;
396
+ glyph._width = this._getWidth(glyph._index);
397
+ var id = (encoding === _TrueTypeCmapEncoding.symbol) ? ((k & 0xff00) === 0xf000 ? k & 0xff : k) : k;
398
+ glyph._charCode = id;
399
+ collection.setValue(id, glyph);
400
+ this._addGlyph(glyph, encoding);
401
+ }
402
+ }
403
+ };
404
+ _TrueTypeReader.prototype._readTrimmedCmapTable = function (subTable, encoding) {
405
+ var tableInfo = this._getTable('cmap');
406
+ this._offset = tableInfo._offset + subTable._offset;
407
+ var table = new _TrueTypeTrimmedCmapSubTable();
408
+ table._format = this._readUInt16(this._offset);
409
+ table._length = this._readUInt16(this._offset);
410
+ table._version = this._readUInt16(this._offset);
411
+ table._firstCode = this._readUInt16(this._offset);
412
+ table._entryCount = this._readUInt16(this._offset);
413
+ for (var i = 0; i < table._entryCount; ++i) {
414
+ var glyphInfo = new _TrueTypeGlyph();
415
+ glyphInfo._index = this._readUInt16(this._offset);
416
+ glyphInfo._width = this._getWidth(glyphInfo._index);
417
+ glyphInfo._charCode = i + table._firstCode;
418
+ this.macintosh.setValue(i, glyphInfo);
419
+ this._addGlyph(glyphInfo, encoding);
420
+ this._maxMacIndex = Math.max(i, this._maxMacIndex);
421
+ }
422
+ };
423
+ _TrueTypeReader.prototype._initializeFontName = function (nameTable) {
424
+ for (var i = 0; i < nameTable._recordsCount; i++) {
425
+ var record = nameTable._nameRecords[Number.parseInt(i.toString(), 10)];
426
+ if (record._nameID === 1) {
427
+ this._metrics._fontFamily = record._name;
428
+ }
429
+ else if (record._nameID === 6) {
430
+ this._metrics._postScriptName = record._name;
431
+ }
432
+ if (this._metrics._fontFamily !== null && this._metrics._fontFamily !== 'undefined' &&
433
+ this._metrics._postScriptName !== null && this._metrics._postScriptName !== 'undefined') {
434
+ break;
435
+ }
436
+ }
437
+ };
438
+ _TrueTypeReader.prototype._getTable = function (name) {
439
+ var table = new _TrueTypeTableInfo();
440
+ var obj;
441
+ if (this._tableDirectory.containsKey(name)) {
442
+ obj = this._tableDirectory.getValue(name);
443
+ }
444
+ if (obj !== null && typeof obj !== 'undefined') {
445
+ table = obj;
446
+ }
447
+ return table;
448
+ };
449
+ _TrueTypeReader.prototype._getWidth = function (glyphCode) {
450
+ glyphCode = (glyphCode < this._width.length) ? glyphCode : this._width.length - 1;
451
+ return this._width[Number.parseInt(glyphCode.toString(), 10)];
452
+ };
453
+ _TrueTypeReader.prototype._getCmapEncoding = function (platformID, encodingID) {
454
+ var format = _TrueTypeCmapEncoding.unknown;
455
+ if (platformID === _TrueTypePlatformID.microsoft &&
456
+ encodingID === _TrueTypeMicrosoftEncodingID.undefined) {
457
+ format = _TrueTypeCmapEncoding.symbol;
458
+ }
459
+ else if (platformID === _TrueTypePlatformID.microsoft
460
+ && encodingID === _TrueTypeMicrosoftEncodingID.unicode) {
461
+ format = _TrueTypeCmapEncoding.unicode;
462
+ }
463
+ else if (platformID === _TrueTypePlatformID.macintosh
464
+ && encodingID === _TrueTypeMacintoshEncodingID.roman) {
465
+ format = _TrueTypeCmapEncoding.macintosh;
466
+ }
467
+ return format;
468
+ };
469
+ _TrueTypeReader.prototype._addGlyph = function (glyph, encoding) {
470
+ var collection = null;
471
+ switch (encoding) {
472
+ case _TrueTypeCmapEncoding.unicode:
473
+ collection = this._microsoftGlyphs;
474
+ break;
475
+ case _TrueTypeCmapEncoding.macintosh:
476
+ case _TrueTypeCmapEncoding.symbol:
477
+ collection = this._macintoshGlyphs;
478
+ break;
479
+ }
480
+ collection.setValue(glyph._index, glyph);
481
+ };
482
+ _TrueTypeReader.prototype._initializeMetrics = function (nameTable, headTable, horizontalHeadTable, os2Table, postTable, cmapTables) {
483
+ this._initializeFontName(nameTable);
484
+ var bSymbol = false;
485
+ for (var i = 0; i < cmapTables.length; i++) {
486
+ var subTable = cmapTables[Number.parseInt(i.toString(), 10)];
487
+ var encoding = this._getCmapEncoding(subTable._platformID, subTable._encodingID);
488
+ if (encoding === _TrueTypeCmapEncoding.symbol) {
489
+ bSymbol = true;
490
+ break;
491
+ }
492
+ }
493
+ this._metrics._isSymbol = bSymbol;
494
+ this._metrics._macStyle = headTable._macStyle;
495
+ this._metrics._isFixedPitch = (postTable._isFixedPitch !== 0);
496
+ this._metrics._italicAngle = postTable._italicAngle;
497
+ var factor = 1000 / headTable._unitsPerEm;
498
+ this._metrics._winAscent = os2Table._sTypoAscender * factor;
499
+ this._metrics._macAscent = horizontalHeadTable._ascender * factor;
500
+ this._metrics._capHeight = (os2Table._sCapHeight !== 0) ? os2Table._sCapHeight : 0.7 * headTable._unitsPerEm * factor;
501
+ this._metrics._winDescent = os2Table._sTypoDescender * factor;
502
+ this._metrics._macDescent = horizontalHeadTable._descender * factor;
503
+ this._metrics._leading = (os2Table._sTypoAscender - os2Table._sTypoDescender + os2Table._sTypoLineGap) * factor;
504
+ this._metrics._lineGap = Math.ceil(horizontalHeadTable._lineGap * factor);
505
+ var left = headTable._xMin * factor;
506
+ var top = Math.ceil(this._metrics._macAscent + this._metrics._lineGap);
507
+ var right = headTable._xMax * factor;
508
+ var bottom = this._metrics._macDescent;
509
+ this._metrics._fontBox = [left, top, right, bottom];
510
+ this._metrics._stemV = 80;
511
+ this._metrics._widthTable = this._updateWidth();
512
+ this._metrics._contains = this._tableDirectory.containsKey('CFF');
513
+ this._metrics._subScriptSizeFactor = headTable._unitsPerEm / os2Table._ySubscriptYSize;
514
+ this._metrics._superscriptSizeFactor = headTable._unitsPerEm / os2Table._ySuperscriptYSize;
515
+ };
516
+ _TrueTypeReader.prototype._updateWidth = function () {
517
+ var count = 256;
518
+ var bytes = [];
519
+ if (this._metrics._isSymbol) {
520
+ for (var i = 0; i < count; i++) {
521
+ var glyphInfo = this._getGlyph(String.fromCharCode(Number.parseInt(i.toString(), 10)));
522
+ bytes[Number.parseInt(i.toString(), 10)] = (glyphInfo._empty) ? 0 : glyphInfo._width;
523
+ }
524
+ }
525
+ else {
526
+ var byteToProcess = [];
527
+ var unknown = '?';
528
+ var space = String.fromCharCode(32);
529
+ for (var i = 0; i < count; i++) {
530
+ byteToProcess[0] = Number.parseInt(i.toString(), 10);
531
+ var text = this._getString(byteToProcess, 0, byteToProcess.length);
532
+ var ch = (text.length > 0) ? text[0] : unknown;
533
+ var glyphInfo = this._getGlyph(ch);
534
+ if (!glyphInfo._empty) {
535
+ bytes[Number.parseInt(i.toString(), 10)] = glyphInfo._width;
536
+ }
537
+ else {
538
+ glyphInfo = this._getGlyph(space);
539
+ bytes[Number.parseInt(i.toString(), 10)] = (glyphInfo._empty) ? 0 : glyphInfo._width;
540
+ }
541
+ }
542
+ }
543
+ return bytes;
544
+ };
545
+ _TrueTypeReader.prototype._getDefaultGlyph = function () {
546
+ var glyph = this._getGlyph(_StringTokenizer._whiteSpace);
547
+ return glyph;
548
+ };
549
+ _TrueTypeReader.prototype._getString = function (byteToProcess, start, length) {
550
+ var result = '';
551
+ for (var index = 0; index < length; index++) {
552
+ result += String.fromCharCode(byteToProcess[index + start]);
553
+ }
554
+ return result;
555
+ };
556
+ _TrueTypeReader.prototype._setOffset = function (offset) {
557
+ this._offset = offset;
558
+ };
559
+ _TrueTypeReader.prototype._readFontProgram = function (chars) {
560
+ var glyphChars = this._getGlyphChars(chars);
561
+ var locaTable = this._readLocaTable(this._bIsLocaShort);
562
+ if (glyphChars && glyphChars._size() < chars._size()) {
563
+ this._missedGlyphs = chars._size() - glyphChars._size();
564
+ }
565
+ this._updateGlyphChars(glyphChars, locaTable);
566
+ var result1 = this._generateGlyphTable(glyphChars, locaTable, null, null);
567
+ var glyphTableSize = result1.glyphTableSize;
568
+ var newLocaTable = result1.newLocaTable;
569
+ var newGlyphTable = result1.newGlyphTable;
570
+ var result2 = this._updateLocaTable(newLocaTable, this._bIsLocaShort);
571
+ var newLocaSize = result2.newLocaSize;
572
+ var newLocaUpdated = result2.newLocaUpdated;
573
+ var fontProgram = this._getFontProgram(newLocaUpdated, newGlyphTable, glyphTableSize, newLocaSize);
574
+ return fontProgram;
575
+ };
576
+ _TrueTypeReader.prototype._generateGlyphTable = function (glyphChars, locaTable, newLocaTable, newGlyphTable) {
577
+ newLocaTable = [];
578
+ var activeGlyphs = glyphChars.keys();
579
+ activeGlyphs.sort(function (a, b) { return a - b; });
580
+ var glyphSize = 0;
581
+ for (var i = 0; i < activeGlyphs.length; i++) {
582
+ var glyphIndex = activeGlyphs[Number.parseInt(i.toString(), 10)];
583
+ if (locaTable._offsets.length > 0) {
584
+ glyphSize += locaTable._offsets[glyphIndex + 1] - locaTable._offsets[Number.parseInt(glyphIndex.toString(), 10)];
585
+ }
586
+ }
587
+ var glyphSizeAligned = this._align(glyphSize);
588
+ newGlyphTable = [];
589
+ for (var i = 0; i < glyphSizeAligned; i++) {
590
+ newGlyphTable.push(0);
591
+ }
592
+ var nextGlyphOffset = 0;
593
+ var nextGlyphIndex = 0;
594
+ var table = this._getTable('glyf');
595
+ for (var i = 0; i < locaTable._offsets.length; i++) {
596
+ newLocaTable.push(nextGlyphOffset);
597
+ if (nextGlyphIndex < activeGlyphs.length && activeGlyphs[Number.parseInt(nextGlyphIndex.toString(), 10)] === i) {
598
+ ++nextGlyphIndex;
599
+ newLocaTable[Number.parseInt(i.toString(), 10)] = nextGlyphOffset;
600
+ var oldGlyphOffset = locaTable._offsets[Number.parseInt(i.toString(), 10)];
601
+ var oldNextGlyphOffset = locaTable._offsets[i + 1] - oldGlyphOffset;
602
+ if (oldNextGlyphOffset > 0) {
603
+ this._offset = table._offset + oldGlyphOffset;
604
+ var result = this._read(newGlyphTable, nextGlyphOffset, oldNextGlyphOffset);
605
+ newGlyphTable = result.buffer;
606
+ nextGlyphOffset += oldNextGlyphOffset;
607
+ }
608
+ }
609
+ }
610
+ return { glyphTableSize: glyphSize, newLocaTable: newLocaTable, newGlyphTable: newGlyphTable };
611
+ };
612
+ _TrueTypeReader.prototype._readLocaTable = function (bShort) {
613
+ var tableInfo = this._getTable('loca');
614
+ this._offset = tableInfo._offset;
615
+ var table = new _TrueTypeLocaTable();
616
+ var buffer = [];
617
+ if (bShort) {
618
+ var len = tableInfo._length / 2;
619
+ buffer = [];
620
+ for (var i = 0; i < len; i++) {
621
+ buffer[Number.parseInt(i.toString(), 10)] = this._readUInt16(this._offset) * 2;
622
+ }
623
+ }
624
+ else {
625
+ var len = tableInfo._length / 4;
626
+ buffer = [];
627
+ for (var i = 0; i < len; i++) {
628
+ buffer[Number.parseInt(i.toString(), 10)] = this._readUInt32(this._offset);
629
+ }
630
+ }
631
+ table._offsets = buffer;
632
+ return table;
633
+ };
634
+ _TrueTypeReader.prototype._updateGlyphChars = function (glyphChars, locaTable) {
635
+ if (!glyphChars.containsKey(0)) {
636
+ glyphChars.setValue(0, 0);
637
+ }
638
+ var clone = new Dictionary();
639
+ var glyphCharKeys = glyphChars.keys();
640
+ for (var i = 0; i < glyphCharKeys.length; i++) {
641
+ clone.setValue(glyphCharKeys[Number.parseInt(i.toString(), 10)], glyphChars.getValue(glyphCharKeys[Number.parseInt(i.toString(), 10)]));
642
+ }
643
+ for (var i = 0; i < glyphCharKeys.length; i++) {
644
+ var nextKey = glyphCharKeys[Number.parseInt(i.toString(), 10)];
645
+ this._processCompositeGlyph(glyphChars, nextKey, locaTable);
646
+ }
647
+ };
648
+ _TrueTypeReader.prototype._processCompositeGlyph = function (glyphChars, glyph, locaTable) {
649
+ if (glyph < locaTable._offsets.length - 1) {
650
+ var glyphOffset = locaTable._offsets[Number.parseInt(glyph.toString(), 10)];
651
+ if (glyphOffset !== locaTable._offsets[glyph + 1]) {
652
+ var tableInfo = this._getTable('glyf');
653
+ this._offset = tableInfo._offset + glyphOffset;
654
+ var glyphHeader = new _TrueTypeGlyphHeader();
655
+ glyphHeader.numberOfContours = this._readInt16(this._offset);
656
+ glyphHeader.xMin = this._readInt16(this._offset);
657
+ glyphHeader.yMin = this._readInt16(this._offset);
658
+ glyphHeader.xMax = this._readInt16(this._offset);
659
+ glyphHeader.yMax = this._readInt16(this._offset);
660
+ if (glyphHeader.numberOfContours < 0) {
661
+ var skipBytes = 0;
662
+ var entry = true;
663
+ while (entry) {
664
+ var flags = this._readUInt16(this._offset);
665
+ var glyphIndex = this._readUInt16(this._offset);
666
+ if (!glyphChars.containsKey(glyphIndex)) {
667
+ glyphChars.setValue(glyphIndex, 0);
668
+ }
669
+ if ((flags & _TrueTypeCompositeGlyphFlag.MoreComponents) === 0) {
670
+ break;
671
+ }
672
+ skipBytes = ((flags & _TrueTypeCompositeGlyphFlag.Arg1And2AreWords) !== 0) ? 4 : 2;
673
+ if ((flags & _TrueTypeCompositeGlyphFlag.WeHaveScale) !== 0) {
674
+ skipBytes += 2;
675
+ }
676
+ else if ((flags & _TrueTypeCompositeGlyphFlag.WeHaveAnXyScale) !== 0) {
677
+ skipBytes += 4;
678
+ }
679
+ else if ((flags & _TrueTypeCompositeGlyphFlag.WeHaveTwoByTwo) !== 0) {
680
+ skipBytes += 2 * 4;
681
+ }
682
+ this._offset += skipBytes;
683
+ }
684
+ }
685
+ }
686
+ }
687
+ };
688
+ _TrueTypeReader.prototype._updateLocaTable = function (newLocaTable, bLocaIsShort) {
689
+ var size = (bLocaIsShort) ? newLocaTable.length * 2 : newLocaTable.length * 4;
690
+ var count = this._align(size);
691
+ var writer = new _BigEndianWriter(count);
692
+ for (var i = 0; i < newLocaTable.length; i++) {
693
+ var value = newLocaTable[Number.parseInt(i.toString(), 10)];
694
+ if (bLocaIsShort) {
695
+ value /= 2;
696
+ writer._writeShort(value);
697
+ }
698
+ else {
699
+ writer._writeInt(value);
700
+ }
701
+ }
702
+ return { newLocaUpdated: writer._data, newLocaSize: size };
703
+ };
704
+ _TrueTypeReader.prototype._align = function (value) {
705
+ return (value + 3) & (~3);
706
+ };
707
+ _TrueTypeReader.prototype._getFontProgram = function (newLocaTableOut, newGlyphTable, glyphTableSize, locaTableSize) {
708
+ var result = this._getFontProgramLength(newLocaTableOut, newGlyphTable, 0);
709
+ var fontProgramLength = result.fontProgramLength;
710
+ var table = result.table;
711
+ var writer = new _BigEndianWriter(fontProgramLength);
712
+ writer._writeInt(0x10000);
713
+ writer._writeShort(table);
714
+ var entrySelector = this._entrySelectors[Number.parseInt(table.toString(), 10)];
715
+ writer._writeShort((1 << (entrySelector & 31)) * 16);
716
+ writer._writeShort(entrySelector);
717
+ writer._writeShort((table - (1 << (entrySelector & 31))) * 16);
718
+ this._writeCheckSums(writer, table, newLocaTableOut, newGlyphTable, glyphTableSize, locaTableSize);
719
+ this._writeGlyphs(writer, newLocaTableOut, newGlyphTable);
720
+ return writer._data;
721
+ };
722
+ _TrueTypeReader.prototype._getFontProgramLength = function (newLocaTableOut, newGlyphTable, table) {
723
+ var fontProgramLength = 0;
724
+ if (newLocaTableOut !== null && typeof newLocaTableOut !== 'undefined' && newLocaTableOut.length > 0 &&
725
+ newGlyphTable !== null && typeof newGlyphTable !== 'undefined' && newGlyphTable.length > 0) {
726
+ table = 2;
727
+ var tableNames = this._tableNames;
728
+ for (var i = 0; i < tableNames.length; i++) {
729
+ var tableName = tableNames[Number.parseInt(i.toString(), 10)];
730
+ if (tableName !== 'glyf' && tableName !== 'loca') {
731
+ var tableInfo = this._getTable(tableName);
732
+ if (!tableInfo._empty) {
733
+ ++table;
734
+ fontProgramLength += this._align(tableInfo._length);
735
+ }
736
+ }
737
+ }
738
+ fontProgramLength += newLocaTableOut.length;
739
+ fontProgramLength += newGlyphTable.length;
740
+ var usedTablesSize = table * 16 + (3 * 4);
741
+ fontProgramLength += usedTablesSize;
742
+ }
743
+ return { fontProgramLength: fontProgramLength, table: table };
744
+ };
745
+ _TrueTypeReader.prototype._getGlyphChars = function (chars) {
746
+ var dictionary = new Dictionary();
747
+ if (chars !== null && typeof chars !== 'undefined') {
748
+ var charKeys = chars.keys();
749
+ for (var i = 0; i < charKeys.length; i++) {
750
+ var ch = charKeys[Number.parseInt(i.toString(), 10)];
751
+ var glyph = this._getGlyph(ch);
752
+ if (!glyph._empty) {
753
+ dictionary.setValue(glyph._index, ch.charCodeAt(0));
754
+ }
755
+ }
756
+ }
757
+ return dictionary;
758
+ };
759
+ _TrueTypeReader.prototype._writeCheckSums = function (writer, table, newLocaTableOut, newGlyphTable, glyphTableSize, locaTableSize) {
760
+ if (writer !== null && typeof writer !== 'undefined' && newLocaTableOut !== null && typeof newLocaTableOut !== 'undefined' &&
761
+ newLocaTableOut.length > 0 && newGlyphTable !== null && typeof newGlyphTable !== 'undefined' && newGlyphTable.length > 0) {
762
+ var tableNames = this._tableNames;
763
+ var usedTablesSize = table * 16 + (3 * 4);
764
+ var nextTableSize = 0;
765
+ for (var i = 0; i < tableNames.length; i++) {
766
+ var tableName = tableNames[Number.parseInt(i.toString(), 10)];
767
+ var tableInfo = this._getTable(tableName);
768
+ if (tableInfo._empty) {
769
+ continue;
770
+ }
771
+ writer._writeString(tableName);
772
+ if (tableName === 'glyf') {
773
+ var checksum = this._calculateCheckSum(newGlyphTable);
774
+ writer._writeInt(checksum);
775
+ nextTableSize = glyphTableSize;
776
+ }
777
+ else if (tableName === 'loca') {
778
+ var checksum = this._calculateCheckSum(newLocaTableOut);
779
+ writer._writeInt(checksum);
780
+ nextTableSize = locaTableSize;
781
+ }
782
+ else {
783
+ writer._writeInt(tableInfo._checksum);
784
+ nextTableSize = tableInfo._length;
785
+ }
786
+ writer._writeUInt(usedTablesSize);
787
+ writer._writeUInt(nextTableSize);
788
+ usedTablesSize += this._align(nextTableSize);
789
+ }
790
+ }
791
+ };
792
+ _TrueTypeReader.prototype._calculateCheckSum = function (bytes) {
793
+ var pos = 0;
794
+ var byte1 = 0;
795
+ var byte2 = 0;
796
+ var byte3 = 0;
797
+ var byte4 = 0;
798
+ var result = 0;
799
+ if (bytes !== null && typeof bytes !== 'undefined' && bytes.length > 0) {
800
+ for (var i = 0; i < (bytes.length + 1) / 4; i++) {
801
+ byte4 += (bytes[pos++] & 255);
802
+ byte3 += (bytes[pos++] & 255);
803
+ byte2 += (bytes[pos++] & 255);
804
+ byte1 += (bytes[pos++] & 255);
805
+ }
806
+ result = byte1;
807
+ result += (byte2 << 8);
808
+ result += (byte3 << 16);
809
+ result += (byte4 << 24);
810
+ }
811
+ return result;
812
+ };
813
+ _TrueTypeReader.prototype._writeGlyphs = function (writer, newLocaTable, newGlyphTable) {
814
+ if (writer !== null && typeof writer !== 'undefined' && newLocaTable !== null && typeof newLocaTable !== 'undefined' &&
815
+ newLocaTable.length > 0 && newGlyphTable !== null && typeof newGlyphTable !== 'undefined' && newGlyphTable.length > 0) {
816
+ var tableNames = this._tableNames;
817
+ for (var i = 0; i < tableNames.length; i++) {
818
+ var tableName = tableNames[Number.parseInt(i.toString(), 10)];
819
+ var tableInfo = this._getTable(tableName);
820
+ if (tableInfo._empty) {
821
+ continue;
822
+ }
823
+ if (tableName === 'glyf') {
824
+ writer._writeBytes(newGlyphTable);
825
+ }
826
+ else if (tableName === 'loca') {
827
+ writer._writeBytes(newLocaTable);
828
+ }
829
+ else {
830
+ var count = this._align(tableInfo._length);
831
+ var buff = [];
832
+ for (var i_1 = 0; i_1 < count; i_1++) {
833
+ buff.push(0);
834
+ }
835
+ this._offset = tableInfo._offset;
836
+ var result = this._read(buff, 0, tableInfo._length);
837
+ writer._writeBytes(result.buffer);
838
+ }
839
+ }
840
+ }
841
+ };
842
+ _TrueTypeReader.prototype._read = function (buffer, index, count) {
843
+ var written = 0;
844
+ if (buffer !== null && typeof buffer !== 'undefined' && buffer.length > 0) {
845
+ var read = 0;
846
+ do {
847
+ for (var i = 0; (i < count - written) && (this._offset + i < this._fontData.length); i++) {
848
+ buffer[index + i] = this._fontData[this._offset + i];
849
+ }
850
+ read = count - written;
851
+ this._offset += read;
852
+ written += read;
853
+ } while (written < count);
854
+ }
855
+ return { buffer: buffer, written: written };
856
+ };
857
+ _TrueTypeReader.prototype._createInternals = function () {
858
+ this._metrics = new _TrueTypeMetrics();
859
+ var nameTable = this._readNameTable();
860
+ var headTable = this._readHeadTable();
861
+ this._bIsLocaShort = (headTable._indexToLocalFormat === 0);
862
+ var horizontalHeadTable = this._readHorizontalHeaderTable();
863
+ var os2Table = this._readOS2Table();
864
+ var postTable = this._readPostTable();
865
+ this._width = this._readWidthTable(horizontalHeadTable._numberOfHMetrics, headTable._unitsPerEm);
866
+ var subTables = this._readCmapTable();
867
+ this._initializeMetrics(nameTable, headTable, horizontalHeadTable, os2Table, postTable, subTables);
868
+ };
869
+ _TrueTypeReader.prototype._getGlyph = function (charCode) {
870
+ if (typeof charCode === 'number') {
871
+ var obj1 = null;
872
+ if (!this._metrics._isSymbol && this._microsoftGlyphs != null) {
873
+ if (this._microsoftGlyphs.containsKey(charCode)) {
874
+ obj1 = this._microsoftGlyphs.getValue(charCode);
875
+ }
876
+ }
877
+ else if (this._metrics._isSymbol && this._macintoshGlyphs != null) {
878
+ if (this._macintoshGlyphs.containsKey(charCode)) {
879
+ obj1 = this._macintoshGlyphs.getValue(charCode);
880
+ }
881
+ }
882
+ var glyph = (obj1 != null) ? obj1 : this._getDefaultGlyph();
883
+ return glyph;
884
+ }
885
+ else {
886
+ var obj = null;
887
+ var code = charCode.charCodeAt(0);
888
+ if (!this._metrics._isSymbol && this._microsoft !== null) {
889
+ if (this._microsoft.containsKey(code)) {
890
+ obj = this._microsoft.getValue(code);
891
+ if (code !== _StringTokenizer._whiteSpace.charCodeAt(0)) {
892
+ this._isFontPresent = true;
893
+ }
894
+ }
895
+ else if (code !== _StringTokenizer._whiteSpace.charCodeAt(0)) {
896
+ this._isFontPresent = false;
897
+ }
898
+ }
899
+ else if (this._metrics._isSymbol && this.macintosh !== null || this._isMacFont) {
900
+ if (this._maxMacIndex !== 0) {
901
+ code %= this._maxMacIndex + 1;
902
+ }
903
+ else {
904
+ code = ((code & 0xff00) === 0xf000 ? code & 0xff : code);
905
+ }
906
+ if (this.macintosh.containsKey(code)) {
907
+ obj = this.macintosh.getValue(code);
908
+ this._isFontPresent = true;
909
+ }
910
+ }
911
+ if (charCode === _StringTokenizer._whiteSpace && obj === null) {
912
+ obj = new _TrueTypeGlyph();
913
+ }
914
+ var glyph = (obj !== null) ? obj : this._getDefaultGlyph();
915
+ return glyph;
916
+ }
917
+ };
918
+ _TrueTypeReader.prototype._readString = function (length, isUnicode) {
919
+ if (typeof isUnicode === 'undefined' || isUnicode === null) {
920
+ return this._readString(length, false);
921
+ }
922
+ else {
923
+ var result = '';
924
+ if (isUnicode) {
925
+ for (var i = 0; i < length; i++) {
926
+ if (i % 2 !== 0) {
927
+ result += String.fromCharCode(this._fontData[this._offset]);
928
+ }
929
+ this._offset += 1;
930
+ }
931
+ }
932
+ else {
933
+ for (var i = 0; i < length; i++) {
934
+ result += String.fromCharCode(this._fontData[this._offset]);
935
+ this._offset += 1;
936
+ }
937
+ }
938
+ return result;
939
+ }
940
+ };
941
+ _TrueTypeReader.prototype._readFixed = function (offset) {
942
+ var integer = this._readInt16(offset);
943
+ var sFraction = this._readInt16(offset + 2);
944
+ var fraction = sFraction / 16384;
945
+ return integer + fraction;
946
+ };
947
+ _TrueTypeReader.prototype._readInt32 = function (offset) {
948
+ var i1 = this._fontData[Number.parseInt(offset.toString(), 10) + 3];
949
+ var i2 = this._fontData[Number.parseInt(offset.toString(), 10) + 2];
950
+ var i3 = this._fontData[Number.parseInt(offset.toString(), 10) + 1];
951
+ var i4 = this._fontData[Number.parseInt(offset.toString(), 10)];
952
+ this._offset += 4;
953
+ return i1 + (i2 << 8) + (i3 << 16) + (i4 << 24);
954
+ };
955
+ _TrueTypeReader.prototype._readUInt32 = function (offset) {
956
+ var i1 = this._fontData[Number.parseInt(offset.toString(), 10) + 3];
957
+ var i2 = this._fontData[Number.parseInt(offset.toString(), 10) + 2];
958
+ var i3 = this._fontData[Number.parseInt(offset.toString(), 10) + 1];
959
+ var i4 = this._fontData[Number.parseInt(offset.toString(), 10)];
960
+ this._offset += 4;
961
+ return (i1 | i2 << 8 | i3 << 16 | i4 << 24);
962
+ };
963
+ _TrueTypeReader.prototype._readInt16 = function (offset) {
964
+ var result = (this._fontData[Number.parseInt(offset.toString(), 10)] << 8) +
965
+ this._fontData[Number.parseInt(offset.toString(), 10) + 1];
966
+ result = result & (1 << 15) ? result - 0x10000 : result;
967
+ this._offset += 2;
968
+ return result;
969
+ };
970
+ _TrueTypeReader.prototype._readInt64 = function (offset) {
971
+ var low = this._readInt32(offset + 4);
972
+ var n = this._readInt32(offset) * 4294967296.0 + low;
973
+ if (low < 0) {
974
+ n += 4294967296;
975
+ }
976
+ return n;
977
+ };
978
+ _TrueTypeReader.prototype._readUInt16 = function (offset) {
979
+ var result = (this._fontData[Number.parseInt(offset.toString(), 10)] << 8) |
980
+ this._fontData[Number.parseInt(offset.toString(), 10) + 1];
981
+ this._offset += 2;
982
+ return result;
983
+ };
984
+ _TrueTypeReader.prototype._readUShortArray = function (length) {
985
+ var buffer = [];
986
+ for (var i = 0; i < length; i++) {
987
+ buffer[Number.parseInt(i.toString(), 10)] = this._readUInt16(this._offset);
988
+ }
989
+ return buffer;
990
+ };
991
+ _TrueTypeReader.prototype._readBytes = function (length) {
992
+ var result = [];
993
+ for (var i = 0; i < length; i++) {
994
+ result.push(this._fontData[Number.parseInt(this._offset.toString(), 10)]);
995
+ this._offset += 1;
996
+ }
997
+ return result;
998
+ };
999
+ _TrueTypeReader.prototype._readByte = function (offset) {
1000
+ var result = this._fontData[Number.parseInt(offset.toString(), 10)];
1001
+ this._offset += 1;
1002
+ return result;
1003
+ };
1004
+ _TrueTypeReader.prototype._getCharacterWidth = function (code) {
1005
+ var glyphInfo = this._getGlyph(code);
1006
+ glyphInfo = (!glyphInfo._empty) ? glyphInfo : this._getDefaultGlyph();
1007
+ var codeWidth = (!glyphInfo._empty) ? glyphInfo._width : 0;
1008
+ return codeWidth;
1009
+ };
1010
+ _TrueTypeReader.prototype._convertString = function (text) {
1011
+ var glyph = '';
1012
+ if (text !== null && text !== undefined && text.length > 0) {
1013
+ for (var k = 0; k < text.length; k++) {
1014
+ var ch = text[Number.parseInt(k.toString(), 10)];
1015
+ var glyphInfo = this._getGlyph(ch);
1016
+ if (!glyphInfo._empty) {
1017
+ glyph += String.fromCharCode(glyphInfo._index);
1018
+ }
1019
+ }
1020
+ }
1021
+ return glyph;
1022
+ };
1023
+ return _TrueTypeReader;
1024
+ }());
1025
+ export { _TrueTypeReader };
1026
+ var _TrueTypeNameRecord = /** @class */ (function () {
1027
+ function _TrueTypeNameRecord() {
1028
+ }
1029
+ return _TrueTypeNameRecord;
1030
+ }());
1031
+ export { _TrueTypeNameRecord };
1032
+ var _TrueTypeMetrics = /** @class */ (function () {
1033
+ function _TrueTypeMetrics() {
1034
+ }
1035
+ Object.defineProperty(_TrueTypeMetrics.prototype, "_isItalic", {
1036
+ get: function () {
1037
+ return ((this._macStyle & 2) !== 0);
1038
+ },
1039
+ enumerable: true,
1040
+ configurable: true
1041
+ });
1042
+ Object.defineProperty(_TrueTypeMetrics.prototype, "_isBold", {
1043
+ get: function () {
1044
+ return ((this._macStyle & 1) !== 0);
1045
+ },
1046
+ enumerable: true,
1047
+ configurable: true
1048
+ });
1049
+ return _TrueTypeMetrics;
1050
+ }());
1051
+ export { _TrueTypeMetrics };
1052
+ var _TrueTypeLongHorMetric = /** @class */ (function () {
1053
+ function _TrueTypeLongHorMetric() {
1054
+ }
1055
+ return _TrueTypeLongHorMetric;
1056
+ }());
1057
+ export { _TrueTypeLongHorMetric };
1058
+ var _TrueTypeGlyph = /** @class */ (function () {
1059
+ function _TrueTypeGlyph() {
1060
+ }
1061
+ Object.defineProperty(_TrueTypeGlyph.prototype, "_empty", {
1062
+ get: function () {
1063
+ return (this._index === this._width && this._width === this._charCode && this._charCode === 0);
1064
+ },
1065
+ enumerable: true,
1066
+ configurable: true
1067
+ });
1068
+ return _TrueTypeGlyph;
1069
+ }());
1070
+ export { _TrueTypeGlyph };
1071
+ var _TrueTypeLocaTable = /** @class */ (function () {
1072
+ function _TrueTypeLocaTable() {
1073
+ }
1074
+ return _TrueTypeLocaTable;
1075
+ }());
1076
+ export { _TrueTypeLocaTable };
1077
+ var _TrueTypeGlyphHeader = /** @class */ (function () {
1078
+ function _TrueTypeGlyphHeader() {
1079
+ }
1080
+ return _TrueTypeGlyphHeader;
1081
+ }());
1082
+ export { _TrueTypeGlyphHeader };
1083
+ var _BigEndianWriter = /** @class */ (function () {
1084
+ function _BigEndianWriter(capacity) {
1085
+ this.int32Size = 4;
1086
+ this.int16Size = 2;
1087
+ this.int64Size = 8;
1088
+ this._bufferLength = capacity;
1089
+ this._buffer = [];
1090
+ }
1091
+ Object.defineProperty(_BigEndianWriter.prototype, "_data", {
1092
+ get: function () {
1093
+ if (this._buffer.length < this._bufferLength) {
1094
+ var length_1 = this._bufferLength - this._buffer.length;
1095
+ for (var i = 0; i < length_1; i++) {
1096
+ this._buffer.push(0);
1097
+ }
1098
+ }
1099
+ return this._buffer;
1100
+ },
1101
+ enumerable: true,
1102
+ configurable: true
1103
+ });
1104
+ Object.defineProperty(_BigEndianWriter.prototype, "_position", {
1105
+ get: function () {
1106
+ if (typeof this._internalPosition === 'undefined' || this._internalPosition === null) {
1107
+ this._internalPosition = 0;
1108
+ }
1109
+ return this._internalPosition;
1110
+ },
1111
+ enumerable: true,
1112
+ configurable: true
1113
+ });
1114
+ _BigEndianWriter.prototype._writeShort = function (value) {
1115
+ var bytes = [((value & 0x0000ff00) >> 8), value & 0x000000ff];
1116
+ this._flush(bytes);
1117
+ };
1118
+ _BigEndianWriter.prototype._writeInt = function (value) {
1119
+ var bytes = [(value & 0xff000000) >> 24, (value & 0x00ff0000) >> 16, (value & 0x0000ff00) >> 8, value & 0x000000ff];
1120
+ this._flush(bytes);
1121
+ };
1122
+ _BigEndianWriter.prototype._writeUInt = function (value) {
1123
+ var buff = [(value & 0xff000000) >> 24, (value & 0x00ff0000) >> 16, (value & 0x0000ff00) >> 8, value & 0x000000ff];
1124
+ this._flush(buff);
1125
+ };
1126
+ _BigEndianWriter.prototype._writeString = function (value) {
1127
+ if (value !== null && typeof value !== 'undefined') {
1128
+ var bytes = [];
1129
+ for (var i = 0; i < value.length; i++) {
1130
+ bytes.push(value.charCodeAt(i));
1131
+ }
1132
+ this._flush(bytes);
1133
+ }
1134
+ };
1135
+ _BigEndianWriter.prototype._writeBytes = function (value) {
1136
+ this._flush(value);
1137
+ };
1138
+ _BigEndianWriter.prototype._flush = function (buff) {
1139
+ if (buff !== null && typeof buff !== 'undefined') {
1140
+ var position = this._position;
1141
+ for (var i = 0; i < buff.length; i++) {
1142
+ this._buffer[Number.parseInt(position.toString(), 10)] = buff[Number.parseInt(i.toString(), 10)];
1143
+ position++;
1144
+ }
1145
+ this._internalPosition += buff.length;
1146
+ }
1147
+ };
1148
+ return _BigEndianWriter;
1149
+ }());
1150
+ export { _BigEndianWriter };