@syncfusion/ej2-pdf 1.0.23 → 23.1.36
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.
- package/.eslintrc.json +260 -0
- package/.gitleaksignore +1 -0
- package/CHANGELOG.md +17 -0
- package/README.md +17 -0
- package/dist/ej2-pdf.umd.min.js +4 -14
- package/dist/ej2-pdf.umd.min.js.map +1 -11
- package/dist/es6/ej2-pdf.es2015.js +48245 -0
- package/dist/es6/ej2-pdf.es2015.js.map +1 -0
- package/dist/es6/ej2-pdf.es5.js +50124 -0
- package/dist/es6/ej2-pdf.es5.js.map +1 -0
- package/dist/global/ej2-pdf.min.js +11 -0
- package/dist/global/ej2-pdf.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/index.js +4 -8
- package/license +10 -3
- package/package.json +58 -16
- package/pdf.d.ts +4 -0
- package/pdf.js +4 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +45 -98
- package/src/index.js +45 -96
- package/src/pdf/core/annotations/annotation-collection.d.ts +289 -0
- package/src/pdf/core/annotations/annotation-collection.js +744 -0
- package/src/pdf/core/annotations/annotation.d.ts +5845 -0
- package/src/pdf/core/annotations/annotation.js +14195 -0
- package/src/pdf/core/annotations/index.d.ts +4 -0
- package/src/pdf/core/annotations/index.js +4 -0
- package/src/pdf/core/annotations/pdf-appearance.d.ts +102 -0
- package/src/pdf/core/annotations/pdf-appearance.js +124 -0
- package/src/pdf/core/annotations/pdf-paddings.d.ts +8 -0
- package/src/pdf/core/annotations/pdf-paddings.js +22 -0
- package/src/pdf/core/base-stream.d.ts +86 -0
- package/src/pdf/core/base-stream.js +332 -0
- package/src/pdf/core/content-parser.d.ts +38 -0
- package/src/pdf/core/content-parser.js +359 -0
- package/src/pdf/core/decode-stream.d.ts +21 -0
- package/src/pdf/core/decode-stream.js +120 -0
- package/src/pdf/core/decrypt-stream.d.ts +11 -0
- package/src/pdf/core/decrypt-stream.js +53 -0
- package/src/pdf/core/enumerator.d.ts +1668 -0
- package/src/pdf/core/enumerator.js +1717 -0
- package/src/pdf/core/flate-stream.d.ts +13 -0
- package/src/pdf/core/flate-stream.js +329 -0
- package/src/pdf/core/fonts/index.d.ts +7 -0
- package/{dist/es6/implementation/graphics → src/pdf/core}/fonts/index.js +3 -4
- package/src/pdf/core/fonts/pdf-font-metrics.d.ts +66 -0
- package/src/pdf/core/fonts/pdf-font-metrics.js +192 -0
- package/src/pdf/core/fonts/pdf-standard-font.d.ts +1023 -0
- package/src/pdf/core/fonts/pdf-standard-font.js +1682 -0
- package/src/pdf/core/fonts/pdf-string-format.d.ts +236 -0
- package/src/pdf/core/fonts/pdf-string-format.js +213 -0
- package/src/pdf/core/fonts/string-layouter.d.ts +68 -0
- package/src/pdf/core/fonts/string-layouter.js +437 -0
- package/src/pdf/core/fonts/ttf-reader.d.ts +167 -0
- package/src/pdf/core/fonts/ttf-reader.js +1150 -0
- package/src/pdf/core/fonts/ttf-table.d.ts +132 -0
- package/src/pdf/core/fonts/ttf-table.js +74 -0
- package/src/pdf/core/fonts/unicode-true-type-font.d.ts +50 -0
- package/src/pdf/core/fonts/unicode-true-type-font.js +289 -0
- package/src/pdf/core/form/field.d.ts +3011 -0
- package/src/pdf/core/form/field.js +6828 -0
- package/src/pdf/core/form/form.d.ts +279 -0
- package/src/pdf/core/form/form.js +782 -0
- package/src/pdf/core/form/index.d.ts +2 -0
- package/src/pdf/core/form/index.js +2 -0
- package/src/pdf/core/graphics/images/image-decoder.d.ts +31 -0
- package/src/pdf/core/graphics/images/image-decoder.js +130 -0
- package/src/{implementation → pdf/core}/graphics/images/index.d.ts +0 -5
- package/{dist/es6/implementation → src/pdf/core}/graphics/images/index.js +0 -1
- package/src/pdf/core/graphics/images/pdf-bitmap.d.ts +73 -0
- package/src/pdf/core/graphics/images/pdf-bitmap.js +68 -0
- package/src/pdf/core/graphics/images/pdf-image.d.ts +201 -0
- package/src/pdf/core/graphics/images/pdf-image.js +201 -0
- package/src/pdf/core/graphics/index.d.ts +10 -0
- package/src/pdf/core/graphics/index.js +10 -0
- package/src/pdf/core/graphics/pdf-graphics.d.ts +956 -0
- package/src/pdf/core/graphics/pdf-graphics.js +1860 -0
- package/src/pdf/core/graphics/pdf-path.d.ts +34 -0
- package/src/pdf/core/graphics/pdf-path.js +177 -0
- package/src/pdf/core/graphics/pdf-stream-writer.d.ts +56 -0
- package/src/pdf/core/graphics/pdf-stream-writer.js +231 -0
- package/src/pdf/core/graphics/pdf-template.d.ts +79 -0
- package/src/pdf/core/graphics/pdf-template.js +100 -0
- package/src/pdf/core/graphics/rightToLeft/bidirectional.d.ts +69 -0
- package/src/pdf/core/graphics/rightToLeft/bidirectional.js +831 -0
- package/src/pdf/core/graphics/rightToLeft/index.d.ts +3 -0
- package/src/pdf/core/graphics/rightToLeft/index.js +3 -0
- package/src/pdf/core/graphics/rightToLeft/text-renderer.d.ts +13 -0
- package/src/pdf/core/graphics/rightToLeft/text-renderer.js +116 -0
- package/src/pdf/core/graphics/rightToLeft/text-shape.d.ts +48 -0
- package/src/pdf/core/graphics/rightToLeft/text-shape.js +289 -0
- package/src/pdf/core/import-export/fdf-document.d.ts +37 -0
- package/src/pdf/core/import-export/fdf-document.js +667 -0
- package/src/pdf/core/import-export/index.d.ts +5 -0
- package/src/pdf/core/import-export/index.js +5 -0
- package/src/pdf/core/import-export/json-document.d.ts +47 -0
- package/src/pdf/core/import-export/json-document.js +1547 -0
- package/src/pdf/core/import-export/xfdf-document.d.ts +146 -0
- package/src/pdf/core/import-export/xfdf-document.js +2920 -0
- package/src/pdf/core/import-export/xml-document.d.ts +14 -0
- package/src/pdf/core/import-export/xml-document.js +166 -0
- package/src/pdf/core/import-export/xml-writer.d.ts +69 -0
- package/src/pdf/core/import-export/xml-writer.js +494 -0
- package/src/pdf/core/pdf-catalog.d.ts +18 -0
- package/src/pdf/core/pdf-catalog.js +166 -0
- package/src/pdf/core/pdf-cross-reference.d.ts +80 -0
- package/src/pdf/core/pdf-cross-reference.js +1049 -0
- package/src/pdf/core/pdf-document.d.ts +821 -0
- package/src/pdf/core/pdf-document.js +1022 -0
- package/src/pdf/core/pdf-file-structure.d.ts +54 -0
- package/src/pdf/core/pdf-file-structure.js +65 -0
- package/src/pdf/core/pdf-outline.d.ts +362 -0
- package/src/pdf/core/pdf-outline.js +860 -0
- package/src/pdf/core/pdf-page.d.ts +589 -0
- package/src/pdf/core/pdf-page.js +1049 -0
- package/src/pdf/core/pdf-parser.d.ts +62 -0
- package/src/pdf/core/pdf-parser.js +1035 -0
- package/src/pdf/core/pdf-primitives.d.ts +87 -0
- package/src/pdf/core/pdf-primitives.js +305 -0
- package/src/pdf/core/predictor-stream.d.ts +15 -0
- package/src/pdf/core/predictor-stream.js +214 -0
- package/src/pdf/core/security/encryptor.d.ts +140 -0
- package/src/pdf/core/security/encryptor.js +1616 -0
- package/src/pdf/core/security/index.d.ts +1 -0
- package/src/pdf/core/security/index.js +1 -0
- package/src/pdf/core/utils.d.ts +678 -0
- package/src/pdf/core/utils.js +3607 -0
- package/src/pdf/index.d.ts +44 -0
- package/src/pdf/index.js +44 -0
- package/tslint.json +111 -0
- package/ReadMe.md +0 -13
- package/dist/es6/implementation/actions/action.js +0 -44
- package/dist/es6/implementation/actions/index.js +0 -2
- package/dist/es6/implementation/actions/uri-action.js +0 -38
- package/dist/es6/implementation/annotations/action-link-annotation.js +0 -29
- package/dist/es6/implementation/annotations/annotation-collection.js +0 -93
- package/dist/es6/implementation/annotations/annotation.js +0 -156
- package/dist/es6/implementation/annotations/document-link-annotation.js +0 -48
- package/dist/es6/implementation/annotations/index.js +0 -7
- package/dist/es6/implementation/annotations/link-annotation.js +0 -31
- package/dist/es6/implementation/annotations/pdf-text-web-link.js +0 -178
- package/dist/es6/implementation/annotations/uri-annotation.js +0 -64
- package/dist/es6/implementation/collections/dictionary.js +0 -71
- package/dist/es6/implementation/collections/index.js +0 -3
- package/dist/es6/implementation/collections/object-object-pair/dictionary.js +0 -84
- package/dist/es6/implementation/collections/object-object-pair/index.js +0 -1
- package/dist/es6/implementation/collections/utils.js +0 -8
- package/dist/es6/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -17
- package/dist/es6/implementation/document/automatic-fields/automatic-field-info.js +0 -68
- package/dist/es6/implementation/document/automatic-fields/automatic-field.js +0 -145
- package/dist/es6/implementation/document/automatic-fields/composite-field.js +0 -61
- package/dist/es6/implementation/document/automatic-fields/index.js +0 -7
- package/dist/es6/implementation/document/automatic-fields/multiple-value-field.js +0 -36
- package/dist/es6/implementation/document/automatic-fields/page-count-field.js +0 -53
- package/dist/es6/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -91
- package/dist/es6/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
- package/dist/es6/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -34
- package/dist/es6/implementation/document/automatic-fields/single-value-field.js +0 -47
- package/dist/es6/implementation/document/index.js +0 -11
- package/dist/es6/implementation/document/pdf-catalog.js +0 -38
- package/dist/es6/implementation/document/pdf-document-base.js +0 -71
- package/dist/es6/implementation/document/pdf-document-template.js +0 -204
- package/dist/es6/implementation/document/pdf-document.js +0 -175
- package/dist/es6/implementation/drawing/index.js +0 -1
- package/dist/es6/implementation/drawing/pdf-drawing.js +0 -80
- package/dist/es6/implementation/general/enum.js +0 -6
- package/dist/es6/implementation/general/index.js +0 -3
- package/dist/es6/implementation/general/pdf-cache-collection.js +0 -24
- package/dist/es6/implementation/general/pdf-collection.js +0 -26
- package/dist/es6/implementation/general/pdf-destination.js +0 -107
- package/dist/es6/implementation/graphics/brushes/index.js +0 -2
- package/dist/es6/implementation/graphics/brushes/pdf-brush.js +0 -6
- package/dist/es6/implementation/graphics/brushes/pdf-solid-brush.js +0 -53
- package/dist/es6/implementation/graphics/constants.js +0 -11
- package/dist/es6/implementation/graphics/enum.js +0 -100
- package/dist/es6/implementation/graphics/figures/base/element-layouter.js +0 -154
- package/dist/es6/implementation/graphics/figures/base/graphics-element.js +0 -18
- package/dist/es6/implementation/graphics/figures/base/index.js +0 -3
- package/dist/es6/implementation/graphics/figures/base/pdf-shape-element.js +0 -32
- package/dist/es6/implementation/graphics/figures/base/shape-layouter.js +0 -55
- package/dist/es6/implementation/graphics/figures/base/text-layouter.js +0 -123
- package/dist/es6/implementation/graphics/figures/enum.js +0 -11
- package/dist/es6/implementation/graphics/figures/index.js +0 -5
- package/dist/es6/implementation/graphics/figures/layout-element.js +0 -41
- package/dist/es6/implementation/graphics/figures/pdf-template.js +0 -110
- package/dist/es6/implementation/graphics/figures/text-element.js +0 -298
- package/dist/es6/implementation/graphics/fonts/enum.js +0 -45
- package/dist/es6/implementation/graphics/fonts/pdf-font-metrics.js +0 -122
- package/dist/es6/implementation/graphics/fonts/pdf-font.js +0 -159
- package/dist/es6/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -357
- package/dist/es6/implementation/graphics/fonts/pdf-standard-font.js +0 -124
- package/dist/es6/implementation/graphics/fonts/pdf-string-format.js +0 -239
- package/dist/es6/implementation/graphics/fonts/string-layouter.js +0 -335
- package/dist/es6/implementation/graphics/fonts/string-tokenizer.js +0 -162
- package/dist/es6/implementation/graphics/images/byte-array.js +0 -82
- package/dist/es6/implementation/graphics/images/image-decoder.js +0 -167
- package/dist/es6/implementation/graphics/images/pdf-bitmap.js +0 -41
- package/dist/es6/implementation/graphics/images/pdf-image.js +0 -68
- package/dist/es6/implementation/graphics/index.js +0 -20
- package/dist/es6/implementation/graphics/pdf-color.js +0 -205
- package/dist/es6/implementation/graphics/pdf-graphics.js +0 -1034
- package/dist/es6/implementation/graphics/pdf-margins.js +0 -75
- package/dist/es6/implementation/graphics/pdf-pen.js +0 -180
- package/dist/es6/implementation/graphics/pdf-resources.js +0 -223
- package/dist/es6/implementation/graphics/pdf-transformation-matrix.js +0 -134
- package/dist/es6/implementation/graphics/pdf-transparency.js +0 -22
- package/dist/es6/implementation/graphics/unit-convertor.js +0 -33
- package/dist/es6/implementation/index.js +0 -85
- package/dist/es6/implementation/input-output/cross-table.js +0 -6
- package/dist/es6/implementation/input-output/enum.js +0 -5
- package/dist/es6/implementation/input-output/index.js +0 -8
- package/dist/es6/implementation/input-output/pdf-cross-table.js +0 -346
- package/dist/es6/implementation/input-output/pdf-dictionary-properties.js +0 -60
- package/dist/es6/implementation/input-output/pdf-main-object-collection.js +0 -115
- package/dist/es6/implementation/input-output/pdf-operators.js +0 -75
- package/dist/es6/implementation/input-output/pdf-stream-writer.js +0 -364
- package/dist/es6/implementation/input-output/pdf-writer.js +0 -44
- package/dist/es6/implementation/pages/enum.js +0 -51
- package/dist/es6/implementation/pages/index.js +0 -13
- package/dist/es6/implementation/pages/page-added-event-arguments.js +0 -19
- package/dist/es6/implementation/pages/pdf-document-page-collection.js +0 -120
- package/dist/es6/implementation/pages/pdf-page-base.js +0 -104
- package/dist/es6/implementation/pages/pdf-page-layer-collection.js +0 -115
- package/dist/es6/implementation/pages/pdf-page-layer.js +0 -160
- package/dist/es6/implementation/pages/pdf-page-settings.js +0 -126
- package/dist/es6/implementation/pages/pdf-page-size.js +0 -36
- package/dist/es6/implementation/pages/pdf-page-template-element.js +0 -510
- package/dist/es6/implementation/pages/pdf-page.js +0 -130
- package/dist/es6/implementation/pages/pdf-section-collection.js +0 -95
- package/dist/es6/implementation/pages/pdf-section-page-collection.js +0 -30
- package/dist/es6/implementation/pages/pdf-section-templates.js +0 -71
- package/dist/es6/implementation/pages/pdf-section.js +0 -388
- package/dist/es6/implementation/primitives/index.js +0 -8
- package/dist/es6/implementation/primitives/pdf-array.js +0 -199
- package/dist/es6/implementation/primitives/pdf-boolean.js +0 -66
- package/dist/es6/implementation/primitives/pdf-dictionary.js +0 -220
- package/dist/es6/implementation/primitives/pdf-name.js +0 -102
- package/dist/es6/implementation/primitives/pdf-number.js +0 -94
- package/dist/es6/implementation/primitives/pdf-reference.js +0 -195
- package/dist/es6/implementation/primitives/pdf-stream.js +0 -149
- package/dist/es6/implementation/primitives/pdf-string.js +0 -143
- package/dist/es6/implementation/structured-elements/grid/index.js +0 -1
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-cell.js +0 -512
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-column.js +0 -125
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-row.js +0 -244
- package/dist/es6/implementation/structured-elements/grid/pdf-grid.js +0 -989
- package/dist/es6/implementation/structured-elements/grid/styles/index.js +0 -2
- package/dist/es6/implementation/structured-elements/grid/styles/pdf-borders.js +0 -145
- package/dist/es6/implementation/structured-elements/grid/styles/style.js +0 -267
- package/dist/es6/implementation/structured-elements/index.js +0 -1
- package/dist/es6/implementation/structured-elements/tables/light-tables/enum.js +0 -5
- package/dist/es6/index.js +0 -89
- package/dist/es6/interfaces/i-pdf-cache.js +0 -1
- package/dist/es6/interfaces/i-pdf-changable.js +0 -1
- package/dist/es6/interfaces/i-pdf-primitives.js +0 -1
- package/dist/es6/interfaces/i-pdf-wrapper.js +0 -1
- package/dist/es6/interfaces/i-pdf-writer.js +0 -1
- package/dist/es6/interfaces/index.js +0 -1
- package/dist/global/ej2-pdf-export.js +0 -15979
- package/implementation.d.ts +0 -4
- package/implementation.js +0 -8
- package/interfaces.d.ts +0 -4
- package/interfaces.js +0 -4
- package/src/implementation/actions/action.d.ts +0 -50
- package/src/implementation/actions/action.js +0 -44
- package/src/implementation/actions/index.d.ts +0 -6
- package/src/implementation/actions/index.js +0 -9
- package/src/implementation/actions/uri-action.d.ts +0 -33
- package/src/implementation/actions/uri-action.js +0 -39
- package/src/implementation/annotations/action-link-annotation.d.ts +0 -30
- package/src/implementation/annotations/action-link-annotation.js +0 -32
- package/src/implementation/annotations/annotation-collection.d.ts +0 -77
- package/src/implementation/annotations/annotation-collection.js +0 -91
- package/src/implementation/annotations/annotation.d.ts +0 -152
- package/src/implementation/annotations/annotation.js +0 -146
- package/src/implementation/annotations/document-link-annotation.d.ts +0 -89
- package/src/implementation/annotations/document-link-annotation.js +0 -51
- package/src/implementation/annotations/index.d.ts +0 -11
- package/src/implementation/annotations/index.js +0 -14
- package/src/implementation/annotations/link-annotation.d.ts +0 -23
- package/src/implementation/annotations/link-annotation.js +0 -33
- package/src/implementation/annotations/pdf-text-web-link.d.ts +0 -118
- package/src/implementation/annotations/pdf-text-web-link.js +0 -173
- package/src/implementation/annotations/uri-annotation.d.ts +0 -48
- package/src/implementation/annotations/uri-annotation.js +0 -65
- package/src/implementation/collections/dictionary.d.ts +0 -76
- package/src/implementation/collections/dictionary.js +0 -74
- package/src/implementation/collections/index.d.ts +0 -7
- package/src/implementation/collections/index.js +0 -10
- package/src/implementation/collections/object-object-pair/dictionary.d.ts +0 -62
- package/src/implementation/collections/object-object-pair/dictionary.js +0 -88
- package/src/implementation/collections/object-object-pair/index.d.ts +0 -5
- package/src/implementation/collections/object-object-pair/index.js +0 -8
- package/src/implementation/collections/utils.d.ts +0 -27
- package/src/implementation/collections/utils.js +0 -13
- package/src/implementation/document/automatic-fields/automatic-field-info-collection.d.ts +0 -31
- package/src/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -21
- package/src/implementation/document/automatic-fields/automatic-field-info.d.ts +0 -67
- package/src/implementation/document/automatic-fields/automatic-field-info.js +0 -70
- package/src/implementation/document/automatic-fields/automatic-field.d.ts +0 -41
- package/src/implementation/document/automatic-fields/automatic-field.js +0 -143
- package/src/implementation/document/automatic-fields/composite-field.d.ts +0 -46
- package/src/implementation/document/automatic-fields/composite-field.js +0 -64
- package/src/implementation/document/automatic-fields/index.d.ts +0 -11
- package/src/implementation/document/automatic-fields/index.js +0 -14
- package/src/implementation/document/automatic-fields/multiple-value-field.d.ts +0 -18
- package/src/implementation/document/automatic-fields/multiple-value-field.js +0 -35
- package/src/implementation/document/automatic-fields/page-count-field.d.ts +0 -44
- package/src/implementation/document/automatic-fields/page-count-field.js +0 -53
- package/src/implementation/document/automatic-fields/pdf-numbers-convertor.d.ts +0 -53
- package/src/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -94
- package/src/implementation/document/automatic-fields/pdf-page-number-field.d.ts +0 -51
- package/src/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
- package/src/implementation/document/automatic-fields/pdf-template-value-pair.d.ts +0 -38
- package/src/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -38
- package/src/implementation/document/automatic-fields/single-value-field.d.ts +0 -15
- package/src/implementation/document/automatic-fields/single-value-field.js +0 -46
- package/src/implementation/document/index.d.ts +0 -15
- package/src/implementation/document/index.js +0 -18
- package/src/implementation/document/pdf-catalog.d.ts +0 -32
- package/src/implementation/document/pdf-catalog.js +0 -38
- package/src/implementation/document/pdf-document-base.d.ts +0 -117
- package/src/implementation/document/pdf-document-base.js +0 -72
- package/src/implementation/document/pdf-document-template.d.ts +0 -166
- package/src/implementation/document/pdf-document-template.js +0 -207
- package/src/implementation/document/pdf-document.d.ts +0 -206
- package/src/implementation/document/pdf-document.js +0 -166
- package/src/implementation/drawing/index.d.ts +0 -5
- package/src/implementation/drawing/index.js +0 -8
- package/src/implementation/drawing/pdf-drawing.d.ts +0 -93
- package/src/implementation/drawing/pdf-drawing.js +0 -84
- package/src/implementation/general/enum.d.ts +0 -21
- package/src/implementation/general/enum.js +0 -10
- package/src/implementation/general/index.d.ts +0 -7
- package/src/implementation/general/index.js +0 -10
- package/src/implementation/general/pdf-cache-collection.d.ts +0 -33
- package/src/implementation/general/pdf-cache-collection.js +0 -27
- package/src/implementation/general/pdf-collection.d.ts +0 -26
- package/src/implementation/general/pdf-collection.js +0 -30
- package/src/implementation/general/pdf-destination.d.ts +0 -103
- package/src/implementation/general/pdf-destination.js +0 -103
- package/src/implementation/graphics/brushes/index.d.ts +0 -6
- package/src/implementation/graphics/brushes/index.js +0 -9
- package/src/implementation/graphics/brushes/pdf-brush.d.ts +0 -55
- package/src/implementation/graphics/brushes/pdf-brush.js +0 -10
- package/src/implementation/graphics/brushes/pdf-solid-brush.d.ts +0 -77
- package/src/implementation/graphics/brushes/pdf-solid-brush.js +0 -54
- package/src/implementation/graphics/constants.d.ts +0 -31
- package/src/implementation/graphics/constants.js +0 -15
- package/src/implementation/graphics/enum.d.ts +0 -392
- package/src/implementation/graphics/enum.js +0 -104
- package/src/implementation/graphics/figures/base/element-layouter.d.ts +0 -160
- package/src/implementation/graphics/figures/base/element-layouter.js +0 -156
- package/src/implementation/graphics/figures/base/graphics-element.d.ts +0 -16
- package/src/implementation/graphics/figures/base/graphics-element.js +0 -22
- package/src/implementation/graphics/figures/base/index.d.ts +0 -7
- package/src/implementation/graphics/figures/base/index.js +0 -10
- package/src/implementation/graphics/figures/base/pdf-shape-element.d.ts +0 -28
- package/src/implementation/graphics/figures/base/pdf-shape-element.js +0 -34
- package/src/implementation/graphics/figures/base/shape-layouter.d.ts +0 -80
- package/src/implementation/graphics/figures/base/shape-layouter.js +0 -57
- package/src/implementation/graphics/figures/base/text-layouter.d.ts +0 -107
- package/src/implementation/graphics/figures/base/text-layouter.js +0 -121
- package/src/implementation/graphics/figures/enum.d.ts +0 -37
- package/src/implementation/graphics/figures/enum.js +0 -15
- package/src/implementation/graphics/figures/index.d.ts +0 -9
- package/src/implementation/graphics/figures/index.js +0 -12
- package/src/implementation/graphics/figures/layout-element.d.ts +0 -57
- package/src/implementation/graphics/figures/layout-element.js +0 -43
- package/src/implementation/graphics/figures/pdf-template.d.ts +0 -113
- package/src/implementation/graphics/figures/pdf-template.js +0 -106
- package/src/implementation/graphics/figures/text-element.d.ts +0 -213
- package/src/implementation/graphics/figures/text-element.js +0 -289
- package/src/implementation/graphics/fonts/enum.d.ts +0 -179
- package/src/implementation/graphics/fonts/enum.js +0 -49
- package/src/implementation/graphics/fonts/index.d.ts +0 -12
- package/src/implementation/graphics/fonts/index.js +0 -15
- package/src/implementation/graphics/fonts/pdf-font-metrics.d.ts +0 -160
- package/src/implementation/graphics/fonts/pdf-font-metrics.js +0 -123
- package/src/implementation/graphics/fonts/pdf-font.d.ts +0 -187
- package/src/implementation/graphics/fonts/pdf-font.js +0 -158
- package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.d.ts +0 -301
- package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -359
- package/src/implementation/graphics/fonts/pdf-standard-font.d.ts +0 -143
- package/src/implementation/graphics/fonts/pdf-standard-font.js +0 -121
- package/src/implementation/graphics/fonts/pdf-string-format.d.ts +0 -319
- package/src/implementation/graphics/fonts/pdf-string-format.js +0 -241
- package/src/implementation/graphics/fonts/string-layouter.d.ts +0 -255
- package/src/implementation/graphics/fonts/string-layouter.js +0 -336
- package/src/implementation/graphics/fonts/string-tokenizer.d.ts +0 -107
- package/src/implementation/graphics/fonts/string-tokenizer.js +0 -166
- package/src/implementation/graphics/images/byte-array.d.ts +0 -68
- package/src/implementation/graphics/images/byte-array.js +0 -86
- package/src/implementation/graphics/images/image-decoder.d.ts +0 -227
- package/src/implementation/graphics/images/image-decoder.js +0 -164
- package/src/implementation/graphics/images/index.js +0 -11
- package/src/implementation/graphics/images/pdf-bitmap.d.ts +0 -90
- package/src/implementation/graphics/images/pdf-bitmap.js +0 -41
- package/src/implementation/graphics/images/pdf-image.d.ts +0 -88
- package/src/implementation/graphics/images/pdf-image.js +0 -69
- package/src/implementation/graphics/index.d.ts +0 -24
- package/src/implementation/graphics/index.js +0 -27
- package/src/implementation/graphics/pdf-color.d.ts +0 -170
- package/src/implementation/graphics/pdf-color.js +0 -204
- package/src/implementation/graphics/pdf-graphics.d.ts +0 -1085
- package/src/implementation/graphics/pdf-graphics.js +0 -1017
- package/src/implementation/graphics/pdf-margins.d.ts +0 -82
- package/src/implementation/graphics/pdf-margins.js +0 -79
- package/src/implementation/graphics/pdf-pen.d.ts +0 -237
- package/src/implementation/graphics/pdf-pen.js +0 -181
- package/src/implementation/graphics/pdf-resources.d.ts +0 -147
- package/src/implementation/graphics/pdf-resources.js +0 -215
- package/src/implementation/graphics/pdf-transformation-matrix.d.ts +0 -143
- package/src/implementation/graphics/pdf-transformation-matrix.js +0 -136
- package/src/implementation/graphics/pdf-transparency.d.ts +0 -34
- package/src/implementation/graphics/pdf-transparency.js +0 -22
- package/src/implementation/graphics/unit-convertor.d.ts +0 -72
- package/src/implementation/graphics/unit-convertor.js +0 -37
- package/src/implementation/index.d.ts +0 -89
- package/src/implementation/index.js +0 -92
- package/src/implementation/input-output/cross-table.d.ts +0 -21
- package/src/implementation/input-output/cross-table.js +0 -10
- package/src/implementation/input-output/enum.d.ts +0 -16
- package/src/implementation/input-output/enum.js +0 -9
- package/src/implementation/input-output/index.d.ts +0 -12
- package/src/implementation/input-output/index.js +0 -15
- package/src/implementation/input-output/pdf-cross-table.d.ts +0 -249
- package/src/implementation/input-output/pdf-cross-table.js +0 -340
- package/src/implementation/input-output/pdf-dictionary-properties.d.ts +0 -283
- package/src/implementation/input-output/pdf-dictionary-properties.js +0 -64
- package/src/implementation/input-output/pdf-main-object-collection.d.ts +0 -120
- package/src/implementation/input-output/pdf-main-object-collection.js +0 -117
- package/src/implementation/input-output/pdf-operators.d.ts +0 -352
- package/src/implementation/input-output/pdf-operators.js +0 -79
- package/src/implementation/input-output/pdf-stream-writer.d.ts +0 -314
- package/src/implementation/input-output/pdf-stream-writer.js +0 -363
- package/src/implementation/input-output/pdf-writer.d.ts +0 -68
- package/src/implementation/input-output/pdf-writer.js +0 -48
- package/src/implementation/pages/enum.d.ts +0 -201
- package/src/implementation/pages/enum.js +0 -55
- package/src/implementation/pages/index.d.ts +0 -17
- package/src/implementation/pages/index.js +0 -20
- package/src/implementation/pages/page-added-event-arguments.d.ts +0 -30
- package/src/implementation/pages/page-added-event-arguments.js +0 -23
- package/src/implementation/pages/pdf-document-page-collection.d.ts +0 -92
- package/src/implementation/pages/pdf-document-page-collection.js +0 -121
- package/src/implementation/pages/pdf-page-base.d.ts +0 -121
- package/src/implementation/pages/pdf-page-base.js +0 -104
- package/src/implementation/pages/pdf-page-layer-collection.d.ts +0 -99
- package/src/implementation/pages/pdf-page-layer-collection.js +0 -113
- package/src/implementation/pages/pdf-page-layer.d.ts +0 -160
- package/src/implementation/pages/pdf-page-layer.js +0 -159
- package/src/implementation/pages/pdf-page-settings.d.ts +0 -111
- package/src/implementation/pages/pdf-page-settings.js +0 -126
- package/src/implementation/pages/pdf-page-size.d.ts +0 -159
- package/src/implementation/pages/pdf-page-size.js +0 -39
- package/src/implementation/pages/pdf-page-template-element.d.ts +0 -230
- package/src/implementation/pages/pdf-page-template-element.js +0 -509
- package/src/implementation/pages/pdf-page.d.ts +0 -153
- package/src/implementation/pages/pdf-page.js +0 -127
- package/src/implementation/pages/pdf-section-collection.d.ts +0 -109
- package/src/implementation/pages/pdf-section-collection.js +0 -91
- package/src/implementation/pages/pdf-section-page-collection.d.ts +0 -41
- package/src/implementation/pages/pdf-section-page-collection.js +0 -34
- package/src/implementation/pages/pdf-section-templates.d.ts +0 -64
- package/src/implementation/pages/pdf-section-templates.js +0 -74
- package/src/implementation/pages/pdf-section.d.ts +0 -319
- package/src/implementation/pages/pdf-section.js +0 -379
- package/src/implementation/primitives/index.d.ts +0 -12
- package/src/implementation/primitives/index.js +0 -15
- package/src/implementation/primitives/pdf-array.d.ts +0 -186
- package/src/implementation/primitives/pdf-array.js +0 -201
- package/src/implementation/primitives/pdf-boolean.d.ts +0 -84
- package/src/implementation/primitives/pdf-boolean.js +0 -70
- package/src/implementation/primitives/pdf-dictionary.d.ts +0 -311
- package/src/implementation/primitives/pdf-dictionary.js +0 -220
- package/src/implementation/primitives/pdf-name.d.ts +0 -121
- package/src/implementation/primitives/pdf-name.js +0 -106
- package/src/implementation/primitives/pdf-number.d.ts +0 -104
- package/src/implementation/primitives/pdf-number.js +0 -98
- package/src/implementation/primitives/pdf-reference.d.ts +0 -222
- package/src/implementation/primitives/pdf-reference.js +0 -192
- package/src/implementation/primitives/pdf-stream.d.ts +0 -111
- package/src/implementation/primitives/pdf-stream.js +0 -146
- package/src/implementation/primitives/pdf-string.d.ts +0 -212
- package/src/implementation/primitives/pdf-string.js +0 -147
- package/src/implementation/structured-elements/grid/index.d.ts +0 -0
- package/src/implementation/structured-elements/grid/index.js +0 -1
- package/src/implementation/structured-elements/grid/pdf-grid-cell.d.ts +0 -248
- package/src/implementation/structured-elements/grid/pdf-grid-cell.js +0 -504
- package/src/implementation/structured-elements/grid/pdf-grid-column.d.ts +0 -108
- package/src/implementation/structured-elements/grid/pdf-grid-column.js +0 -127
- package/src/implementation/structured-elements/grid/pdf-grid-row.d.ts +0 -207
- package/src/implementation/structured-elements/grid/pdf-grid-row.js +0 -246
- package/src/implementation/structured-elements/grid/pdf-grid.d.ts +0 -678
- package/src/implementation/structured-elements/grid/pdf-grid.js +0 -982
- package/src/implementation/structured-elements/grid/styles/index.d.ts +0 -5
- package/src/implementation/structured-elements/grid/styles/index.js +0 -9
- package/src/implementation/structured-elements/grid/styles/pdf-borders.d.ts +0 -126
- package/src/implementation/structured-elements/grid/styles/pdf-borders.js +0 -146
- package/src/implementation/structured-elements/grid/styles/style.d.ts +0 -250
- package/src/implementation/structured-elements/grid/styles/style.js +0 -269
- package/src/implementation/structured-elements/index.d.ts +0 -0
- package/src/implementation/structured-elements/index.js +0 -1
- package/src/implementation/structured-elements/tables/light-tables/enum.d.ts +0 -16
- package/src/implementation/structured-elements/tables/light-tables/enum.js +0 -9
- package/src/interfaces/i-pdf-cache.d.ts +0 -23
- package/src/interfaces/i-pdf-cache.js +0 -4
- package/src/interfaces/i-pdf-changable.d.ts +0 -17
- package/src/interfaces/i-pdf-changable.js +0 -4
- package/src/interfaces/i-pdf-primitives.d.ts +0 -45
- package/src/interfaces/i-pdf-primitives.js +0 -4
- package/src/interfaces/i-pdf-wrapper.d.ts +0 -13
- package/src/interfaces/i-pdf-wrapper.js +0 -4
- package/src/interfaces/i-pdf-writer.d.ts +0 -29
- package/src/interfaces/i-pdf-writer.js +0 -4
- package/src/interfaces/index.d.ts +0 -9
- 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 };
|