@wordpress/global-styles-ui 1.1.0
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/LICENSE.md +788 -0
- package/README.md +48 -0
- package/build/background-panel.js +62 -0
- package/build/background-panel.js.map +7 -0
- package/build/block-preview-panel.js +90 -0
- package/build/block-preview-panel.js.map +7 -0
- package/build/color-indicator-wrapper.js +55 -0
- package/build/color-indicator-wrapper.js.map +7 -0
- package/build/color-palette-panel.js +123 -0
- package/build/color-palette-panel.js.map +7 -0
- package/build/color-preview.js +94 -0
- package/build/color-preview.js.map +7 -0
- package/build/color-variations.js +41 -0
- package/build/color-variations.js.map +7 -0
- package/build/confirm-reset-shadow-dialog.js +55 -0
- package/build/confirm-reset-shadow-dialog.js.map +7 -0
- package/build/context.js +37 -0
- package/build/context.js.map +7 -0
- package/build/dimensions-panel.js +89 -0
- package/build/dimensions-panel.js.map +7 -0
- package/build/font-families.js +114 -0
- package/build/font-families.js.map +7 -0
- package/build/font-family-item.js +48 -0
- package/build/font-family-item.js.map +7 -0
- package/build/font-library-modal/collection-font-variant.js +75 -0
- package/build/font-library-modal/collection-font-variant.js.map +7 -0
- package/build/font-library-modal/context.js +386 -0
- package/build/font-library-modal/context.js.map +7 -0
- package/build/font-library-modal/font-card.js +81 -0
- package/build/font-library-modal/font-card.js.map +7 -0
- package/build/font-library-modal/font-collection.js +510 -0
- package/build/font-library-modal/font-collection.js.map +7 -0
- package/build/font-library-modal/font-demo.js +111 -0
- package/build/font-library-modal/font-demo.js.map +7 -0
- package/build/font-library-modal/google-fonts-confirm-dialog.js +58 -0
- package/build/font-library-modal/google-fonts-confirm-dialog.js.map +7 -0
- package/build/font-library-modal/index.js +110 -0
- package/build/font-library-modal/index.js.map +7 -0
- package/build/font-library-modal/installed-fonts.js +453 -0
- package/build/font-library-modal/installed-fonts.js.map +7 -0
- package/build/font-library-modal/lib/inflate.js +2628 -0
- package/build/font-library-modal/lib/inflate.js.map +7 -0
- package/build/font-library-modal/lib/lib-font.browser.d.js +33 -0
- package/build/font-library-modal/lib/lib-font.browser.d.js.map +7 -0
- package/build/font-library-modal/lib/lib-font.browser.js +3788 -0
- package/build/font-library-modal/lib/lib-font.browser.js.map +7 -0
- package/build/font-library-modal/lib/unbrotli.js +3678 -0
- package/build/font-library-modal/lib/unbrotli.js.map +7 -0
- package/build/font-library-modal/library-font-details.js +63 -0
- package/build/font-library-modal/library-font-details.js.map +7 -0
- package/build/font-library-modal/library-font-variant.js +81 -0
- package/build/font-library-modal/library-font-variant.js.map +7 -0
- package/build/font-library-modal/resolvers.js +115 -0
- package/build/font-library-modal/resolvers.js.map +7 -0
- package/build/font-library-modal/types.js +17 -0
- package/build/font-library-modal/types.js.map +7 -0
- package/build/font-library-modal/upload-fonts.js +207 -0
- package/build/font-library-modal/upload-fonts.js.map +7 -0
- package/build/font-library-modal/utils/constants.js +49 -0
- package/build/font-library-modal/utils/constants.js.map +7 -0
- package/build/font-library-modal/utils/filter-fonts.js +39 -0
- package/build/font-library-modal/utils/filter-fonts.js.map +7 -0
- package/build/font-library-modal/utils/fonts-outline.js +51 -0
- package/build/font-library-modal/utils/fonts-outline.js.map +7 -0
- package/build/font-library-modal/utils/index.js +274 -0
- package/build/font-library-modal/utils/index.js.map +7 -0
- package/build/font-library-modal/utils/make-families-from-faces.js +45 -0
- package/build/font-library-modal/utils/make-families-from-faces.js.map +7 -0
- package/build/font-library-modal/utils/preview-styles.js +119 -0
- package/build/font-library-modal/utils/preview-styles.js.map +7 -0
- package/build/font-library-modal/utils/set-immutably.js +40 -0
- package/build/font-library-modal/utils/set-immutably.js.map +7 -0
- package/build/font-library-modal/utils/sort-font-faces.js +59 -0
- package/build/font-library-modal/utils/sort-font-faces.js.map +7 -0
- package/build/font-library-modal/utils/toggleFont.js +67 -0
- package/build/font-library-modal/utils/toggleFont.js.map +7 -0
- package/build/font-sizes/confirm-delete-font-size-dialog.js +60 -0
- package/build/font-sizes/confirm-delete-font-size-dialog.js.map +7 -0
- package/build/font-sizes/confirm-reset-font-sizes-dialog.js +55 -0
- package/build/font-sizes/confirm-reset-font-sizes-dialog.js.map +7 -0
- package/build/font-sizes/font-size-preview.js +50 -0
- package/build/font-sizes/font-size-preview.js.map +7 -0
- package/build/font-sizes/font-size.js +261 -0
- package/build/font-sizes/font-size.js.map +7 -0
- package/build/font-sizes/font-sizes-count.js +40 -0
- package/build/font-sizes/font-sizes-count.js.map +7 -0
- package/build/font-sizes/font-sizes.js +215 -0
- package/build/font-sizes/font-sizes.js.map +7 -0
- package/build/font-sizes/rename-font-size-dialog.js +96 -0
- package/build/font-sizes/rename-font-size-dialog.js.map +7 -0
- package/build/global-styles-ui.js +213 -0
- package/build/global-styles-ui.js.map +7 -0
- package/build/gradients-palette-panel.js +133 -0
- package/build/gradients-palette-panel.js.map +7 -0
- package/build/highlighted-colors.js +57 -0
- package/build/highlighted-colors.js.map +7 -0
- package/build/hooks.js +176 -0
- package/build/hooks.js.map +7 -0
- package/build/icon-with-current-color.js +56 -0
- package/build/icon-with-current-color.js.map +7 -0
- package/build/index.js +51 -0
- package/build/index.js.map +7 -0
- package/build/lock-unlock.js +35 -0
- package/build/lock-unlock.js.map +7 -0
- package/build/navigation-button.js +52 -0
- package/build/navigation-button.js.map +7 -0
- package/build/pagination/index.js +133 -0
- package/build/pagination/index.js.map +7 -0
- package/build/palette.js +93 -0
- package/build/palette.js.map +7 -0
- package/build/preset-colors.js +40 -0
- package/build/preset-colors.js.map +7 -0
- package/build/preview-colors.js +86 -0
- package/build/preview-colors.js.map +7 -0
- package/build/preview-hooks.js +60 -0
- package/build/preview-hooks.js.map +7 -0
- package/build/preview-styles.js +219 -0
- package/build/preview-styles.js.map +7 -0
- package/build/preview-typography.js +72 -0
- package/build/preview-typography.js.map +7 -0
- package/build/preview-wrapper.js +102 -0
- package/build/preview-wrapper.js.map +7 -0
- package/build/provider.js +54 -0
- package/build/provider.js.map +7 -0
- package/build/root-menu.js +72 -0
- package/build/root-menu.js.map +7 -0
- package/build/screen-background.js +58 -0
- package/build/screen-background.js.map +7 -0
- package/build/screen-block-list.js +160 -0
- package/build/screen-block-list.js.map +7 -0
- package/build/screen-block.js +316 -0
- package/build/screen-block.js.map +7 -0
- package/build/screen-color-palette.js +64 -0
- package/build/screen-color-palette.js.map +7 -0
- package/build/screen-colors.js +85 -0
- package/build/screen-colors.js.map +7 -0
- package/build/screen-css.js +68 -0
- package/build/screen-css.js.map +7 -0
- package/build/screen-header.js +61 -0
- package/build/screen-header.js.map +7 -0
- package/build/screen-layout.js +54 -0
- package/build/screen-layout.js.map +7 -0
- package/build/screen-revisions/index.js +147 -0
- package/build/screen-revisions/index.js.map +7 -0
- package/build/screen-revisions/revisions-buttons.js +198 -0
- package/build/screen-revisions/revisions-buttons.js.map +7 -0
- package/build/screen-revisions/types.js +17 -0
- package/build/screen-revisions/types.js.map +7 -0
- package/build/screen-revisions/use-global-styles-revisions.js +163 -0
- package/build/screen-revisions/use-global-styles-revisions.js.map +7 -0
- package/build/screen-root.js +134 -0
- package/build/screen-root.js.map +7 -0
- package/build/screen-shadows.js +49 -0
- package/build/screen-shadows.js.map +7 -0
- package/build/screen-style-variations.js +52 -0
- package/build/screen-style-variations.js.map +7 -0
- package/build/screen-typography-element.js +167 -0
- package/build/screen-typography-element.js.map +7 -0
- package/build/screen-typography.js +65 -0
- package/build/screen-typography.js.map +7 -0
- package/build/shadow-utils.js +125 -0
- package/build/shadow-utils.js.map +7 -0
- package/build/shadows-edit-panel.js +503 -0
- package/build/shadows-edit-panel.js.map +7 -0
- package/build/shadows-panel.js +203 -0
- package/build/shadows-panel.js.map +7 -0
- package/build/size-control/index.js +86 -0
- package/build/size-control/index.js.map +7 -0
- package/build/style-variations-container.js +130 -0
- package/build/style-variations-container.js.map +7 -0
- package/build/style-variations-content.js +52 -0
- package/build/style-variations-content.js.map +7 -0
- package/build/style-variations.js +41 -0
- package/build/style-variations.js.map +7 -0
- package/build/subtitle.js +33 -0
- package/build/subtitle.js.map +7 -0
- package/build/typography-elements.js +117 -0
- package/build/typography-elements.js.map +7 -0
- package/build/typography-example.js +79 -0
- package/build/typography-example.js.map +7 -0
- package/build/typography-panel.js +64 -0
- package/build/typography-panel.js.map +7 -0
- package/build/typography-preview.js +70 -0
- package/build/typography-preview.js.map +7 -0
- package/build/typography-variations.js +41 -0
- package/build/typography-variations.js.map +7 -0
- package/build/utils.js +210 -0
- package/build/utils.js.map +7 -0
- package/build/variations/variation.js +116 -0
- package/build/variations/variation.js.map +7 -0
- package/build/variations/variations-color.js +64 -0
- package/build/variations/variations-color.js.map +7 -0
- package/build/variations/variations-panel.js +69 -0
- package/build/variations/variations-panel.js.map +7 -0
- package/build/variations/variations-typography.js +80 -0
- package/build/variations/variations-typography.js.map +7 -0
- package/build/with-global-styles-provider.js +48 -0
- package/build/with-global-styles-provider.js.map +7 -0
- package/build-module/background-panel.js +38 -0
- package/build-module/background-panel.js.map +7 -0
- package/build-module/block-preview-panel.js +70 -0
- package/build-module/block-preview-panel.js.map +7 -0
- package/build-module/color-indicator-wrapper.js +25 -0
- package/build-module/color-indicator-wrapper.js.map +7 -0
- package/build-module/color-palette-panel.js +97 -0
- package/build-module/color-palette-panel.js.map +7 -0
- package/build-module/color-preview.js +70 -0
- package/build-module/color-preview.js.map +7 -0
- package/build-module/color-variations.js +7 -0
- package/build-module/color-variations.js.map +7 -0
- package/build-module/confirm-reset-shadow-dialog.js +35 -0
- package/build-module/confirm-reset-shadow-dialog.js.map +7 -0
- package/build-module/context.js +13 -0
- package/build-module/context.js.map +7 -0
- package/build-module/dimensions-panel.js +69 -0
- package/build-module/dimensions-panel.js.map +7 -0
- package/build-module/font-families.js +92 -0
- package/build-module/font-families.js.map +7 -0
- package/build-module/font-family-item.js +32 -0
- package/build-module/font-family-item.js.map +7 -0
- package/build-module/font-library-modal/collection-font-variant.js +45 -0
- package/build-module/font-library-modal/collection-font-variant.js.map +7 -0
- package/build-module/font-library-modal/context.js +382 -0
- package/build-module/font-library-modal/context.js.map +7 -0
- package/build-module/font-library-modal/font-card.js +57 -0
- package/build-module/font-library-modal/font-card.js.map +7 -0
- package/build-module/font-library-modal/font-collection.js +510 -0
- package/build-module/font-library-modal/font-collection.js.map +7 -0
- package/build-module/font-library-modal/font-demo.js +94 -0
- package/build-module/font-library-modal/font-demo.js.map +7 -0
- package/build-module/font-library-modal/google-fonts-confirm-dialog.js +45 -0
- package/build-module/font-library-modal/google-fonts-confirm-dialog.js.map +7 -0
- package/build-module/font-library-modal/index.js +83 -0
- package/build-module/font-library-modal/index.js.map +7 -0
- package/build-module/font-library-modal/installed-fonts.js +442 -0
- package/build-module/font-library-modal/installed-fonts.js.map +7 -0
- package/build-module/font-library-modal/lib/inflate.js +2636 -0
- package/build-module/font-library-modal/lib/inflate.js.map +7 -0
- package/build-module/font-library-modal/lib/lib-font.browser.d.js +9 -0
- package/build-module/font-library-modal/lib/lib-font.browser.d.js.map +7 -0
- package/build-module/font-library-modal/lib/lib-font.browser.js +3754 -0
- package/build-module/font-library-modal/lib/lib-font.browser.js.map +7 -0
- package/build-module/font-library-modal/lib/unbrotli.js +3686 -0
- package/build-module/font-library-modal/lib/unbrotli.js.map +7 -0
- package/build-module/font-library-modal/library-font-details.js +36 -0
- package/build-module/font-library-modal/library-font-details.js.map +7 -0
- package/build-module/font-library-modal/library-font-variant.js +51 -0
- package/build-module/font-library-modal/library-font-variant.js.map +7 -0
- package/build-module/font-library-modal/resolvers.js +76 -0
- package/build-module/font-library-modal/resolvers.js.map +7 -0
- package/build-module/font-library-modal/types.js +1 -0
- package/build-module/font-library-modal/types.js.map +7 -0
- package/build-module/font-library-modal/upload-fonts.js +187 -0
- package/build-module/font-library-modal/upload-fonts.js.map +7 -0
- package/build-module/font-library-modal/utils/constants.js +23 -0
- package/build-module/font-library-modal/utils/constants.js.map +7 -0
- package/build-module/font-library-modal/utils/filter-fonts.js +19 -0
- package/build-module/font-library-modal/utils/filter-fonts.js.map +7 -0
- package/build-module/font-library-modal/utils/fonts-outline.js +26 -0
- package/build-module/font-library-modal/utils/fonts-outline.js.map +7 -0
- package/build-module/font-library-modal/utils/index.js +238 -0
- package/build-module/font-library-modal/utils/index.js.map +7 -0
- package/build-module/font-library-modal/utils/make-families-from-faces.js +25 -0
- package/build-module/font-library-modal/utils/make-families-from-faces.js.map +7 -0
- package/build-module/font-library-modal/utils/preview-styles.js +92 -0
- package/build-module/font-library-modal/utils/preview-styles.js.map +7 -0
- package/build-module/font-library-modal/utils/set-immutably.js +16 -0
- package/build-module/font-library-modal/utils/set-immutably.js.map +7 -0
- package/build-module/font-library-modal/utils/sort-font-faces.js +35 -0
- package/build-module/font-library-modal/utils/sort-font-faces.js.map +7 -0
- package/build-module/font-library-modal/utils/toggleFont.js +43 -0
- package/build-module/font-library-modal/utils/toggleFont.js.map +7 -0
- package/build-module/font-sizes/confirm-delete-font-size-dialog.js +40 -0
- package/build-module/font-sizes/confirm-delete-font-size-dialog.js.map +7 -0
- package/build-module/font-sizes/confirm-reset-font-sizes-dialog.js +35 -0
- package/build-module/font-sizes/confirm-reset-font-sizes-dialog.js.map +7 -0
- package/build-module/font-sizes/font-size-preview.js +30 -0
- package/build-module/font-sizes/font-size-preview.js.map +7 -0
- package/build-module/font-sizes/font-size.js +241 -0
- package/build-module/font-sizes/font-size.js.map +7 -0
- package/build-module/font-sizes/font-sizes-count.js +25 -0
- package/build-module/font-sizes/font-sizes-count.js.map +7 -0
- package/build-module/font-sizes/font-sizes.js +200 -0
- package/build-module/font-sizes/font-sizes.js.map +7 -0
- package/build-module/font-sizes/rename-font-size-dialog.js +82 -0
- package/build-module/font-sizes/rename-font-size-dialog.js.map +7 -0
- package/build-module/global-styles-ui.js +182 -0
- package/build-module/global-styles-ui.js.map +7 -0
- package/build-module/gradients-palette-panel.js +118 -0
- package/build-module/gradients-palette-panel.js.map +7 -0
- package/build-module/highlighted-colors.js +37 -0
- package/build-module/highlighted-colors.js.map +7 -0
- package/build-module/hooks.js +144 -0
- package/build-module/hooks.js.map +7 -0
- package/build-module/icon-with-current-color.js +22 -0
- package/build-module/icon-with-current-color.js.map +7 -0
- package/build-module/index.js +13 -0
- package/build-module/index.js.map +7 -0
- package/build-module/lock-unlock.js +10 -0
- package/build-module/lock-unlock.js.map +7 -0
- package/build-module/navigation-button.js +32 -0
- package/build-module/navigation-button.js.map +7 -0
- package/build-module/pagination/index.js +107 -0
- package/build-module/pagination/index.js.map +7 -0
- package/build-module/palette.js +70 -0
- package/build-module/palette.js.map +7 -0
- package/build-module/preset-colors.js +20 -0
- package/build-module/preset-colors.js.map +7 -0
- package/build-module/preview-colors.js +59 -0
- package/build-module/preview-colors.js.map +7 -0
- package/build-module/preview-hooks.js +36 -0
- package/build-module/preview-hooks.js.map +7 -0
- package/build-module/preview-styles.js +193 -0
- package/build-module/preview-styles.js.map +7 -0
- package/build-module/preview-typography.js +42 -0
- package/build-module/preview-typography.js.map +7 -0
- package/build-module/preview-wrapper.js +86 -0
- package/build-module/preview-wrapper.js.map +7 -0
- package/build-module/provider.js +30 -0
- package/build-module/provider.js.map +7 -0
- package/build-module/root-menu.js +58 -0
- package/build-module/root-menu.js.map +7 -0
- package/build-module/screen-background.js +28 -0
- package/build-module/screen-background.js.map +7 -0
- package/build-module/screen-block-list.js +150 -0
- package/build-module/screen-block-list.js.map +7 -0
- package/build-module/screen-block.js +293 -0
- package/build-module/screen-block.js.map +7 -0
- package/build-module/screen-color-palette.js +34 -0
- package/build-module/screen-color-palette.js.map +7 -0
- package/build-module/screen-colors.js +55 -0
- package/build-module/screen-colors.js.map +7 -0
- package/build-module/screen-css.js +48 -0
- package/build-module/screen-css.js.map +7 -0
- package/build-module/screen-header.js +44 -0
- package/build-module/screen-header.js.map +7 -0
- package/build-module/screen-layout.js +24 -0
- package/build-module/screen-layout.js.map +7 -0
- package/build-module/screen-revisions/index.js +121 -0
- package/build-module/screen-revisions/index.js.map +7 -0
- package/build-module/screen-revisions/revisions-buttons.js +178 -0
- package/build-module/screen-revisions/revisions-buttons.js.map +7 -0
- package/build-module/screen-revisions/types.js +1 -0
- package/build-module/screen-revisions/types.js.map +7 -0
- package/build-module/screen-revisions/use-global-styles-revisions.js +145 -0
- package/build-module/screen-revisions/use-global-styles-revisions.js.map +7 -0
- package/build-module/screen-root.js +114 -0
- package/build-module/screen-root.js.map +7 -0
- package/build-module/screen-shadows.js +14 -0
- package/build-module/screen-shadows.js.map +7 -0
- package/build-module/screen-style-variations.js +32 -0
- package/build-module/screen-style-variations.js.map +7 -0
- package/build-module/screen-typography-element.js +141 -0
- package/build-module/screen-typography-element.js.map +7 -0
- package/build-module/screen-typography.js +35 -0
- package/build-module/screen-typography.js.map +7 -0
- package/build-module/shadow-utils.js +98 -0
- package/build-module/shadow-utils.js.map +7 -0
- package/build-module/shadows-edit-panel.js +502 -0
- package/build-module/shadows-edit-panel.js.map +7 -0
- package/build-module/shadows-panel.js +182 -0
- package/build-module/shadows-panel.js.map +7 -0
- package/build-module/size-control/index.js +72 -0
- package/build-module/size-control/index.js.map +7 -0
- package/build-module/style-variations-container.js +100 -0
- package/build-module/style-variations-container.js.map +7 -0
- package/build-module/style-variations-content.js +18 -0
- package/build-module/style-variations-content.js.map +7 -0
- package/build-module/style-variations.js +7 -0
- package/build-module/style-variations.js.map +7 -0
- package/build-module/subtitle.js +9 -0
- package/build-module/subtitle.js.map +7 -0
- package/build-module/typography-elements.js +102 -0
- package/build-module/typography-elements.js.map +7 -0
- package/build-module/typography-example.js +59 -0
- package/build-module/typography-example.js.map +7 -0
- package/build-module/typography-panel.js +44 -0
- package/build-module/typography-panel.js.map +7 -0
- package/build-module/typography-preview.js +50 -0
- package/build-module/typography-preview.js.map +7 -0
- package/build-module/typography-variations.js +7 -0
- package/build-module/typography-variations.js.map +7 -0
- package/build-module/utils.js +179 -0
- package/build-module/utils.js.map +7 -0
- package/build-module/variations/variation.js +86 -0
- package/build-module/variations/variation.js.map +7 -0
- package/build-module/variations/variations-color.js +37 -0
- package/build-module/variations/variations-color.js.map +7 -0
- package/build-module/variations/variations-panel.js +44 -0
- package/build-module/variations/variations-panel.js.map +7 -0
- package/build-module/variations/variations-typography.js +53 -0
- package/build-module/variations/variations-typography.js.map +7 -0
- package/build-module/with-global-styles-provider.js +24 -0
- package/build-module/with-global-styles-provider.js.map +7 -0
- package/build-style/style-rtl.css +717 -0
- package/build-style/style.css +718 -0
- package/build-types/background-panel.d.ts +10 -0
- package/build-types/background-panel.d.ts.map +1 -0
- package/build-types/block-preview-panel.d.ts +7 -0
- package/build-types/block-preview-panel.d.ts.map +1 -0
- package/build-types/color-indicator-wrapper.d.ts +7 -0
- package/build-types/color-indicator-wrapper.d.ts.map +1 -0
- package/build-types/color-palette-panel.d.ts +6 -0
- package/build-types/color-palette-panel.d.ts.map +1 -0
- package/build-types/color-preview.d.ts +2 -0
- package/build-types/color-preview.d.ts.map +1 -0
- package/build-types/color-variations.d.ts +27 -0
- package/build-types/color-variations.d.ts.map +1 -0
- package/build-types/confirm-reset-shadow-dialog.d.ts +10 -0
- package/build-types/confirm-reset-shadow-dialog.d.ts.map +1 -0
- package/build-types/context.d.ts +10 -0
- package/build-types/context.d.ts.map +1 -0
- package/build-types/dimensions-panel.d.ts +2 -0
- package/build-types/dimensions-panel.d.ts.map +1 -0
- package/build-types/font-families.d.ts +4 -0
- package/build-types/font-families.d.ts.map +1 -0
- package/build-types/font-family-item.d.ts +7 -0
- package/build-types/font-family-item.d.ts.map +1 -0
- package/build-types/font-library-modal/collection-font-variant.d.ts +4 -0
- package/build-types/font-library-modal/collection-font-variant.d.ts.map +1 -0
- package/build-types/font-library-modal/context.d.ts +7 -0
- package/build-types/font-library-modal/context.d.ts.map +1 -0
- package/build-types/font-library-modal/font-card.d.ts +9 -0
- package/build-types/font-library-modal/font-card.d.ts.map +1 -0
- package/build-types/font-library-modal/font-collection.d.ts +5 -0
- package/build-types/font-library-modal/font-collection.d.ts.map +1 -0
- package/build-types/font-library-modal/font-demo.d.ts +4 -0
- package/build-types/font-library-modal/font-demo.d.ts.map +1 -0
- package/build-types/font-library-modal/google-fonts-confirm-dialog.d.ts +3 -0
- package/build-types/font-library-modal/google-fonts-confirm-dialog.d.ts.map +1 -0
- package/build-types/font-library-modal/index.d.ts +6 -0
- package/build-types/font-library-modal/index.d.ts.map +1 -0
- package/build-types/font-library-modal/installed-fonts.d.ts +3 -0
- package/build-types/font-library-modal/installed-fonts.d.ts.map +1 -0
- package/build-types/font-library-modal/library-font-details.d.ts +6 -0
- package/build-types/font-library-modal/library-font-details.d.ts.map +1 -0
- package/build-types/font-library-modal/library-font-variant.d.ts +7 -0
- package/build-types/font-library-modal/library-font-variant.d.ts.map +1 -0
- package/build-types/font-library-modal/resolvers.d.ts +43 -0
- package/build-types/font-library-modal/resolvers.d.ts.map +1 -0
- package/build-types/font-library-modal/types.d.ts +133 -0
- package/build-types/font-library-modal/types.d.ts.map +1 -0
- package/build-types/font-library-modal/upload-fonts.d.ts +3 -0
- package/build-types/font-library-modal/upload-fonts.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/constants.d.ts +4 -0
- package/build-types/font-library-modal/utils/constants.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/filter-fonts.d.ts +25 -0
- package/build-types/font-library-modal/utils/filter-fonts.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/fonts-outline.d.ts +7 -0
- package/build-types/font-library-modal/utils/fonts-outline.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/index.d.ts +21 -0
- package/build-types/font-library-modal/utils/index.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/make-families-from-faces.d.ts +6 -0
- package/build-types/font-library-modal/utils/make-families-from-faces.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/preview-styles.d.ts +13 -0
- package/build-types/font-library-modal/utils/preview-styles.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/set-immutably.d.ts +13 -0
- package/build-types/font-library-modal/utils/set-immutably.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/sort-font-faces.d.ts +6 -0
- package/build-types/font-library-modal/utils/sort-font-faces.d.ts.map +1 -0
- package/build-types/font-library-modal/utils/toggleFont.d.ts +38 -0
- package/build-types/font-library-modal/utils/toggleFont.d.ts.map +1 -0
- package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts +10 -0
- package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts.map +1 -0
- package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts +10 -0
- package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts.map +1 -0
- package/build-types/font-sizes/font-size-preview.d.ts +7 -0
- package/build-types/font-sizes/font-size-preview.d.ts.map +1 -0
- package/build-types/font-sizes/font-size.d.ts +4 -0
- package/build-types/font-sizes/font-size.d.ts.map +1 -0
- package/build-types/font-sizes/font-sizes-count.d.ts +3 -0
- package/build-types/font-sizes/font-sizes-count.d.ts.map +1 -0
- package/build-types/font-sizes/font-sizes.d.ts +3 -0
- package/build-types/font-sizes/font-sizes.d.ts.map +1 -0
- package/build-types/font-sizes/rename-font-size-dialog.d.ts +9 -0
- package/build-types/font-sizes/rename-font-size-dialog.d.ts.map +1 -0
- package/build-types/global-styles-ui.d.ts +26 -0
- package/build-types/global-styles-ui.d.ts.map +1 -0
- package/build-types/gradients-palette-panel.d.ts +6 -0
- package/build-types/gradients-palette-panel.d.ts.map +1 -0
- package/build-types/highlighted-colors.d.ts +7 -0
- package/build-types/highlighted-colors.d.ts.map +1 -0
- package/build-types/hooks.d.ts +46 -0
- package/build-types/hooks.d.ts.map +1 -0
- package/build-types/icon-with-current-color.d.ts +9 -0
- package/build-types/icon-with-current-color.d.ts.map +1 -0
- package/build-types/index.d.ts +6 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/navigation-button.d.ts +10 -0
- package/build-types/navigation-button.d.ts.map +1 -0
- package/build-types/pagination/index.d.ts +13 -0
- package/build-types/pagination/index.d.ts.map +1 -0
- package/build-types/palette.d.ts +6 -0
- package/build-types/palette.d.ts.map +1 -0
- package/build-types/preset-colors.d.ts +2 -0
- package/build-types/preset-colors.d.ts.map +1 -0
- package/build-types/preview-colors.d.ts +8 -0
- package/build-types/preview-colors.d.ts.map +1 -0
- package/build-types/preview-hooks.d.ts +9 -0
- package/build-types/preview-hooks.d.ts.map +1 -0
- package/build-types/preview-styles.d.ts +9 -0
- package/build-types/preview-styles.d.ts.map +1 -0
- package/build-types/preview-typography.d.ts +8 -0
- package/build-types/preview-typography.d.ts.map +1 -0
- package/build-types/preview-wrapper.d.ts +15 -0
- package/build-types/preview-wrapper.d.ts.map +1 -0
- package/build-types/provider.d.ts +15 -0
- package/build-types/provider.d.ts.map +1 -0
- package/build-types/root-menu.d.ts +3 -0
- package/build-types/root-menu.d.ts.map +1 -0
- package/build-types/screen-background.d.ts +3 -0
- package/build-types/screen-background.d.ts.map +1 -0
- package/build-types/screen-block-list.d.ts +4 -0
- package/build-types/screen-block-list.d.ts.map +1 -0
- package/build-types/screen-block.d.ts +7 -0
- package/build-types/screen-block.d.ts.map +1 -0
- package/build-types/screen-color-palette.d.ts +5 -0
- package/build-types/screen-color-palette.d.ts.map +1 -0
- package/build-types/screen-colors.d.ts +3 -0
- package/build-types/screen-colors.d.ts.map +1 -0
- package/build-types/screen-css.d.ts +3 -0
- package/build-types/screen-css.d.ts.map +1 -0
- package/build-types/screen-header.d.ts +8 -0
- package/build-types/screen-header.d.ts.map +1 -0
- package/build-types/screen-layout.d.ts +3 -0
- package/build-types/screen-layout.d.ts.map +1 -0
- package/build-types/screen-revisions/index.d.ts +6 -0
- package/build-types/screen-revisions/index.d.ts.map +1 -0
- package/build-types/screen-revisions/revisions-buttons.d.ts +23 -0
- package/build-types/screen-revisions/revisions-buttons.d.ts.map +1 -0
- package/build-types/screen-revisions/types.d.ts +17 -0
- package/build-types/screen-revisions/types.d.ts.map +1 -0
- package/build-types/screen-revisions/use-global-styles-revisions.d.ts +17 -0
- package/build-types/screen-revisions/use-global-styles-revisions.d.ts.map +1 -0
- package/build-types/screen-root.d.ts +3 -0
- package/build-types/screen-root.d.ts.map +1 -0
- package/build-types/screen-shadows.d.ts +3 -0
- package/build-types/screen-shadows.d.ts.map +1 -0
- package/build-types/screen-style-variations.d.ts +3 -0
- package/build-types/screen-style-variations.d.ts.map +1 -0
- package/build-types/screen-typography-element.d.ts +28 -0
- package/build-types/screen-typography-element.d.ts.map +1 -0
- package/build-types/screen-typography.d.ts +3 -0
- package/build-types/screen-typography.d.ts.map +1 -0
- package/build-types/shadow-utils.d.ts +126 -0
- package/build-types/shadow-utils.d.ts.map +1 -0
- package/build-types/shadows-edit-panel.d.ts +2 -0
- package/build-types/shadows-edit-panel.d.ts.map +1 -0
- package/build-types/shadows-panel.d.ts +3 -0
- package/build-types/shadows-panel.d.ts.map +1 -0
- package/build-types/size-control/index.d.ts +11 -0
- package/build-types/size-control/index.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts +6 -0
- package/build-types/stories/index.story.d.ts.map +1 -0
- package/build-types/style-variations-container.d.ts +6 -0
- package/build-types/style-variations-container.d.ts.map +1 -0
- package/build-types/style-variations-content.d.ts +2 -0
- package/build-types/style-variations-content.d.ts.map +1 -0
- package/build-types/style-variations.d.ts +25 -0
- package/build-types/style-variations.d.ts.map +1 -0
- package/build-types/subtitle.d.ts +7 -0
- package/build-types/subtitle.d.ts.map +1 -0
- package/build-types/test/shadow-utils.spec.d.ts +2 -0
- package/build-types/test/shadow-utils.spec.d.ts.map +1 -0
- package/build-types/test/utils.spec.d.ts +2 -0
- package/build-types/test/utils.spec.d.ts.map +1 -0
- package/build-types/typography-elements.d.ts +3 -0
- package/build-types/typography-elements.d.ts.map +1 -0
- package/build-types/typography-example.d.ts +7 -0
- package/build-types/typography-example.d.ts.map +1 -0
- package/build-types/typography-panel.d.ts +7 -0
- package/build-types/typography-panel.d.ts.map +1 -0
- package/build-types/typography-preview.d.ts +8 -0
- package/build-types/typography-preview.d.ts.map +1 -0
- package/build-types/typography-variations.d.ts +27 -0
- package/build-types/typography-variations.d.ts.map +1 -0
- package/build-types/utils.d.ts +63 -0
- package/build-types/utils.d.ts.map +1 -0
- package/build-types/variations/variation.d.ts +10 -0
- package/build-types/variations/variation.d.ts.map +1 -0
- package/build-types/variations/variations-color.d.ts +7 -0
- package/build-types/variations/variations-color.d.ts.map +1 -0
- package/build-types/variations/variations-panel.d.ts +13 -0
- package/build-types/variations/variations-panel.d.ts.map +1 -0
- package/build-types/variations/variations-typography.d.ts +7 -0
- package/build-types/variations/variations-typography.d.ts.map +1 -0
- package/build-types/with-global-styles-provider.d.ts +20 -0
- package/build-types/with-global-styles-provider.d.ts.map +1 -0
- package/package.json +67 -0
- package/src/README.md +99 -0
- package/src/background-panel.tsx +56 -0
- package/src/block-preview-panel.tsx +91 -0
- package/src/color-indicator-wrapper.tsx +34 -0
- package/src/color-palette-panel.tsx +111 -0
- package/src/color-preview.tsx +78 -0
- package/src/color-variations.tsx +35 -0
- package/src/confirm-reset-shadow-dialog.tsx +45 -0
- package/src/context.ts +21 -0
- package/src/dimensions-panel.tsx +85 -0
- package/src/font-families.tsx +127 -0
- package/src/font-family-item.tsx +52 -0
- package/src/font-library-modal/collection-font-variant.tsx +52 -0
- package/src/font-library-modal/context.tsx +591 -0
- package/src/font-library-modal/font-card.tsx +77 -0
- package/src/font-library-modal/font-collection.tsx +592 -0
- package/src/font-library-modal/font-demo.tsx +123 -0
- package/src/font-library-modal/google-fonts-confirm-dialog.tsx +57 -0
- package/src/font-library-modal/index.tsx +110 -0
- package/src/font-library-modal/installed-fonts.tsx +547 -0
- package/src/font-library-modal/lib/inflate.js +4112 -0
- package/src/font-library-modal/lib/lib-font.browser.d.ts +11 -0
- package/src/font-library-modal/lib/lib-font.browser.js +3861 -0
- package/src/font-library-modal/lib/unbrotli.js +2706 -0
- package/src/font-library-modal/library-font-details.tsx +46 -0
- package/src/font-library-modal/library-font-variant.tsx +67 -0
- package/src/font-library-modal/resolvers.tsx +100 -0
- package/src/font-library-modal/style.scss +222 -0
- package/src/font-library-modal/types.ts +176 -0
- package/src/font-library-modal/upload-fonts.tsx +269 -0
- package/src/font-library-modal/utils/constants.ts +23 -0
- package/src/font-library-modal/utils/filter-fonts.ts +47 -0
- package/src/font-library-modal/utils/fonts-outline.ts +33 -0
- package/src/font-library-modal/utils/index.ts +368 -0
- package/src/font-library-modal/utils/make-families-from-faces.ts +34 -0
- package/src/font-library-modal/utils/preview-styles.ts +167 -0
- package/src/font-library-modal/utils/set-immutably.ts +37 -0
- package/src/font-library-modal/utils/sort-font-faces.ts +46 -0
- package/src/font-library-modal/utils/toggleFont.ts +109 -0
- package/src/font-sizes/confirm-delete-font-size-dialog.tsx +51 -0
- package/src/font-sizes/confirm-reset-font-sizes-dialog.tsx +45 -0
- package/src/font-sizes/font-size-preview.tsx +47 -0
- package/src/font-sizes/font-size.tsx +289 -0
- package/src/font-sizes/font-sizes-count.tsx +37 -0
- package/src/font-sizes/font-sizes.tsx +265 -0
- package/src/font-sizes/rename-font-size-dialog.tsx +83 -0
- package/src/global-styles-ui.tsx +292 -0
- package/src/gradients-palette-panel.tsx +126 -0
- package/src/highlighted-colors.tsx +44 -0
- package/src/hooks.ts +251 -0
- package/src/icon-with-current-color.tsx +31 -0
- package/src/index.ts +7 -0
- package/src/lock-unlock.ts +10 -0
- package/src/navigation-button.tsx +53 -0
- package/src/pagination/index.tsx +107 -0
- package/src/pagination/style.scss +7 -0
- package/src/palette.tsx +101 -0
- package/src/preset-colors.tsx +18 -0
- package/src/preview-colors.tsx +68 -0
- package/src/preview-hooks.tsx +58 -0
- package/src/preview-styles.tsx +196 -0
- package/src/preview-typography.tsx +49 -0
- package/src/preview-wrapper.tsx +137 -0
- package/src/provider.tsx +54 -0
- package/src/root-menu.tsx +87 -0
- package/src/screen-background.tsx +37 -0
- package/src/screen-block-list.tsx +198 -0
- package/src/screen-block.tsx +370 -0
- package/src/screen-color-palette.tsx +47 -0
- package/src/screen-colors.tsx +67 -0
- package/src/screen-css.tsx +56 -0
- package/src/screen-header.tsx +56 -0
- package/src/screen-layout.tsx +34 -0
- package/src/screen-revisions/index.tsx +158 -0
- package/src/screen-revisions/revisions-buttons.tsx +259 -0
- package/src/screen-revisions/style.scss +194 -0
- package/src/screen-revisions/types.ts +18 -0
- package/src/screen-revisions/use-global-styles-revisions.tsx +204 -0
- package/src/screen-root.tsx +146 -0
- package/src/screen-shadows.tsx +13 -0
- package/src/screen-style-variations.tsx +36 -0
- package/src/screen-typography-element.tsx +127 -0
- package/src/screen-typography.tsx +41 -0
- package/src/shadow-utils.ts +167 -0
- package/src/shadows-edit-panel.tsx +559 -0
- package/src/shadows-panel.tsx +207 -0
- package/src/size-control/index.tsx +97 -0
- package/src/size-control/style.scss +7 -0
- package/src/stories/index.story.js +410 -0
- package/src/style-variations-container.tsx +153 -0
- package/src/style-variations-content.tsx +24 -0
- package/src/style-variations.tsx +33 -0
- package/src/style.scss +287 -0
- package/src/subtitle.tsx +17 -0
- package/src/test/shadow-utils.spec.js +251 -0
- package/src/test/utils.spec.js +59 -0
- package/src/typography-elements.tsx +113 -0
- package/src/typography-example.tsx +78 -0
- package/src/typography-panel.tsx +56 -0
- package/src/typography-preview.tsx +61 -0
- package/src/typography-variations.tsx +35 -0
- package/src/utils.ts +301 -0
- package/src/variations/style.scss +43 -0
- package/src/variations/variation.tsx +113 -0
- package/src/variations/variations-color.tsx +54 -0
- package/src/variations/variations-panel.tsx +79 -0
- package/src/variations/variations-typography.tsx +65 -0
- package/src/with-global-styles-provider.tsx +44 -0
- package/tsconfig.json +26 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,3754 @@
|
|
|
1
|
+
import unbrotli from "./unbrotli";
|
|
2
|
+
import GzipDecode from "./inflate";
|
|
3
|
+
let fetchFunction = globalThis.fetch;
|
|
4
|
+
class Event {
|
|
5
|
+
constructor(type, detail = {}, msg) {
|
|
6
|
+
this.type = type;
|
|
7
|
+
this.detail = detail;
|
|
8
|
+
this.msg = msg;
|
|
9
|
+
Object.defineProperty(this, `__mayPropagate`, {
|
|
10
|
+
enumerable: false,
|
|
11
|
+
writable: true
|
|
12
|
+
});
|
|
13
|
+
this.__mayPropagate = true;
|
|
14
|
+
}
|
|
15
|
+
preventDefault() {
|
|
16
|
+
}
|
|
17
|
+
stopPropagation() {
|
|
18
|
+
this.__mayPropagate = false;
|
|
19
|
+
}
|
|
20
|
+
valueOf() {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return this.msg ? `[${this.type} event]: ${this.msg}` : `[${this.type} event]`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class EventManager {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.listeners = {};
|
|
30
|
+
}
|
|
31
|
+
addEventListener(type, listener, useCapture) {
|
|
32
|
+
let bin = this.listeners[type] || [];
|
|
33
|
+
if (useCapture) bin.unshift(listener);
|
|
34
|
+
else bin.push(listener);
|
|
35
|
+
this.listeners[type] = bin;
|
|
36
|
+
}
|
|
37
|
+
removeEventListener(type, listener) {
|
|
38
|
+
let bin = this.listeners[type] || [];
|
|
39
|
+
let pos = bin.findIndex((e) => e === listener);
|
|
40
|
+
if (pos > -1) {
|
|
41
|
+
bin.splice(pos, 1);
|
|
42
|
+
this.listeners[type] = bin;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
dispatch(event) {
|
|
46
|
+
let bin = this.listeners[event.type];
|
|
47
|
+
if (bin) {
|
|
48
|
+
for (let l = 0, e = bin.length; l < e; l++) {
|
|
49
|
+
if (!event.__mayPropagate) break;
|
|
50
|
+
bin[l](event);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime();
|
|
56
|
+
function asText(data) {
|
|
57
|
+
return Array.from(data).map((v) => String.fromCharCode(v)).join(``);
|
|
58
|
+
}
|
|
59
|
+
class Parser {
|
|
60
|
+
constructor(dict, dataview, name2) {
|
|
61
|
+
this.name = (name2 || dict.tag || ``).trim();
|
|
62
|
+
this.length = dict.length;
|
|
63
|
+
this.start = dict.offset;
|
|
64
|
+
this.offset = 0;
|
|
65
|
+
this.data = dataview;
|
|
66
|
+
[
|
|
67
|
+
`getInt8`,
|
|
68
|
+
`getUint8`,
|
|
69
|
+
`getInt16`,
|
|
70
|
+
`getUint16`,
|
|
71
|
+
`getInt32`,
|
|
72
|
+
`getUint32`,
|
|
73
|
+
`getBigInt64`,
|
|
74
|
+
`getBigUint64`
|
|
75
|
+
].forEach((name3) => {
|
|
76
|
+
let fn = name3.replace(/get(Big)?/, "").toLowerCase();
|
|
77
|
+
let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8;
|
|
78
|
+
Object.defineProperty(this, fn, {
|
|
79
|
+
get: () => this.getValue(name3, increment)
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
get currentPosition() {
|
|
84
|
+
return this.start + this.offset;
|
|
85
|
+
}
|
|
86
|
+
set currentPosition(position) {
|
|
87
|
+
this.start = position;
|
|
88
|
+
this.offset = 0;
|
|
89
|
+
}
|
|
90
|
+
skip(n = 0, bits = 8) {
|
|
91
|
+
this.offset += n * bits / 8;
|
|
92
|
+
}
|
|
93
|
+
getValue(type, increment) {
|
|
94
|
+
let pos = this.start + this.offset;
|
|
95
|
+
this.offset += increment;
|
|
96
|
+
try {
|
|
97
|
+
return this.data[type](pos);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
console.error(`parser`, type, increment, this);
|
|
100
|
+
console.error(`parser`, this.start, this.offset);
|
|
101
|
+
throw e;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
flags(n) {
|
|
105
|
+
if (n === 8 || n === 16 || n === 32 || n === 64) {
|
|
106
|
+
return this[`uint${n}`].toString(2).padStart(n, 0).split(``).map((v) => v === "1");
|
|
107
|
+
}
|
|
108
|
+
console.error(
|
|
109
|
+
`Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long`
|
|
110
|
+
);
|
|
111
|
+
console.trace();
|
|
112
|
+
}
|
|
113
|
+
get tag() {
|
|
114
|
+
const t = this.uint32;
|
|
115
|
+
return asText([
|
|
116
|
+
t >> 24 & 255,
|
|
117
|
+
t >> 16 & 255,
|
|
118
|
+
t >> 8 & 255,
|
|
119
|
+
t & 255
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
get fixed() {
|
|
123
|
+
let major = this.int16;
|
|
124
|
+
let minor = Math.round(1e3 * this.uint16 / 65356);
|
|
125
|
+
return major + minor / 1e3;
|
|
126
|
+
}
|
|
127
|
+
get legacyFixed() {
|
|
128
|
+
let major = this.uint16;
|
|
129
|
+
let minor = this.uint16.toString(16).padStart(4, 0);
|
|
130
|
+
return parseFloat(`${major}.${minor}`);
|
|
131
|
+
}
|
|
132
|
+
get uint24() {
|
|
133
|
+
return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8;
|
|
134
|
+
}
|
|
135
|
+
get uint128() {
|
|
136
|
+
let value = 0;
|
|
137
|
+
for (let i = 0; i < 5; i++) {
|
|
138
|
+
let byte = this.uint8;
|
|
139
|
+
value = value * 128 + (byte & 127);
|
|
140
|
+
if (byte < 128) break;
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
get longdatetime() {
|
|
145
|
+
return new Date(startDate + 1e3 * parseInt(this.int64.toString()));
|
|
146
|
+
}
|
|
147
|
+
get fword() {
|
|
148
|
+
return this.int16;
|
|
149
|
+
}
|
|
150
|
+
get ufword() {
|
|
151
|
+
return this.uint16;
|
|
152
|
+
}
|
|
153
|
+
get Offset16() {
|
|
154
|
+
return this.uint16;
|
|
155
|
+
}
|
|
156
|
+
get Offset32() {
|
|
157
|
+
return this.uint32;
|
|
158
|
+
}
|
|
159
|
+
get F2DOT14() {
|
|
160
|
+
const bits = p.uint16;
|
|
161
|
+
const integer = [0, 1, -2, -1][bits >> 14];
|
|
162
|
+
const fraction = bits & 16383;
|
|
163
|
+
return integer + fraction / 16384;
|
|
164
|
+
}
|
|
165
|
+
verifyLength() {
|
|
166
|
+
if (this.offset != this.length) {
|
|
167
|
+
console.error(
|
|
168
|
+
`unexpected parsed table size (${this.offset}) for "${this.name}" (expected ${this.length})`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
readBytes(n = 0, position = 0, bits = 8, signed = false) {
|
|
173
|
+
n = n || this.length;
|
|
174
|
+
if (n === 0) return [];
|
|
175
|
+
if (position) this.currentPosition = position;
|
|
176
|
+
const fn = `${signed ? `` : `u`}int${bits}`, slice = [];
|
|
177
|
+
while (n--) slice.push(this[fn]);
|
|
178
|
+
return slice;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
class ParsedData {
|
|
182
|
+
constructor(parser) {
|
|
183
|
+
const pGetter = { enumerable: false, get: () => parser };
|
|
184
|
+
Object.defineProperty(this, `parser`, pGetter);
|
|
185
|
+
const start = parser.currentPosition;
|
|
186
|
+
const startGetter = { enumerable: false, get: () => start };
|
|
187
|
+
Object.defineProperty(this, `start`, startGetter);
|
|
188
|
+
}
|
|
189
|
+
load(struct) {
|
|
190
|
+
Object.keys(struct).forEach((p2) => {
|
|
191
|
+
let props = Object.getOwnPropertyDescriptor(struct, p2);
|
|
192
|
+
if (props.get) {
|
|
193
|
+
this[p2] = props.get.bind(this);
|
|
194
|
+
} else if (props.value !== void 0) {
|
|
195
|
+
this[p2] = props.value;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
if (this.parser.length) {
|
|
199
|
+
this.parser.verifyLength();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
class SimpleTable extends ParsedData {
|
|
204
|
+
constructor(dict, dataview, name2) {
|
|
205
|
+
const { parser, start } = super(
|
|
206
|
+
new Parser(dict, dataview, name2)
|
|
207
|
+
);
|
|
208
|
+
const pGetter = { enumerable: false, get: () => parser };
|
|
209
|
+
Object.defineProperty(this, `p`, pGetter);
|
|
210
|
+
const startGetter = { enumerable: false, get: () => start };
|
|
211
|
+
Object.defineProperty(this, `tableStart`, startGetter);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function lazy$1(object, property, getter) {
|
|
215
|
+
let val;
|
|
216
|
+
Object.defineProperty(object, property, {
|
|
217
|
+
get: () => {
|
|
218
|
+
if (val) return val;
|
|
219
|
+
val = getter();
|
|
220
|
+
return val;
|
|
221
|
+
},
|
|
222
|
+
enumerable: true
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
class SFNT extends SimpleTable {
|
|
226
|
+
constructor(font2, dataview, createTable2) {
|
|
227
|
+
const { p: p2 } = super({ offset: 0, length: 12 }, dataview, `sfnt`);
|
|
228
|
+
this.version = p2.uint32;
|
|
229
|
+
this.numTables = p2.uint16;
|
|
230
|
+
this.searchRange = p2.uint16;
|
|
231
|
+
this.entrySelector = p2.uint16;
|
|
232
|
+
this.rangeShift = p2.uint16;
|
|
233
|
+
p2.verifyLength();
|
|
234
|
+
this.directory = [...new Array(this.numTables)].map(
|
|
235
|
+
(_) => new TableRecord(p2)
|
|
236
|
+
);
|
|
237
|
+
this.tables = {};
|
|
238
|
+
this.directory.forEach((entry) => {
|
|
239
|
+
const getter = () => createTable2(
|
|
240
|
+
this.tables,
|
|
241
|
+
{
|
|
242
|
+
tag: entry.tag,
|
|
243
|
+
offset: entry.offset,
|
|
244
|
+
length: entry.length
|
|
245
|
+
},
|
|
246
|
+
dataview
|
|
247
|
+
);
|
|
248
|
+
lazy$1(this.tables, entry.tag.trim(), getter);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
class TableRecord {
|
|
253
|
+
constructor(p2) {
|
|
254
|
+
this.tag = p2.tag;
|
|
255
|
+
this.checksum = p2.uint32;
|
|
256
|
+
this.offset = p2.uint32;
|
|
257
|
+
this.length = p2.uint32;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const gzipDecode = GzipDecode.inflate || void 0;
|
|
261
|
+
let nativeGzipDecode = void 0;
|
|
262
|
+
class WOFF$1 extends SimpleTable {
|
|
263
|
+
constructor(font2, dataview, createTable2) {
|
|
264
|
+
const { p: p2 } = super({ offset: 0, length: 44 }, dataview, `woff`);
|
|
265
|
+
this.signature = p2.tag;
|
|
266
|
+
this.flavor = p2.uint32;
|
|
267
|
+
this.length = p2.uint32;
|
|
268
|
+
this.numTables = p2.uint16;
|
|
269
|
+
p2.uint16;
|
|
270
|
+
this.totalSfntSize = p2.uint32;
|
|
271
|
+
this.majorVersion = p2.uint16;
|
|
272
|
+
this.minorVersion = p2.uint16;
|
|
273
|
+
this.metaOffset = p2.uint32;
|
|
274
|
+
this.metaLength = p2.uint32;
|
|
275
|
+
this.metaOrigLength = p2.uint32;
|
|
276
|
+
this.privOffset = p2.uint32;
|
|
277
|
+
this.privLength = p2.uint32;
|
|
278
|
+
p2.verifyLength();
|
|
279
|
+
this.directory = [...new Array(this.numTables)].map(
|
|
280
|
+
(_) => new WoffTableDirectoryEntry(p2)
|
|
281
|
+
);
|
|
282
|
+
buildWoffLazyLookups(this, dataview, createTable2);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
class WoffTableDirectoryEntry {
|
|
286
|
+
constructor(p2) {
|
|
287
|
+
this.tag = p2.tag;
|
|
288
|
+
this.offset = p2.uint32;
|
|
289
|
+
this.compLength = p2.uint32;
|
|
290
|
+
this.origLength = p2.uint32;
|
|
291
|
+
this.origChecksum = p2.uint32;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function buildWoffLazyLookups(woff, dataview, createTable2) {
|
|
295
|
+
woff.tables = {};
|
|
296
|
+
woff.directory.forEach((entry) => {
|
|
297
|
+
lazy$1(woff.tables, entry.tag.trim(), () => {
|
|
298
|
+
let offset = 0;
|
|
299
|
+
let view = dataview;
|
|
300
|
+
if (entry.compLength !== entry.origLength) {
|
|
301
|
+
const data = dataview.buffer.slice(
|
|
302
|
+
entry.offset,
|
|
303
|
+
entry.offset + entry.compLength
|
|
304
|
+
);
|
|
305
|
+
let unpacked;
|
|
306
|
+
if (gzipDecode) {
|
|
307
|
+
unpacked = gzipDecode(new Uint8Array(data));
|
|
308
|
+
} else if (nativeGzipDecode) {
|
|
309
|
+
unpacked = nativeGzipDecode(new Uint8Array(data));
|
|
310
|
+
} else {
|
|
311
|
+
const msg = `no brotli decoder available to decode WOFF2 font`;
|
|
312
|
+
if (font.onerror) font.onerror(msg);
|
|
313
|
+
throw new Error(msg);
|
|
314
|
+
}
|
|
315
|
+
view = new DataView(unpacked.buffer);
|
|
316
|
+
} else {
|
|
317
|
+
offset = entry.offset;
|
|
318
|
+
}
|
|
319
|
+
return createTable2(
|
|
320
|
+
woff.tables,
|
|
321
|
+
{ tag: entry.tag, offset, length: entry.origLength },
|
|
322
|
+
view
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
const brotliDecode = unbrotli;
|
|
328
|
+
let nativeBrotliDecode = void 0;
|
|
329
|
+
class WOFF2$1 extends SimpleTable {
|
|
330
|
+
constructor(font2, dataview, createTable2) {
|
|
331
|
+
const { p: p2 } = super({ offset: 0, length: 48 }, dataview, `woff2`);
|
|
332
|
+
this.signature = p2.tag;
|
|
333
|
+
this.flavor = p2.uint32;
|
|
334
|
+
this.length = p2.uint32;
|
|
335
|
+
this.numTables = p2.uint16;
|
|
336
|
+
p2.uint16;
|
|
337
|
+
this.totalSfntSize = p2.uint32;
|
|
338
|
+
this.totalCompressedSize = p2.uint32;
|
|
339
|
+
this.majorVersion = p2.uint16;
|
|
340
|
+
this.minorVersion = p2.uint16;
|
|
341
|
+
this.metaOffset = p2.uint32;
|
|
342
|
+
this.metaLength = p2.uint32;
|
|
343
|
+
this.metaOrigLength = p2.uint32;
|
|
344
|
+
this.privOffset = p2.uint32;
|
|
345
|
+
this.privLength = p2.uint32;
|
|
346
|
+
p2.verifyLength();
|
|
347
|
+
this.directory = [...new Array(this.numTables)].map(
|
|
348
|
+
(_) => new Woff2TableDirectoryEntry(p2)
|
|
349
|
+
);
|
|
350
|
+
let dictOffset = p2.currentPosition;
|
|
351
|
+
this.directory[0].offset = 0;
|
|
352
|
+
this.directory.forEach((e, i) => {
|
|
353
|
+
let next = this.directory[i + 1];
|
|
354
|
+
if (next) {
|
|
355
|
+
next.offset = e.offset + (e.transformLength !== void 0 ? e.transformLength : e.origLength);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
let decoded;
|
|
359
|
+
let buffer = dataview.buffer.slice(dictOffset);
|
|
360
|
+
if (brotliDecode) {
|
|
361
|
+
decoded = brotliDecode(new Uint8Array(buffer));
|
|
362
|
+
} else if (nativeBrotliDecode) {
|
|
363
|
+
decoded = new Uint8Array(nativeBrotliDecode(buffer));
|
|
364
|
+
} else {
|
|
365
|
+
const msg = `no brotli decoder available to decode WOFF2 font`;
|
|
366
|
+
if (font2.onerror) font2.onerror(msg);
|
|
367
|
+
throw new Error(msg);
|
|
368
|
+
}
|
|
369
|
+
buildWoff2LazyLookups(this, decoded, createTable2);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
class Woff2TableDirectoryEntry {
|
|
373
|
+
constructor(p2) {
|
|
374
|
+
this.flags = p2.uint8;
|
|
375
|
+
const tagNumber = this.tagNumber = this.flags & 63;
|
|
376
|
+
if (tagNumber === 63) {
|
|
377
|
+
this.tag = p2.tag;
|
|
378
|
+
} else {
|
|
379
|
+
this.tag = getWOFF2Tag(tagNumber);
|
|
380
|
+
}
|
|
381
|
+
const transformVersion = this.transformVersion = (this.flags & 192) >> 6;
|
|
382
|
+
let hasTransforms = transformVersion !== 0;
|
|
383
|
+
if (this.tag === `glyf` || this.tag === `loca`) {
|
|
384
|
+
hasTransforms = this.transformVersion !== 3;
|
|
385
|
+
}
|
|
386
|
+
this.origLength = p2.uint128;
|
|
387
|
+
if (hasTransforms) {
|
|
388
|
+
this.transformLength = p2.uint128;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function buildWoff2LazyLookups(woff2, decoded, createTable2) {
|
|
393
|
+
woff2.tables = {};
|
|
394
|
+
woff2.directory.forEach((entry) => {
|
|
395
|
+
lazy$1(woff2.tables, entry.tag.trim(), () => {
|
|
396
|
+
const start = entry.offset;
|
|
397
|
+
const end = start + (entry.transformLength ? entry.transformLength : entry.origLength);
|
|
398
|
+
const data = new DataView(decoded.slice(start, end).buffer);
|
|
399
|
+
try {
|
|
400
|
+
return createTable2(
|
|
401
|
+
woff2.tables,
|
|
402
|
+
{ tag: entry.tag, offset: 0, length: entry.origLength },
|
|
403
|
+
data
|
|
404
|
+
);
|
|
405
|
+
} catch (e) {
|
|
406
|
+
console.error(e);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function getWOFF2Tag(flag) {
|
|
412
|
+
return [
|
|
413
|
+
`cmap`,
|
|
414
|
+
`head`,
|
|
415
|
+
`hhea`,
|
|
416
|
+
`hmtx`,
|
|
417
|
+
`maxp`,
|
|
418
|
+
`name`,
|
|
419
|
+
`OS/2`,
|
|
420
|
+
`post`,
|
|
421
|
+
`cvt `,
|
|
422
|
+
`fpgm`,
|
|
423
|
+
`glyf`,
|
|
424
|
+
`loca`,
|
|
425
|
+
`prep`,
|
|
426
|
+
`CFF `,
|
|
427
|
+
`VORG`,
|
|
428
|
+
`EBDT`,
|
|
429
|
+
`EBLC`,
|
|
430
|
+
`gasp`,
|
|
431
|
+
`hdmx`,
|
|
432
|
+
`kern`,
|
|
433
|
+
`LTSH`,
|
|
434
|
+
`PCLT`,
|
|
435
|
+
`VDMX`,
|
|
436
|
+
`vhea`,
|
|
437
|
+
`vmtx`,
|
|
438
|
+
`BASE`,
|
|
439
|
+
`GDEF`,
|
|
440
|
+
`GPOS`,
|
|
441
|
+
`GSUB`,
|
|
442
|
+
`EBSC`,
|
|
443
|
+
`JSTF`,
|
|
444
|
+
`MATH`,
|
|
445
|
+
`CBDT`,
|
|
446
|
+
`CBLC`,
|
|
447
|
+
`COLR`,
|
|
448
|
+
`CPAL`,
|
|
449
|
+
`SVG `,
|
|
450
|
+
`sbix`,
|
|
451
|
+
`acnt`,
|
|
452
|
+
`avar`,
|
|
453
|
+
`bdat`,
|
|
454
|
+
`bloc`,
|
|
455
|
+
`bsln`,
|
|
456
|
+
`cvar`,
|
|
457
|
+
`fdsc`,
|
|
458
|
+
`feat`,
|
|
459
|
+
`fmtx`,
|
|
460
|
+
`fvar`,
|
|
461
|
+
`gvar`,
|
|
462
|
+
`hsty`,
|
|
463
|
+
`just`,
|
|
464
|
+
`lcar`,
|
|
465
|
+
`mort`,
|
|
466
|
+
`morx`,
|
|
467
|
+
`opbd`,
|
|
468
|
+
`prop`,
|
|
469
|
+
`trak`,
|
|
470
|
+
`Zapf`,
|
|
471
|
+
`Silf`,
|
|
472
|
+
`Glat`,
|
|
473
|
+
`Gloc`,
|
|
474
|
+
`Feat`,
|
|
475
|
+
`Sill`
|
|
476
|
+
][flag & 63];
|
|
477
|
+
}
|
|
478
|
+
const tableClasses = {};
|
|
479
|
+
let tableClassesLoaded = false;
|
|
480
|
+
Promise.all([
|
|
481
|
+
Promise.resolve().then(function() {
|
|
482
|
+
return cmap$1;
|
|
483
|
+
}),
|
|
484
|
+
Promise.resolve().then(function() {
|
|
485
|
+
return head$1;
|
|
486
|
+
}),
|
|
487
|
+
Promise.resolve().then(function() {
|
|
488
|
+
return hhea$1;
|
|
489
|
+
}),
|
|
490
|
+
Promise.resolve().then(function() {
|
|
491
|
+
return hmtx$1;
|
|
492
|
+
}),
|
|
493
|
+
Promise.resolve().then(function() {
|
|
494
|
+
return maxp$1;
|
|
495
|
+
}),
|
|
496
|
+
Promise.resolve().then(function() {
|
|
497
|
+
return name$1;
|
|
498
|
+
}),
|
|
499
|
+
Promise.resolve().then(function() {
|
|
500
|
+
return OS2$1;
|
|
501
|
+
}),
|
|
502
|
+
Promise.resolve().then(function() {
|
|
503
|
+
return post$1;
|
|
504
|
+
}),
|
|
505
|
+
Promise.resolve().then(function() {
|
|
506
|
+
return BASE$1;
|
|
507
|
+
}),
|
|
508
|
+
Promise.resolve().then(function() {
|
|
509
|
+
return GDEF$1;
|
|
510
|
+
}),
|
|
511
|
+
Promise.resolve().then(function() {
|
|
512
|
+
return GSUB$1;
|
|
513
|
+
}),
|
|
514
|
+
Promise.resolve().then(function() {
|
|
515
|
+
return GPOS$1;
|
|
516
|
+
}),
|
|
517
|
+
Promise.resolve().then(function() {
|
|
518
|
+
return SVG$1;
|
|
519
|
+
}),
|
|
520
|
+
Promise.resolve().then(function() {
|
|
521
|
+
return fvar$1;
|
|
522
|
+
}),
|
|
523
|
+
Promise.resolve().then(function() {
|
|
524
|
+
return cvt$1;
|
|
525
|
+
}),
|
|
526
|
+
Promise.resolve().then(function() {
|
|
527
|
+
return fpgm$1;
|
|
528
|
+
}),
|
|
529
|
+
Promise.resolve().then(function() {
|
|
530
|
+
return gasp$1;
|
|
531
|
+
}),
|
|
532
|
+
Promise.resolve().then(function() {
|
|
533
|
+
return glyf$1;
|
|
534
|
+
}),
|
|
535
|
+
Promise.resolve().then(function() {
|
|
536
|
+
return loca$1;
|
|
537
|
+
}),
|
|
538
|
+
Promise.resolve().then(function() {
|
|
539
|
+
return prep$1;
|
|
540
|
+
}),
|
|
541
|
+
Promise.resolve().then(function() {
|
|
542
|
+
return CFF$1;
|
|
543
|
+
}),
|
|
544
|
+
Promise.resolve().then(function() {
|
|
545
|
+
return CFF2$1;
|
|
546
|
+
}),
|
|
547
|
+
Promise.resolve().then(function() {
|
|
548
|
+
return VORG$1;
|
|
549
|
+
}),
|
|
550
|
+
Promise.resolve().then(function() {
|
|
551
|
+
return EBLC$1;
|
|
552
|
+
}),
|
|
553
|
+
Promise.resolve().then(function() {
|
|
554
|
+
return EBDT$1;
|
|
555
|
+
}),
|
|
556
|
+
Promise.resolve().then(function() {
|
|
557
|
+
return EBSC$1;
|
|
558
|
+
}),
|
|
559
|
+
Promise.resolve().then(function() {
|
|
560
|
+
return CBLC$1;
|
|
561
|
+
}),
|
|
562
|
+
Promise.resolve().then(function() {
|
|
563
|
+
return CBDT$1;
|
|
564
|
+
}),
|
|
565
|
+
Promise.resolve().then(function() {
|
|
566
|
+
return sbix$1;
|
|
567
|
+
}),
|
|
568
|
+
Promise.resolve().then(function() {
|
|
569
|
+
return COLR$1;
|
|
570
|
+
}),
|
|
571
|
+
Promise.resolve().then(function() {
|
|
572
|
+
return CPAL$1;
|
|
573
|
+
}),
|
|
574
|
+
Promise.resolve().then(function() {
|
|
575
|
+
return DSIG$1;
|
|
576
|
+
}),
|
|
577
|
+
Promise.resolve().then(function() {
|
|
578
|
+
return hdmx$1;
|
|
579
|
+
}),
|
|
580
|
+
Promise.resolve().then(function() {
|
|
581
|
+
return kern$1;
|
|
582
|
+
}),
|
|
583
|
+
Promise.resolve().then(function() {
|
|
584
|
+
return LTSH$1;
|
|
585
|
+
}),
|
|
586
|
+
Promise.resolve().then(function() {
|
|
587
|
+
return MERG$1;
|
|
588
|
+
}),
|
|
589
|
+
Promise.resolve().then(function() {
|
|
590
|
+
return meta$1;
|
|
591
|
+
}),
|
|
592
|
+
Promise.resolve().then(function() {
|
|
593
|
+
return PCLT$1;
|
|
594
|
+
}),
|
|
595
|
+
Promise.resolve().then(function() {
|
|
596
|
+
return VDMX$1;
|
|
597
|
+
}),
|
|
598
|
+
Promise.resolve().then(function() {
|
|
599
|
+
return vhea$1;
|
|
600
|
+
}),
|
|
601
|
+
Promise.resolve().then(function() {
|
|
602
|
+
return vmtx$1;
|
|
603
|
+
})
|
|
604
|
+
]).then((data) => {
|
|
605
|
+
data.forEach((e) => {
|
|
606
|
+
let name2 = Object.keys(e)[0];
|
|
607
|
+
tableClasses[name2] = e[name2];
|
|
608
|
+
});
|
|
609
|
+
tableClassesLoaded = true;
|
|
610
|
+
});
|
|
611
|
+
function createTable(tables, dict, dataview) {
|
|
612
|
+
let name2 = dict.tag.replace(/[^\w\d]/g, ``);
|
|
613
|
+
let Type = tableClasses[name2];
|
|
614
|
+
if (Type) return new Type(dict, dataview, tables);
|
|
615
|
+
console.warn(
|
|
616
|
+
`lib-font has no definition for ${name2}. The table was skipped.`
|
|
617
|
+
);
|
|
618
|
+
return {};
|
|
619
|
+
}
|
|
620
|
+
function loadTableClasses() {
|
|
621
|
+
let count = 0;
|
|
622
|
+
function checkLoaded(resolve, reject) {
|
|
623
|
+
if (!tableClassesLoaded) {
|
|
624
|
+
if (count > 10) {
|
|
625
|
+
return reject(new Error(`loading took too long`));
|
|
626
|
+
}
|
|
627
|
+
count++;
|
|
628
|
+
return setTimeout(() => checkLoaded(resolve), 250);
|
|
629
|
+
}
|
|
630
|
+
resolve(createTable);
|
|
631
|
+
}
|
|
632
|
+
return new Promise((resolve, reject) => checkLoaded(resolve));
|
|
633
|
+
}
|
|
634
|
+
function getFontCSSFormat(path, errorOnStyle) {
|
|
635
|
+
let pos = path.lastIndexOf(`.`);
|
|
636
|
+
let ext = (path.substring(pos + 1) || ``).toLowerCase();
|
|
637
|
+
let format = {
|
|
638
|
+
ttf: `truetype`,
|
|
639
|
+
otf: `opentype`,
|
|
640
|
+
woff: `woff`,
|
|
641
|
+
woff2: `woff2`
|
|
642
|
+
}[ext];
|
|
643
|
+
if (format) return format;
|
|
644
|
+
let msg = {
|
|
645
|
+
eot: `The .eot format is not supported: it died in January 12, 2016, when Microsoft retired all versions of IE that didn't already support WOFF.`,
|
|
646
|
+
svg: `The .svg format is not supported: SVG fonts (not to be confused with OpenType with embedded SVG) were so bad we took the entire fonts chapter out of the SVG specification again.`,
|
|
647
|
+
fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`,
|
|
648
|
+
ttc: `Based on the current CSS specification, font collections are not (yet?) supported.`
|
|
649
|
+
}[ext];
|
|
650
|
+
if (!msg) msg = `${path} is not a known webfont format.`;
|
|
651
|
+
if (errorOnStyle) {
|
|
652
|
+
throw new Error(msg);
|
|
653
|
+
} else {
|
|
654
|
+
console.warn(`Could not load font: ${msg}`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async function setupFontFace(name2, url, options = {}) {
|
|
658
|
+
if (!globalThis.document) return;
|
|
659
|
+
let format = getFontCSSFormat(url, options.errorOnStyle);
|
|
660
|
+
if (!format) return;
|
|
661
|
+
let style = document.createElement(`style`);
|
|
662
|
+
style.className = `injected-by-Font-js`;
|
|
663
|
+
let rules = [];
|
|
664
|
+
if (options.styleRules) {
|
|
665
|
+
rules = Object.entries(options.styleRules).map(
|
|
666
|
+
([key, value]) => `${key}: ${value};`
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
style.textContent = `
|
|
670
|
+
@font-face {
|
|
671
|
+
font-family: "${name2}";
|
|
672
|
+
${rules.join(
|
|
673
|
+
`
|
|
674
|
+
`
|
|
675
|
+
)}
|
|
676
|
+
src: url("${url}") format("${format}");
|
|
677
|
+
}`;
|
|
678
|
+
globalThis.document.head.appendChild(style);
|
|
679
|
+
return style;
|
|
680
|
+
}
|
|
681
|
+
const TTF = [0, 1, 0, 0];
|
|
682
|
+
const OTF = [79, 84, 84, 79];
|
|
683
|
+
const WOFF = [119, 79, 70, 70];
|
|
684
|
+
const WOFF2 = [119, 79, 70, 50];
|
|
685
|
+
function match(ar1, ar2) {
|
|
686
|
+
if (ar1.length !== ar2.length) return;
|
|
687
|
+
for (let i = 0; i < ar1.length; i++) {
|
|
688
|
+
if (ar1[i] !== ar2[i]) return;
|
|
689
|
+
}
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
function validFontFormat(dataview) {
|
|
693
|
+
const LEAD_BYTES = [
|
|
694
|
+
dataview.getUint8(0),
|
|
695
|
+
dataview.getUint8(1),
|
|
696
|
+
dataview.getUint8(2),
|
|
697
|
+
dataview.getUint8(3)
|
|
698
|
+
];
|
|
699
|
+
if (match(LEAD_BYTES, TTF) || match(LEAD_BYTES, OTF)) return `SFNT`;
|
|
700
|
+
if (match(LEAD_BYTES, WOFF)) return `WOFF`;
|
|
701
|
+
if (match(LEAD_BYTES, WOFF2)) return `WOFF2`;
|
|
702
|
+
}
|
|
703
|
+
function checkFetchResponseStatus(response) {
|
|
704
|
+
if (!response.ok) {
|
|
705
|
+
throw new Error(
|
|
706
|
+
`HTTP ${response.status} - ${response.statusText}`
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
return response;
|
|
710
|
+
}
|
|
711
|
+
class Font extends EventManager {
|
|
712
|
+
constructor(name2, options = {}) {
|
|
713
|
+
super();
|
|
714
|
+
this.name = name2;
|
|
715
|
+
this.options = options;
|
|
716
|
+
this.metrics = false;
|
|
717
|
+
}
|
|
718
|
+
get src() {
|
|
719
|
+
return this.__src;
|
|
720
|
+
}
|
|
721
|
+
set src(src) {
|
|
722
|
+
this.__src = src;
|
|
723
|
+
(async () => {
|
|
724
|
+
if (globalThis.document && !this.options.skipStyleSheet) {
|
|
725
|
+
await setupFontFace(this.name, src, this.options);
|
|
726
|
+
}
|
|
727
|
+
this.loadFont(src);
|
|
728
|
+
})();
|
|
729
|
+
}
|
|
730
|
+
async loadFont(url, filename) {
|
|
731
|
+
fetch(url).then(
|
|
732
|
+
(response) => checkFetchResponseStatus(response) && response.arrayBuffer()
|
|
733
|
+
).then(
|
|
734
|
+
(buffer) => this.fromDataBuffer(buffer, filename || url)
|
|
735
|
+
).catch((err) => {
|
|
736
|
+
const evt = new Event(
|
|
737
|
+
`error`,
|
|
738
|
+
err,
|
|
739
|
+
`Failed to load font at ${filename || url}`
|
|
740
|
+
);
|
|
741
|
+
this.dispatch(evt);
|
|
742
|
+
if (this.onerror) this.onerror(evt);
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
async fromDataBuffer(buffer, filenameOrUrL) {
|
|
746
|
+
this.fontData = new DataView(buffer);
|
|
747
|
+
let type = validFontFormat(this.fontData);
|
|
748
|
+
if (!type) {
|
|
749
|
+
throw new Error(
|
|
750
|
+
`${filenameOrUrL} is either an unsupported font format, or not a font at all.`
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
await this.parseBasicData(type);
|
|
754
|
+
const evt = new Event("load", { font: this });
|
|
755
|
+
this.dispatch(evt);
|
|
756
|
+
if (this.onload) this.onload(evt);
|
|
757
|
+
}
|
|
758
|
+
async parseBasicData(type) {
|
|
759
|
+
return loadTableClasses().then((createTable2) => {
|
|
760
|
+
if (type === `SFNT`) {
|
|
761
|
+
this.opentype = new SFNT(this, this.fontData, createTable2);
|
|
762
|
+
}
|
|
763
|
+
if (type === `WOFF`) {
|
|
764
|
+
this.opentype = new WOFF$1(this, this.fontData, createTable2);
|
|
765
|
+
}
|
|
766
|
+
if (type === `WOFF2`) {
|
|
767
|
+
this.opentype = new WOFF2$1(this, this.fontData, createTable2);
|
|
768
|
+
}
|
|
769
|
+
return this.opentype;
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
getGlyphId(char) {
|
|
773
|
+
return this.opentype.tables.cmap.getGlyphId(char);
|
|
774
|
+
}
|
|
775
|
+
reverse(glyphid) {
|
|
776
|
+
return this.opentype.tables.cmap.reverse(glyphid);
|
|
777
|
+
}
|
|
778
|
+
supports(char) {
|
|
779
|
+
return this.getGlyphId(char) !== 0;
|
|
780
|
+
}
|
|
781
|
+
supportsVariation(variation) {
|
|
782
|
+
return this.opentype.tables.cmap.supportsVariation(variation) !== false;
|
|
783
|
+
}
|
|
784
|
+
measureText(text, size = 16) {
|
|
785
|
+
if (this.__unloaded)
|
|
786
|
+
throw new Error(
|
|
787
|
+
"Cannot measure text: font was unloaded. Please reload before calling measureText()"
|
|
788
|
+
);
|
|
789
|
+
let d = document.createElement("div");
|
|
790
|
+
d.textContent = text;
|
|
791
|
+
d.style.fontFamily = this.name;
|
|
792
|
+
d.style.fontSize = `${size}px`;
|
|
793
|
+
d.style.color = `transparent`;
|
|
794
|
+
d.style.background = `transparent`;
|
|
795
|
+
d.style.top = `0`;
|
|
796
|
+
d.style.left = `0`;
|
|
797
|
+
d.style.position = `absolute`;
|
|
798
|
+
document.body.appendChild(d);
|
|
799
|
+
let bbox = d.getBoundingClientRect();
|
|
800
|
+
document.body.removeChild(d);
|
|
801
|
+
const OS22 = this.opentype.tables["OS/2"];
|
|
802
|
+
bbox.fontSize = size;
|
|
803
|
+
bbox.ascender = OS22.sTypoAscender;
|
|
804
|
+
bbox.descender = OS22.sTypoDescender;
|
|
805
|
+
return bbox;
|
|
806
|
+
}
|
|
807
|
+
unload() {
|
|
808
|
+
if (this.styleElement.parentNode) {
|
|
809
|
+
this.styleElement.parentNode.removeElement(this.styleElement);
|
|
810
|
+
const evt = new Event("unload", { font: this });
|
|
811
|
+
this.dispatch(evt);
|
|
812
|
+
if (this.onunload) this.onunload(evt);
|
|
813
|
+
}
|
|
814
|
+
this._unloaded = true;
|
|
815
|
+
}
|
|
816
|
+
load() {
|
|
817
|
+
if (this.__unloaded) {
|
|
818
|
+
delete this.__unloaded;
|
|
819
|
+
document.head.appendChild(this.styleElement);
|
|
820
|
+
const evt = new Event("load", { font: this });
|
|
821
|
+
this.dispatch(evt);
|
|
822
|
+
if (this.onload) this.onload(evt);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
globalThis.Font = Font;
|
|
827
|
+
class Subtable extends ParsedData {
|
|
828
|
+
constructor(p2, plaformID, encodingID) {
|
|
829
|
+
super(p2);
|
|
830
|
+
this.plaformID = plaformID;
|
|
831
|
+
this.encodingID = encodingID;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
class Format0 extends Subtable {
|
|
835
|
+
constructor(p2, platformID, encodingID) {
|
|
836
|
+
super(p2, platformID, encodingID);
|
|
837
|
+
this.format = 0;
|
|
838
|
+
this.length = p2.uint16;
|
|
839
|
+
this.language = p2.uint16;
|
|
840
|
+
this.glyphIdArray = [...new Array(256)].map((_) => p2.uint8);
|
|
841
|
+
}
|
|
842
|
+
supports(charCode) {
|
|
843
|
+
if (charCode.charCodeAt) {
|
|
844
|
+
charCode = -1;
|
|
845
|
+
console.warn(
|
|
846
|
+
`supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.`
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
return 0 <= charCode && charCode <= 255;
|
|
850
|
+
}
|
|
851
|
+
reverse(glyphID) {
|
|
852
|
+
console.warn(`reverse not implemented for cmap subtable format 0`);
|
|
853
|
+
return {};
|
|
854
|
+
}
|
|
855
|
+
getSupportedCharCodes() {
|
|
856
|
+
return [{ start: 1, end: 256 }];
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
class Format2 extends Subtable {
|
|
860
|
+
constructor(p2, platformID, encodingID) {
|
|
861
|
+
super(p2, platformID, encodingID);
|
|
862
|
+
this.format = 2;
|
|
863
|
+
this.length = p2.uint16;
|
|
864
|
+
this.language = p2.uint16;
|
|
865
|
+
this.subHeaderKeys = [...new Array(256)].map((_) => p2.uint16);
|
|
866
|
+
const subHeaderCount = Math.max(...this.subHeaderKeys);
|
|
867
|
+
const subHeaderOffset = p2.currentPosition;
|
|
868
|
+
lazy$1(this, `subHeaders`, () => {
|
|
869
|
+
p2.currentPosition = subHeaderOffset;
|
|
870
|
+
return [...new Array(subHeaderCount)].map(
|
|
871
|
+
(_) => new SubHeader(p2)
|
|
872
|
+
);
|
|
873
|
+
});
|
|
874
|
+
const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8;
|
|
875
|
+
lazy$1(this, `glyphIndexArray`, () => {
|
|
876
|
+
p2.currentPosition = glyphIndexOffset;
|
|
877
|
+
return [...new Array(subHeaderCount)].map((_) => p2.uint16);
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
supports(charCode) {
|
|
881
|
+
if (charCode.charCodeAt) {
|
|
882
|
+
charCode = -1;
|
|
883
|
+
console.warn(
|
|
884
|
+
`supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
const low = charCode && 255;
|
|
888
|
+
const high = charCode && 65280;
|
|
889
|
+
const subHeaderKey = this.subHeaders[high];
|
|
890
|
+
const subheader = this.subHeaders[subHeaderKey];
|
|
891
|
+
const first = subheader.firstCode;
|
|
892
|
+
const last = first + subheader.entryCount;
|
|
893
|
+
return first <= low && low <= last;
|
|
894
|
+
}
|
|
895
|
+
reverse(glyphID) {
|
|
896
|
+
console.warn(`reverse not implemented for cmap subtable format 2`);
|
|
897
|
+
return {};
|
|
898
|
+
}
|
|
899
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
900
|
+
if (preservePropNames) {
|
|
901
|
+
return this.subHeaders.map((h) => ({
|
|
902
|
+
firstCode: h.firstCode,
|
|
903
|
+
lastCode: h.lastCode
|
|
904
|
+
}));
|
|
905
|
+
}
|
|
906
|
+
return this.subHeaders.map((h) => ({
|
|
907
|
+
start: h.firstCode,
|
|
908
|
+
end: h.lastCode
|
|
909
|
+
}));
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
class SubHeader {
|
|
913
|
+
constructor(p2) {
|
|
914
|
+
this.firstCode = p2.uint16;
|
|
915
|
+
this.entryCount = p2.uint16;
|
|
916
|
+
this.lastCode = this.first + this.entryCount;
|
|
917
|
+
this.idDelta = p2.int16;
|
|
918
|
+
this.idRangeOffset = p2.uint16;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
class Format4 extends Subtable {
|
|
922
|
+
constructor(p2, platformID, encodingID) {
|
|
923
|
+
super(p2, platformID, encodingID);
|
|
924
|
+
this.format = 4;
|
|
925
|
+
this.length = p2.uint16;
|
|
926
|
+
this.language = p2.uint16;
|
|
927
|
+
this.segCountX2 = p2.uint16;
|
|
928
|
+
this.segCount = this.segCountX2 / 2;
|
|
929
|
+
this.searchRange = p2.uint16;
|
|
930
|
+
this.entrySelector = p2.uint16;
|
|
931
|
+
this.rangeShift = p2.uint16;
|
|
932
|
+
const endCodePosition = p2.currentPosition;
|
|
933
|
+
lazy$1(
|
|
934
|
+
this,
|
|
935
|
+
`endCode`,
|
|
936
|
+
() => p2.readBytes(this.segCount, endCodePosition, 16)
|
|
937
|
+
);
|
|
938
|
+
const startCodePosition = endCodePosition + 2 + this.segCountX2;
|
|
939
|
+
lazy$1(
|
|
940
|
+
this,
|
|
941
|
+
`startCode`,
|
|
942
|
+
() => p2.readBytes(this.segCount, startCodePosition, 16)
|
|
943
|
+
);
|
|
944
|
+
const idDeltaPosition = startCodePosition + this.segCountX2;
|
|
945
|
+
lazy$1(
|
|
946
|
+
this,
|
|
947
|
+
`idDelta`,
|
|
948
|
+
() => p2.readBytes(this.segCount, idDeltaPosition, 16, true)
|
|
949
|
+
);
|
|
950
|
+
const idRangePosition = idDeltaPosition + this.segCountX2;
|
|
951
|
+
lazy$1(
|
|
952
|
+
this,
|
|
953
|
+
`idRangeOffset`,
|
|
954
|
+
() => p2.readBytes(this.segCount, idRangePosition, 16)
|
|
955
|
+
);
|
|
956
|
+
const glyphIdArrayPosition = idRangePosition + this.segCountX2;
|
|
957
|
+
const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart);
|
|
958
|
+
lazy$1(
|
|
959
|
+
this,
|
|
960
|
+
`glyphIdArray`,
|
|
961
|
+
() => p2.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16)
|
|
962
|
+
);
|
|
963
|
+
lazy$1(
|
|
964
|
+
this,
|
|
965
|
+
`segments`,
|
|
966
|
+
() => this.buildSegments(idRangePosition, glyphIdArrayPosition, p2)
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
buildSegments(idRangePosition, glyphIdArrayPosition, p2) {
|
|
970
|
+
const build = (_, i) => {
|
|
971
|
+
let startCode = this.startCode[i], endCode = this.endCode[i], idDelta = this.idDelta[i], idRangeOffset = this.idRangeOffset[i], idRangeOffsetPointer = idRangePosition + 2 * i, glyphIDs = [];
|
|
972
|
+
if (idRangeOffset === 0) {
|
|
973
|
+
for (let i2 = startCode + idDelta, e = endCode + idDelta; i2 <= e; i2++) {
|
|
974
|
+
glyphIDs.push(i2);
|
|
975
|
+
}
|
|
976
|
+
} else {
|
|
977
|
+
for (let i2 = 0, e = endCode - startCode; i2 <= e; i2++) {
|
|
978
|
+
p2.currentPosition = idRangeOffsetPointer + idRangeOffset + i2 * 2;
|
|
979
|
+
glyphIDs.push(p2.uint16);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return {
|
|
983
|
+
startCode,
|
|
984
|
+
endCode,
|
|
985
|
+
idDelta,
|
|
986
|
+
idRangeOffset,
|
|
987
|
+
glyphIDs
|
|
988
|
+
};
|
|
989
|
+
};
|
|
990
|
+
return [...new Array(this.segCount)].map(build);
|
|
991
|
+
}
|
|
992
|
+
reverse(glyphID) {
|
|
993
|
+
let s = this.segments.find((v) => v.glyphIDs.includes(glyphID));
|
|
994
|
+
if (!s) return {};
|
|
995
|
+
const code = s.startCode + s.glyphIDs.indexOf(glyphID);
|
|
996
|
+
return { code, unicode: String.fromCodePoint(code) };
|
|
997
|
+
}
|
|
998
|
+
getGlyphId(charCode) {
|
|
999
|
+
if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
|
|
1000
|
+
if (55296 <= charCode && charCode <= 57343) return 0;
|
|
1001
|
+
if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
|
|
1002
|
+
return 0;
|
|
1003
|
+
let segment = this.segments.find(
|
|
1004
|
+
(s) => s.startCode <= charCode && charCode <= s.endCode
|
|
1005
|
+
);
|
|
1006
|
+
if (!segment) return 0;
|
|
1007
|
+
return segment.glyphIDs[charCode - segment.startCode];
|
|
1008
|
+
}
|
|
1009
|
+
supports(charCode) {
|
|
1010
|
+
return this.getGlyphId(charCode) !== 0;
|
|
1011
|
+
}
|
|
1012
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
1013
|
+
if (preservePropNames) return this.segments;
|
|
1014
|
+
return this.segments.map((v) => ({
|
|
1015
|
+
start: v.startCode,
|
|
1016
|
+
end: v.endCode
|
|
1017
|
+
}));
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
class Format6 extends Subtable {
|
|
1021
|
+
constructor(p2, platformID, encodingID) {
|
|
1022
|
+
super(p2, platformID, encodingID);
|
|
1023
|
+
this.format = 6;
|
|
1024
|
+
this.length = p2.uint16;
|
|
1025
|
+
this.language = p2.uint16;
|
|
1026
|
+
this.firstCode = p2.uint16;
|
|
1027
|
+
this.entryCount = p2.uint16;
|
|
1028
|
+
this.lastCode = this.firstCode + this.entryCount - 1;
|
|
1029
|
+
const getter = () => [...new Array(this.entryCount)].map((_) => p2.uint16);
|
|
1030
|
+
lazy$1(this, `glyphIdArray`, getter);
|
|
1031
|
+
}
|
|
1032
|
+
supports(charCode) {
|
|
1033
|
+
if (charCode.charCodeAt) {
|
|
1034
|
+
charCode = -1;
|
|
1035
|
+
console.warn(
|
|
1036
|
+
`supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.`
|
|
1037
|
+
);
|
|
1038
|
+
}
|
|
1039
|
+
if (charCode < this.firstCode) return {};
|
|
1040
|
+
if (charCode > this.firstCode + this.entryCount) return {};
|
|
1041
|
+
const code = charCode - this.firstCode;
|
|
1042
|
+
return { code, unicode: String.fromCodePoint(code) };
|
|
1043
|
+
}
|
|
1044
|
+
reverse(glyphID) {
|
|
1045
|
+
let pos = this.glyphIdArray.indexOf(glyphID);
|
|
1046
|
+
if (pos > -1) return this.firstCode + pos;
|
|
1047
|
+
}
|
|
1048
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
1049
|
+
if (preservePropNames) {
|
|
1050
|
+
return [{ firstCode: this.firstCode, lastCode: this.lastCode }];
|
|
1051
|
+
}
|
|
1052
|
+
return [{ start: this.firstCode, end: this.lastCode }];
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
class Format8 extends Subtable {
|
|
1056
|
+
constructor(p2, platformID, encodingID) {
|
|
1057
|
+
super(p2, platformID, encodingID);
|
|
1058
|
+
this.format = 8;
|
|
1059
|
+
p2.uint16;
|
|
1060
|
+
this.length = p2.uint32;
|
|
1061
|
+
this.language = p2.uint32;
|
|
1062
|
+
this.is32 = [...new Array(8192)].map((_) => p2.uint8);
|
|
1063
|
+
this.numGroups = p2.uint32;
|
|
1064
|
+
const getter = () => [...new Array(this.numGroups)].map(
|
|
1065
|
+
(_) => new SequentialMapGroup$1(p2)
|
|
1066
|
+
);
|
|
1067
|
+
lazy$1(this, `groups`, getter);
|
|
1068
|
+
}
|
|
1069
|
+
supports(charCode) {
|
|
1070
|
+
if (charCode.charCodeAt) {
|
|
1071
|
+
charCode = -1;
|
|
1072
|
+
console.warn(
|
|
1073
|
+
`supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.`
|
|
1074
|
+
);
|
|
1075
|
+
}
|
|
1076
|
+
return this.groups.findIndex(
|
|
1077
|
+
(s) => s.startcharCode <= charCode && charCode <= s.endcharCode
|
|
1078
|
+
) !== -1;
|
|
1079
|
+
}
|
|
1080
|
+
reverse(glyphID) {
|
|
1081
|
+
console.warn(`reverse not implemented for cmap subtable format 8`);
|
|
1082
|
+
return {};
|
|
1083
|
+
}
|
|
1084
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
1085
|
+
if (preservePropNames) return this.groups;
|
|
1086
|
+
return this.groups.map((v) => ({
|
|
1087
|
+
start: v.startcharCode,
|
|
1088
|
+
end: v.endcharCode
|
|
1089
|
+
}));
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
class SequentialMapGroup$1 {
|
|
1093
|
+
constructor(p2) {
|
|
1094
|
+
this.startcharCode = p2.uint32;
|
|
1095
|
+
this.endcharCode = p2.uint32;
|
|
1096
|
+
this.startGlyphID = p2.uint32;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
class Format10 extends Subtable {
|
|
1100
|
+
constructor(p2, platformID, encodingID) {
|
|
1101
|
+
super(p2, platformID, encodingID);
|
|
1102
|
+
this.format = 10;
|
|
1103
|
+
p2.uint16;
|
|
1104
|
+
this.length = p2.uint32;
|
|
1105
|
+
this.language = p2.uint32;
|
|
1106
|
+
this.startCharCode = p2.uint32;
|
|
1107
|
+
this.numChars = p2.uint32;
|
|
1108
|
+
this.endCharCode = this.startCharCode + this.numChars;
|
|
1109
|
+
const getter = () => [...new Array(this.numChars)].map((_) => p2.uint16);
|
|
1110
|
+
lazy$1(this, `glyphs`, getter);
|
|
1111
|
+
}
|
|
1112
|
+
supports(charCode) {
|
|
1113
|
+
if (charCode.charCodeAt) {
|
|
1114
|
+
charCode = -1;
|
|
1115
|
+
console.warn(
|
|
1116
|
+
`supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.`
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
if (charCode < this.startCharCode) return false;
|
|
1120
|
+
if (charCode > this.startCharCode + this.numChars) return false;
|
|
1121
|
+
return charCode - this.startCharCode;
|
|
1122
|
+
}
|
|
1123
|
+
reverse(glyphID) {
|
|
1124
|
+
console.warn(`reverse not implemented for cmap subtable format 10`);
|
|
1125
|
+
return {};
|
|
1126
|
+
}
|
|
1127
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
1128
|
+
if (preservePropNames) {
|
|
1129
|
+
return [
|
|
1130
|
+
{
|
|
1131
|
+
startCharCode: this.startCharCode,
|
|
1132
|
+
endCharCode: this.endCharCode
|
|
1133
|
+
}
|
|
1134
|
+
];
|
|
1135
|
+
}
|
|
1136
|
+
return [{ start: this.startCharCode, end: this.endCharCode }];
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
class Format12 extends Subtable {
|
|
1140
|
+
constructor(p2, platformID, encodingID) {
|
|
1141
|
+
super(p2, platformID, encodingID);
|
|
1142
|
+
this.format = 12;
|
|
1143
|
+
p2.uint16;
|
|
1144
|
+
this.length = p2.uint32;
|
|
1145
|
+
this.language = p2.uint32;
|
|
1146
|
+
this.numGroups = p2.uint32;
|
|
1147
|
+
const getter = () => [...new Array(this.numGroups)].map(
|
|
1148
|
+
(_) => new SequentialMapGroup(p2)
|
|
1149
|
+
);
|
|
1150
|
+
lazy$1(this, `groups`, getter);
|
|
1151
|
+
}
|
|
1152
|
+
supports(charCode) {
|
|
1153
|
+
if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
|
|
1154
|
+
if (55296 <= charCode && charCode <= 57343) return 0;
|
|
1155
|
+
if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
|
|
1156
|
+
return 0;
|
|
1157
|
+
return this.groups.findIndex(
|
|
1158
|
+
(s) => s.startCharCode <= charCode && charCode <= s.endCharCode
|
|
1159
|
+
) !== -1;
|
|
1160
|
+
}
|
|
1161
|
+
reverse(glyphID) {
|
|
1162
|
+
for (let group of this.groups) {
|
|
1163
|
+
let start = group.startGlyphID;
|
|
1164
|
+
if (start > glyphID) continue;
|
|
1165
|
+
if (start === glyphID) return group.startCharCode;
|
|
1166
|
+
let end = start + (group.endCharCode - group.startCharCode);
|
|
1167
|
+
if (end < glyphID) continue;
|
|
1168
|
+
const code = group.startCharCode + (glyphID - start);
|
|
1169
|
+
return { code, unicode: String.fromCodePoint(code) };
|
|
1170
|
+
}
|
|
1171
|
+
return {};
|
|
1172
|
+
}
|
|
1173
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
1174
|
+
if (preservePropNames) return this.groups;
|
|
1175
|
+
return this.groups.map((v) => ({
|
|
1176
|
+
start: v.startCharCode,
|
|
1177
|
+
end: v.endCharCode
|
|
1178
|
+
}));
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
class SequentialMapGroup {
|
|
1182
|
+
constructor(p2) {
|
|
1183
|
+
this.startCharCode = p2.uint32;
|
|
1184
|
+
this.endCharCode = p2.uint32;
|
|
1185
|
+
this.startGlyphID = p2.uint32;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
class Format13 extends Subtable {
|
|
1189
|
+
constructor(p2, platformID, encodingID) {
|
|
1190
|
+
super(p2, platformID, encodingID);
|
|
1191
|
+
this.format = 13;
|
|
1192
|
+
p2.uint16;
|
|
1193
|
+
this.length = p2.uint32;
|
|
1194
|
+
this.language = p2.uint32;
|
|
1195
|
+
this.numGroups = p2.uint32;
|
|
1196
|
+
const getter = [...new Array(this.numGroups)].map(
|
|
1197
|
+
(_) => new ConstantMapGroup(p2)
|
|
1198
|
+
);
|
|
1199
|
+
lazy$1(this, `groups`, getter);
|
|
1200
|
+
}
|
|
1201
|
+
supports(charCode) {
|
|
1202
|
+
if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
|
|
1203
|
+
return this.groups.findIndex(
|
|
1204
|
+
(s) => s.startCharCode <= charCode && charCode <= s.endCharCode
|
|
1205
|
+
) !== -1;
|
|
1206
|
+
}
|
|
1207
|
+
reverse(glyphID) {
|
|
1208
|
+
console.warn(`reverse not implemented for cmap subtable format 13`);
|
|
1209
|
+
return {};
|
|
1210
|
+
}
|
|
1211
|
+
getSupportedCharCodes(preservePropNames = false) {
|
|
1212
|
+
if (preservePropNames) return this.groups;
|
|
1213
|
+
return this.groups.map((v) => ({
|
|
1214
|
+
start: v.startCharCode,
|
|
1215
|
+
end: v.endCharCode
|
|
1216
|
+
}));
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
class ConstantMapGroup {
|
|
1220
|
+
constructor(p2) {
|
|
1221
|
+
this.startCharCode = p2.uint32;
|
|
1222
|
+
this.endCharCode = p2.uint32;
|
|
1223
|
+
this.glyphID = p2.uint32;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
class Format14 extends Subtable {
|
|
1227
|
+
constructor(p2, platformID, encodingID) {
|
|
1228
|
+
super(p2, platformID, encodingID);
|
|
1229
|
+
this.subTableStart = p2.currentPosition;
|
|
1230
|
+
this.format = 14;
|
|
1231
|
+
this.length = p2.uint32;
|
|
1232
|
+
this.numVarSelectorRecords = p2.uint32;
|
|
1233
|
+
lazy$1(
|
|
1234
|
+
this,
|
|
1235
|
+
`varSelectors`,
|
|
1236
|
+
() => [...new Array(this.numVarSelectorRecords)].map(
|
|
1237
|
+
(_) => new VariationSelector(p2)
|
|
1238
|
+
)
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
supports() {
|
|
1242
|
+
console.warn(`supports not implemented for cmap subtable format 14`);
|
|
1243
|
+
return 0;
|
|
1244
|
+
}
|
|
1245
|
+
getSupportedCharCodes() {
|
|
1246
|
+
console.warn(
|
|
1247
|
+
`getSupportedCharCodes not implemented for cmap subtable format 14`
|
|
1248
|
+
);
|
|
1249
|
+
return [];
|
|
1250
|
+
}
|
|
1251
|
+
reverse(glyphID) {
|
|
1252
|
+
console.warn(`reverse not implemented for cmap subtable format 14`);
|
|
1253
|
+
return {};
|
|
1254
|
+
}
|
|
1255
|
+
supportsVariation(variation) {
|
|
1256
|
+
let v = this.varSelector.find(
|
|
1257
|
+
(uvs) => uvs.varSelector === variation
|
|
1258
|
+
);
|
|
1259
|
+
return v ? v : false;
|
|
1260
|
+
}
|
|
1261
|
+
getSupportedVariations() {
|
|
1262
|
+
return this.varSelectors.map((v) => v.varSelector);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
class VariationSelector {
|
|
1266
|
+
constructor(p2) {
|
|
1267
|
+
this.varSelector = p2.uint24;
|
|
1268
|
+
this.defaultUVSOffset = p2.Offset32;
|
|
1269
|
+
this.nonDefaultUVSOffset = p2.Offset32;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
function createSubTable(parser, platformID, encodingID) {
|
|
1273
|
+
const format = parser.uint16;
|
|
1274
|
+
if (format === 0) return new Format0(parser, platformID, encodingID);
|
|
1275
|
+
if (format === 2) return new Format2(parser, platformID, encodingID);
|
|
1276
|
+
if (format === 4) return new Format4(parser, platformID, encodingID);
|
|
1277
|
+
if (format === 6) return new Format6(parser, platformID, encodingID);
|
|
1278
|
+
if (format === 8) return new Format8(parser, platformID, encodingID);
|
|
1279
|
+
if (format === 10) return new Format10(parser, platformID, encodingID);
|
|
1280
|
+
if (format === 12) return new Format12(parser, platformID, encodingID);
|
|
1281
|
+
if (format === 13) return new Format13(parser, platformID, encodingID);
|
|
1282
|
+
if (format === 14) return new Format14(parser, platformID, encodingID);
|
|
1283
|
+
return {};
|
|
1284
|
+
}
|
|
1285
|
+
class cmap extends SimpleTable {
|
|
1286
|
+
constructor(dict, dataview) {
|
|
1287
|
+
const { p: p2 } = super(dict, dataview);
|
|
1288
|
+
this.version = p2.uint16;
|
|
1289
|
+
this.numTables = p2.uint16;
|
|
1290
|
+
this.encodingRecords = [...new Array(this.numTables)].map(
|
|
1291
|
+
(_) => new EncodingRecord(p2, this.tableStart)
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
getSubTable(tableID) {
|
|
1295
|
+
return this.encodingRecords[tableID].table;
|
|
1296
|
+
}
|
|
1297
|
+
getSupportedEncodings() {
|
|
1298
|
+
return this.encodingRecords.map((r) => ({
|
|
1299
|
+
platformID: r.platformID,
|
|
1300
|
+
encodingId: r.encodingID
|
|
1301
|
+
}));
|
|
1302
|
+
}
|
|
1303
|
+
getSupportedCharCodes(platformID, encodingID) {
|
|
1304
|
+
const recordID = this.encodingRecords.findIndex(
|
|
1305
|
+
(r) => r.platformID === platformID && r.encodingID === encodingID
|
|
1306
|
+
);
|
|
1307
|
+
if (recordID === -1) return false;
|
|
1308
|
+
const subtable = this.getSubTable(recordID);
|
|
1309
|
+
return subtable.getSupportedCharCodes();
|
|
1310
|
+
}
|
|
1311
|
+
reverse(glyphid) {
|
|
1312
|
+
for (let i = 0; i < this.numTables; i++) {
|
|
1313
|
+
let code = this.getSubTable(i).reverse(glyphid);
|
|
1314
|
+
if (code) return code;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
getGlyphId(char) {
|
|
1318
|
+
let last = 0;
|
|
1319
|
+
this.encodingRecords.some((_, tableID) => {
|
|
1320
|
+
let t = this.getSubTable(tableID);
|
|
1321
|
+
if (!t.getGlyphId) return false;
|
|
1322
|
+
last = t.getGlyphId(char);
|
|
1323
|
+
return last !== 0;
|
|
1324
|
+
});
|
|
1325
|
+
return last;
|
|
1326
|
+
}
|
|
1327
|
+
supports(char) {
|
|
1328
|
+
return this.encodingRecords.some((_, tableID) => {
|
|
1329
|
+
const t = this.getSubTable(tableID);
|
|
1330
|
+
return t.supports && t.supports(char) !== false;
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
supportsVariation(variation) {
|
|
1334
|
+
return this.encodingRecords.some((_, tableID) => {
|
|
1335
|
+
const t = this.getSubTable(tableID);
|
|
1336
|
+
return t.supportsVariation && t.supportsVariation(variation) !== false;
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
class EncodingRecord {
|
|
1341
|
+
constructor(p2, tableStart) {
|
|
1342
|
+
const platformID = this.platformID = p2.uint16;
|
|
1343
|
+
const encodingID = this.encodingID = p2.uint16;
|
|
1344
|
+
const offset = this.offset = p2.Offset32;
|
|
1345
|
+
lazy$1(this, `table`, () => {
|
|
1346
|
+
p2.currentPosition = tableStart + offset;
|
|
1347
|
+
return createSubTable(p2, platformID, encodingID);
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
var cmap$1 = Object.freeze({ __proto__: null, cmap });
|
|
1352
|
+
class head extends SimpleTable {
|
|
1353
|
+
constructor(dict, dataview) {
|
|
1354
|
+
const { p: p2 } = super(dict, dataview);
|
|
1355
|
+
this.load({
|
|
1356
|
+
majorVersion: p2.uint16,
|
|
1357
|
+
minorVersion: p2.uint16,
|
|
1358
|
+
fontRevision: p2.fixed,
|
|
1359
|
+
checkSumAdjustment: p2.uint32,
|
|
1360
|
+
magicNumber: p2.uint32,
|
|
1361
|
+
flags: p2.flags(16),
|
|
1362
|
+
unitsPerEm: p2.uint16,
|
|
1363
|
+
created: p2.longdatetime,
|
|
1364
|
+
modified: p2.longdatetime,
|
|
1365
|
+
xMin: p2.int16,
|
|
1366
|
+
yMin: p2.int16,
|
|
1367
|
+
xMax: p2.int16,
|
|
1368
|
+
yMax: p2.int16,
|
|
1369
|
+
macStyle: p2.flags(16),
|
|
1370
|
+
lowestRecPPEM: p2.uint16,
|
|
1371
|
+
fontDirectionHint: p2.uint16,
|
|
1372
|
+
indexToLocFormat: p2.uint16,
|
|
1373
|
+
glyphDataFormat: p2.uint16
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
var head$1 = Object.freeze({ __proto__: null, head });
|
|
1378
|
+
class hhea extends SimpleTable {
|
|
1379
|
+
constructor(dict, dataview) {
|
|
1380
|
+
const { p: p2 } = super(dict, dataview);
|
|
1381
|
+
this.majorVersion = p2.uint16;
|
|
1382
|
+
this.minorVersion = p2.uint16;
|
|
1383
|
+
this.ascender = p2.fword;
|
|
1384
|
+
this.descender = p2.fword;
|
|
1385
|
+
this.lineGap = p2.fword;
|
|
1386
|
+
this.advanceWidthMax = p2.ufword;
|
|
1387
|
+
this.minLeftSideBearing = p2.fword;
|
|
1388
|
+
this.minRightSideBearing = p2.fword;
|
|
1389
|
+
this.xMaxExtent = p2.fword;
|
|
1390
|
+
this.caretSlopeRise = p2.int16;
|
|
1391
|
+
this.caretSlopeRun = p2.int16;
|
|
1392
|
+
this.caretOffset = p2.int16;
|
|
1393
|
+
p2.int16;
|
|
1394
|
+
p2.int16;
|
|
1395
|
+
p2.int16;
|
|
1396
|
+
p2.int16;
|
|
1397
|
+
this.metricDataFormat = p2.int16;
|
|
1398
|
+
this.numberOfHMetrics = p2.uint16;
|
|
1399
|
+
p2.verifyLength();
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
var hhea$1 = Object.freeze({ __proto__: null, hhea });
|
|
1403
|
+
class hmtx extends SimpleTable {
|
|
1404
|
+
constructor(dict, dataview, tables) {
|
|
1405
|
+
const { p: p2 } = super(dict, dataview);
|
|
1406
|
+
const numberOfHMetrics = tables.hhea.numberOfHMetrics;
|
|
1407
|
+
const numGlyphs = tables.maxp.numGlyphs;
|
|
1408
|
+
const metricsStart = p2.currentPosition;
|
|
1409
|
+
lazy$1(this, `hMetrics`, () => {
|
|
1410
|
+
p2.currentPosition = metricsStart;
|
|
1411
|
+
return [...new Array(numberOfHMetrics)].map(
|
|
1412
|
+
(_) => new LongHorMetric(p2.uint16, p2.int16)
|
|
1413
|
+
);
|
|
1414
|
+
});
|
|
1415
|
+
if (numberOfHMetrics < numGlyphs) {
|
|
1416
|
+
const lsbStart = metricsStart + numberOfHMetrics * 4;
|
|
1417
|
+
lazy$1(this, `leftSideBearings`, () => {
|
|
1418
|
+
p2.currentPosition = lsbStart;
|
|
1419
|
+
return [...new Array(numGlyphs - numberOfHMetrics)].map(
|
|
1420
|
+
(_) => p2.int16
|
|
1421
|
+
);
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
class LongHorMetric {
|
|
1427
|
+
constructor(w, b) {
|
|
1428
|
+
this.advanceWidth = w;
|
|
1429
|
+
this.lsb = b;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
var hmtx$1 = Object.freeze({ __proto__: null, hmtx });
|
|
1433
|
+
class maxp extends SimpleTable {
|
|
1434
|
+
constructor(dict, dataview) {
|
|
1435
|
+
const { p: p2 } = super(dict, dataview);
|
|
1436
|
+
this.version = p2.legacyFixed;
|
|
1437
|
+
this.numGlyphs = p2.uint16;
|
|
1438
|
+
if (this.version === 1) {
|
|
1439
|
+
this.maxPoints = p2.uint16;
|
|
1440
|
+
this.maxContours = p2.uint16;
|
|
1441
|
+
this.maxCompositePoints = p2.uint16;
|
|
1442
|
+
this.maxCompositeContours = p2.uint16;
|
|
1443
|
+
this.maxZones = p2.uint16;
|
|
1444
|
+
this.maxTwilightPoints = p2.uint16;
|
|
1445
|
+
this.maxStorage = p2.uint16;
|
|
1446
|
+
this.maxFunctionDefs = p2.uint16;
|
|
1447
|
+
this.maxInstructionDefs = p2.uint16;
|
|
1448
|
+
this.maxStackElements = p2.uint16;
|
|
1449
|
+
this.maxSizeOfInstructions = p2.uint16;
|
|
1450
|
+
this.maxComponentElements = p2.uint16;
|
|
1451
|
+
this.maxComponentDepth = p2.uint16;
|
|
1452
|
+
}
|
|
1453
|
+
p2.verifyLength();
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
var maxp$1 = Object.freeze({ __proto__: null, maxp });
|
|
1457
|
+
class name extends SimpleTable {
|
|
1458
|
+
constructor(dict, dataview) {
|
|
1459
|
+
const { p: p2 } = super(dict, dataview);
|
|
1460
|
+
this.format = p2.uint16;
|
|
1461
|
+
this.count = p2.uint16;
|
|
1462
|
+
this.stringOffset = p2.Offset16;
|
|
1463
|
+
this.nameRecords = [...new Array(this.count)].map(
|
|
1464
|
+
(_) => new NameRecord(p2, this)
|
|
1465
|
+
);
|
|
1466
|
+
if (this.format === 1) {
|
|
1467
|
+
this.langTagCount = p2.uint16;
|
|
1468
|
+
this.langTagRecords = [...new Array(this.langTagCount)].map(
|
|
1469
|
+
(_) => new LangTagRecord(p2.uint16, p2.Offset16)
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
this.stringStart = this.tableStart + this.stringOffset;
|
|
1473
|
+
}
|
|
1474
|
+
get(nameID) {
|
|
1475
|
+
let record = this.nameRecords.find(
|
|
1476
|
+
(record2) => record2.nameID === nameID
|
|
1477
|
+
);
|
|
1478
|
+
if (record) return record.string;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
class LangTagRecord {
|
|
1482
|
+
constructor(length, offset) {
|
|
1483
|
+
this.length = length;
|
|
1484
|
+
this.offset = offset;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
class NameRecord {
|
|
1488
|
+
constructor(p2, nameTable) {
|
|
1489
|
+
this.platformID = p2.uint16;
|
|
1490
|
+
this.encodingID = p2.uint16;
|
|
1491
|
+
this.languageID = p2.uint16;
|
|
1492
|
+
this.nameID = p2.uint16;
|
|
1493
|
+
this.length = p2.uint16;
|
|
1494
|
+
this.offset = p2.Offset16;
|
|
1495
|
+
lazy$1(this, `string`, () => {
|
|
1496
|
+
p2.currentPosition = nameTable.stringStart + this.offset;
|
|
1497
|
+
return decodeString(p2, this);
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
function decodeString(p2, record) {
|
|
1502
|
+
const { platformID, length } = record;
|
|
1503
|
+
if (length === 0) return ``;
|
|
1504
|
+
if (platformID === 0 || platformID === 3) {
|
|
1505
|
+
const str2 = [];
|
|
1506
|
+
for (let i = 0, e = length / 2; i < e; i++)
|
|
1507
|
+
str2[i] = String.fromCharCode(p2.uint16);
|
|
1508
|
+
return str2.join(``);
|
|
1509
|
+
}
|
|
1510
|
+
const bytes = p2.readBytes(length);
|
|
1511
|
+
const str = [];
|
|
1512
|
+
bytes.forEach(function(b, i) {
|
|
1513
|
+
str[i] = String.fromCharCode(b);
|
|
1514
|
+
});
|
|
1515
|
+
return str.join(``);
|
|
1516
|
+
}
|
|
1517
|
+
var name$1 = Object.freeze({ __proto__: null, name });
|
|
1518
|
+
class OS2 extends SimpleTable {
|
|
1519
|
+
constructor(dict, dataview) {
|
|
1520
|
+
const { p: p2 } = super(dict, dataview);
|
|
1521
|
+
this.version = p2.uint16;
|
|
1522
|
+
this.xAvgCharWidth = p2.int16;
|
|
1523
|
+
this.usWeightClass = p2.uint16;
|
|
1524
|
+
this.usWidthClass = p2.uint16;
|
|
1525
|
+
this.fsType = p2.uint16;
|
|
1526
|
+
this.ySubscriptXSize = p2.int16;
|
|
1527
|
+
this.ySubscriptYSize = p2.int16;
|
|
1528
|
+
this.ySubscriptXOffset = p2.int16;
|
|
1529
|
+
this.ySubscriptYOffset = p2.int16;
|
|
1530
|
+
this.ySuperscriptXSize = p2.int16;
|
|
1531
|
+
this.ySuperscriptYSize = p2.int16;
|
|
1532
|
+
this.ySuperscriptXOffset = p2.int16;
|
|
1533
|
+
this.ySuperscriptYOffset = p2.int16;
|
|
1534
|
+
this.yStrikeoutSize = p2.int16;
|
|
1535
|
+
this.yStrikeoutPosition = p2.int16;
|
|
1536
|
+
this.sFamilyClass = p2.int16;
|
|
1537
|
+
this.panose = [...new Array(10)].map((_) => p2.uint8);
|
|
1538
|
+
this.ulUnicodeRange1 = p2.flags(32);
|
|
1539
|
+
this.ulUnicodeRange2 = p2.flags(32);
|
|
1540
|
+
this.ulUnicodeRange3 = p2.flags(32);
|
|
1541
|
+
this.ulUnicodeRange4 = p2.flags(32);
|
|
1542
|
+
this.achVendID = p2.tag;
|
|
1543
|
+
this.fsSelection = p2.uint16;
|
|
1544
|
+
this.usFirstCharIndex = p2.uint16;
|
|
1545
|
+
this.usLastCharIndex = p2.uint16;
|
|
1546
|
+
this.sTypoAscender = p2.int16;
|
|
1547
|
+
this.sTypoDescender = p2.int16;
|
|
1548
|
+
this.sTypoLineGap = p2.int16;
|
|
1549
|
+
this.usWinAscent = p2.uint16;
|
|
1550
|
+
this.usWinDescent = p2.uint16;
|
|
1551
|
+
if (this.version === 0) return p2.verifyLength();
|
|
1552
|
+
this.ulCodePageRange1 = p2.flags(32);
|
|
1553
|
+
this.ulCodePageRange2 = p2.flags(32);
|
|
1554
|
+
if (this.version === 1) return p2.verifyLength();
|
|
1555
|
+
this.sxHeight = p2.int16;
|
|
1556
|
+
this.sCapHeight = p2.int16;
|
|
1557
|
+
this.usDefaultChar = p2.uint16;
|
|
1558
|
+
this.usBreakChar = p2.uint16;
|
|
1559
|
+
this.usMaxContext = p2.uint16;
|
|
1560
|
+
if (this.version <= 4) return p2.verifyLength();
|
|
1561
|
+
this.usLowerOpticalPointSize = p2.uint16;
|
|
1562
|
+
this.usUpperOpticalPointSize = p2.uint16;
|
|
1563
|
+
if (this.version === 5) return p2.verifyLength();
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
var OS2$1 = Object.freeze({ __proto__: null, OS2 });
|
|
1567
|
+
class post extends SimpleTable {
|
|
1568
|
+
constructor(dict, dataview) {
|
|
1569
|
+
const { p: p2 } = super(dict, dataview);
|
|
1570
|
+
this.version = p2.legacyFixed;
|
|
1571
|
+
this.italicAngle = p2.fixed;
|
|
1572
|
+
this.underlinePosition = p2.fword;
|
|
1573
|
+
this.underlineThickness = p2.fword;
|
|
1574
|
+
this.isFixedPitch = p2.uint32;
|
|
1575
|
+
this.minMemType42 = p2.uint32;
|
|
1576
|
+
this.maxMemType42 = p2.uint32;
|
|
1577
|
+
this.minMemType1 = p2.uint32;
|
|
1578
|
+
this.maxMemType1 = p2.uint32;
|
|
1579
|
+
if (this.version === 1 || this.version === 3) return p2.verifyLength();
|
|
1580
|
+
this.numGlyphs = p2.uint16;
|
|
1581
|
+
if (this.version === 2) {
|
|
1582
|
+
this.glyphNameIndex = [...new Array(this.numGlyphs)].map(
|
|
1583
|
+
(_) => p2.uint16
|
|
1584
|
+
);
|
|
1585
|
+
this.namesOffset = p2.currentPosition;
|
|
1586
|
+
this.glyphNameOffsets = [1];
|
|
1587
|
+
for (let i = 0; i < this.numGlyphs; i++) {
|
|
1588
|
+
let index = this.glyphNameIndex[i];
|
|
1589
|
+
if (index < macStrings.length) {
|
|
1590
|
+
this.glyphNameOffsets.push(this.glyphNameOffsets[i]);
|
|
1591
|
+
continue;
|
|
1592
|
+
}
|
|
1593
|
+
let bytelength = p2.int8;
|
|
1594
|
+
p2.skip(bytelength);
|
|
1595
|
+
this.glyphNameOffsets.push(
|
|
1596
|
+
this.glyphNameOffsets[i] + bytelength + 1
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
if (this.version === 2.5) {
|
|
1601
|
+
this.offset = [...new Array(this.numGlyphs)].map(
|
|
1602
|
+
(_) => p2.int8
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
getGlyphName(glyphid) {
|
|
1607
|
+
if (this.version !== 2) {
|
|
1608
|
+
console.warn(
|
|
1609
|
+
`post table version ${this.version} does not support glyph name lookups`
|
|
1610
|
+
);
|
|
1611
|
+
return ``;
|
|
1612
|
+
}
|
|
1613
|
+
let index = this.glyphNameIndex[glyphid];
|
|
1614
|
+
if (index < 258) return macStrings[index];
|
|
1615
|
+
let offset = this.glyphNameOffsets[glyphid];
|
|
1616
|
+
let next = this.glyphNameOffsets[glyphid + 1];
|
|
1617
|
+
let len = next - offset - 1;
|
|
1618
|
+
if (len === 0) return `.notdef.`;
|
|
1619
|
+
this.parser.currentPosition = this.namesOffset + offset;
|
|
1620
|
+
const data = this.parser.readBytes(
|
|
1621
|
+
len,
|
|
1622
|
+
this.namesOffset + offset,
|
|
1623
|
+
8,
|
|
1624
|
+
true
|
|
1625
|
+
);
|
|
1626
|
+
return data.map((b) => String.fromCharCode(b)).join(``);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
const macStrings = [
|
|
1630
|
+
`.notdef`,
|
|
1631
|
+
`.null`,
|
|
1632
|
+
`nonmarkingreturn`,
|
|
1633
|
+
`space`,
|
|
1634
|
+
`exclam`,
|
|
1635
|
+
`quotedbl`,
|
|
1636
|
+
`numbersign`,
|
|
1637
|
+
`dollar`,
|
|
1638
|
+
`percent`,
|
|
1639
|
+
`ampersand`,
|
|
1640
|
+
`quotesingle`,
|
|
1641
|
+
`parenleft`,
|
|
1642
|
+
`parenright`,
|
|
1643
|
+
`asterisk`,
|
|
1644
|
+
`plus`,
|
|
1645
|
+
`comma`,
|
|
1646
|
+
`hyphen`,
|
|
1647
|
+
`period`,
|
|
1648
|
+
`slash`,
|
|
1649
|
+
`zero`,
|
|
1650
|
+
`one`,
|
|
1651
|
+
`two`,
|
|
1652
|
+
`three`,
|
|
1653
|
+
`four`,
|
|
1654
|
+
`five`,
|
|
1655
|
+
`six`,
|
|
1656
|
+
`seven`,
|
|
1657
|
+
`eight`,
|
|
1658
|
+
`nine`,
|
|
1659
|
+
`colon`,
|
|
1660
|
+
`semicolon`,
|
|
1661
|
+
`less`,
|
|
1662
|
+
`equal`,
|
|
1663
|
+
`greater`,
|
|
1664
|
+
`question`,
|
|
1665
|
+
`at`,
|
|
1666
|
+
`A`,
|
|
1667
|
+
`B`,
|
|
1668
|
+
`C`,
|
|
1669
|
+
`D`,
|
|
1670
|
+
`E`,
|
|
1671
|
+
`F`,
|
|
1672
|
+
`G`,
|
|
1673
|
+
`H`,
|
|
1674
|
+
`I`,
|
|
1675
|
+
`J`,
|
|
1676
|
+
`K`,
|
|
1677
|
+
`L`,
|
|
1678
|
+
`M`,
|
|
1679
|
+
`N`,
|
|
1680
|
+
`O`,
|
|
1681
|
+
`P`,
|
|
1682
|
+
`Q`,
|
|
1683
|
+
`R`,
|
|
1684
|
+
`S`,
|
|
1685
|
+
`T`,
|
|
1686
|
+
`U`,
|
|
1687
|
+
`V`,
|
|
1688
|
+
`W`,
|
|
1689
|
+
`X`,
|
|
1690
|
+
`Y`,
|
|
1691
|
+
`Z`,
|
|
1692
|
+
`bracketleft`,
|
|
1693
|
+
`backslash`,
|
|
1694
|
+
`bracketright`,
|
|
1695
|
+
`asciicircum`,
|
|
1696
|
+
`underscore`,
|
|
1697
|
+
`grave`,
|
|
1698
|
+
`a`,
|
|
1699
|
+
`b`,
|
|
1700
|
+
`c`,
|
|
1701
|
+
`d`,
|
|
1702
|
+
`e`,
|
|
1703
|
+
`f`,
|
|
1704
|
+
`g`,
|
|
1705
|
+
`h`,
|
|
1706
|
+
`i`,
|
|
1707
|
+
`j`,
|
|
1708
|
+
`k`,
|
|
1709
|
+
`l`,
|
|
1710
|
+
`m`,
|
|
1711
|
+
`n`,
|
|
1712
|
+
`o`,
|
|
1713
|
+
`p`,
|
|
1714
|
+
`q`,
|
|
1715
|
+
`r`,
|
|
1716
|
+
`s`,
|
|
1717
|
+
`t`,
|
|
1718
|
+
`u`,
|
|
1719
|
+
`v`,
|
|
1720
|
+
`w`,
|
|
1721
|
+
`x`,
|
|
1722
|
+
`y`,
|
|
1723
|
+
`z`,
|
|
1724
|
+
`braceleft`,
|
|
1725
|
+
`bar`,
|
|
1726
|
+
`braceright`,
|
|
1727
|
+
`asciitilde`,
|
|
1728
|
+
`Adieresis`,
|
|
1729
|
+
`Aring`,
|
|
1730
|
+
`Ccedilla`,
|
|
1731
|
+
`Eacute`,
|
|
1732
|
+
`Ntilde`,
|
|
1733
|
+
`Odieresis`,
|
|
1734
|
+
`Udieresis`,
|
|
1735
|
+
`aacute`,
|
|
1736
|
+
`agrave`,
|
|
1737
|
+
`acircumflex`,
|
|
1738
|
+
`adieresis`,
|
|
1739
|
+
`atilde`,
|
|
1740
|
+
`aring`,
|
|
1741
|
+
`ccedilla`,
|
|
1742
|
+
`eacute`,
|
|
1743
|
+
`egrave`,
|
|
1744
|
+
`ecircumflex`,
|
|
1745
|
+
`edieresis`,
|
|
1746
|
+
`iacute`,
|
|
1747
|
+
`igrave`,
|
|
1748
|
+
`icircumflex`,
|
|
1749
|
+
`idieresis`,
|
|
1750
|
+
`ntilde`,
|
|
1751
|
+
`oacute`,
|
|
1752
|
+
`ograve`,
|
|
1753
|
+
`ocircumflex`,
|
|
1754
|
+
`odieresis`,
|
|
1755
|
+
`otilde`,
|
|
1756
|
+
`uacute`,
|
|
1757
|
+
`ugrave`,
|
|
1758
|
+
`ucircumflex`,
|
|
1759
|
+
`udieresis`,
|
|
1760
|
+
`dagger`,
|
|
1761
|
+
`degree`,
|
|
1762
|
+
`cent`,
|
|
1763
|
+
`sterling`,
|
|
1764
|
+
`section`,
|
|
1765
|
+
`bullet`,
|
|
1766
|
+
`paragraph`,
|
|
1767
|
+
`germandbls`,
|
|
1768
|
+
`registered`,
|
|
1769
|
+
`copyright`,
|
|
1770
|
+
`trademark`,
|
|
1771
|
+
`acute`,
|
|
1772
|
+
`dieresis`,
|
|
1773
|
+
`notequal`,
|
|
1774
|
+
`AE`,
|
|
1775
|
+
`Oslash`,
|
|
1776
|
+
`infinity`,
|
|
1777
|
+
`plusminus`,
|
|
1778
|
+
`lessequal`,
|
|
1779
|
+
`greaterequal`,
|
|
1780
|
+
`yen`,
|
|
1781
|
+
`mu`,
|
|
1782
|
+
`partialdiff`,
|
|
1783
|
+
`summation`,
|
|
1784
|
+
`product`,
|
|
1785
|
+
`pi`,
|
|
1786
|
+
`integral`,
|
|
1787
|
+
`ordfeminine`,
|
|
1788
|
+
`ordmasculine`,
|
|
1789
|
+
`Omega`,
|
|
1790
|
+
`ae`,
|
|
1791
|
+
`oslash`,
|
|
1792
|
+
`questiondown`,
|
|
1793
|
+
`exclamdown`,
|
|
1794
|
+
`logicalnot`,
|
|
1795
|
+
`radical`,
|
|
1796
|
+
`florin`,
|
|
1797
|
+
`approxequal`,
|
|
1798
|
+
`Delta`,
|
|
1799
|
+
`guillemotleft`,
|
|
1800
|
+
`guillemotright`,
|
|
1801
|
+
`ellipsis`,
|
|
1802
|
+
`nonbreakingspace`,
|
|
1803
|
+
`Agrave`,
|
|
1804
|
+
`Atilde`,
|
|
1805
|
+
`Otilde`,
|
|
1806
|
+
`OE`,
|
|
1807
|
+
`oe`,
|
|
1808
|
+
`endash`,
|
|
1809
|
+
`emdash`,
|
|
1810
|
+
`quotedblleft`,
|
|
1811
|
+
`quotedblright`,
|
|
1812
|
+
`quoteleft`,
|
|
1813
|
+
`quoteright`,
|
|
1814
|
+
`divide`,
|
|
1815
|
+
`lozenge`,
|
|
1816
|
+
`ydieresis`,
|
|
1817
|
+
`Ydieresis`,
|
|
1818
|
+
`fraction`,
|
|
1819
|
+
`currency`,
|
|
1820
|
+
`guilsinglleft`,
|
|
1821
|
+
`guilsinglright`,
|
|
1822
|
+
`fi`,
|
|
1823
|
+
`fl`,
|
|
1824
|
+
`daggerdbl`,
|
|
1825
|
+
`periodcentered`,
|
|
1826
|
+
`quotesinglbase`,
|
|
1827
|
+
`quotedblbase`,
|
|
1828
|
+
`perthousand`,
|
|
1829
|
+
`Acircumflex`,
|
|
1830
|
+
`Ecircumflex`,
|
|
1831
|
+
`Aacute`,
|
|
1832
|
+
`Edieresis`,
|
|
1833
|
+
`Egrave`,
|
|
1834
|
+
`Iacute`,
|
|
1835
|
+
`Icircumflex`,
|
|
1836
|
+
`Idieresis`,
|
|
1837
|
+
`Igrave`,
|
|
1838
|
+
`Oacute`,
|
|
1839
|
+
`Ocircumflex`,
|
|
1840
|
+
`apple`,
|
|
1841
|
+
`Ograve`,
|
|
1842
|
+
`Uacute`,
|
|
1843
|
+
`Ucircumflex`,
|
|
1844
|
+
`Ugrave`,
|
|
1845
|
+
`dotlessi`,
|
|
1846
|
+
`circumflex`,
|
|
1847
|
+
`tilde`,
|
|
1848
|
+
`macron`,
|
|
1849
|
+
`breve`,
|
|
1850
|
+
`dotaccent`,
|
|
1851
|
+
`ring`,
|
|
1852
|
+
`cedilla`,
|
|
1853
|
+
`hungarumlaut`,
|
|
1854
|
+
`ogonek`,
|
|
1855
|
+
`caron`,
|
|
1856
|
+
`Lslash`,
|
|
1857
|
+
`lslash`,
|
|
1858
|
+
`Scaron`,
|
|
1859
|
+
`scaron`,
|
|
1860
|
+
`Zcaron`,
|
|
1861
|
+
`zcaron`,
|
|
1862
|
+
`brokenbar`,
|
|
1863
|
+
`Eth`,
|
|
1864
|
+
`eth`,
|
|
1865
|
+
`Yacute`,
|
|
1866
|
+
`yacute`,
|
|
1867
|
+
`Thorn`,
|
|
1868
|
+
`thorn`,
|
|
1869
|
+
`minus`,
|
|
1870
|
+
`multiply`,
|
|
1871
|
+
`onesuperior`,
|
|
1872
|
+
`twosuperior`,
|
|
1873
|
+
`threesuperior`,
|
|
1874
|
+
`onehalf`,
|
|
1875
|
+
`onequarter`,
|
|
1876
|
+
`threequarters`,
|
|
1877
|
+
`franc`,
|
|
1878
|
+
`Gbreve`,
|
|
1879
|
+
`gbreve`,
|
|
1880
|
+
`Idotaccent`,
|
|
1881
|
+
`Scedilla`,
|
|
1882
|
+
`scedilla`,
|
|
1883
|
+
`Cacute`,
|
|
1884
|
+
`cacute`,
|
|
1885
|
+
`Ccaron`,
|
|
1886
|
+
`ccaron`,
|
|
1887
|
+
`dcroat`
|
|
1888
|
+
];
|
|
1889
|
+
var post$1 = Object.freeze({ __proto__: null, post });
|
|
1890
|
+
class BASE extends SimpleTable {
|
|
1891
|
+
constructor(dict, dataview) {
|
|
1892
|
+
const { p: p2 } = super(dict, dataview);
|
|
1893
|
+
this.majorVersion = p2.uint16;
|
|
1894
|
+
this.minorVersion = p2.uint16;
|
|
1895
|
+
this.horizAxisOffset = p2.Offset16;
|
|
1896
|
+
this.vertAxisOffset = p2.Offset16;
|
|
1897
|
+
lazy$1(
|
|
1898
|
+
this,
|
|
1899
|
+
`horizAxis`,
|
|
1900
|
+
() => new AxisTable(
|
|
1901
|
+
{ offset: dict.offset + this.horizAxisOffset },
|
|
1902
|
+
dataview
|
|
1903
|
+
)
|
|
1904
|
+
);
|
|
1905
|
+
lazy$1(
|
|
1906
|
+
this,
|
|
1907
|
+
`vertAxis`,
|
|
1908
|
+
() => new AxisTable(
|
|
1909
|
+
{ offset: dict.offset + this.vertAxisOffset },
|
|
1910
|
+
dataview
|
|
1911
|
+
)
|
|
1912
|
+
);
|
|
1913
|
+
if (this.majorVersion === 1 && this.minorVersion === 1) {
|
|
1914
|
+
this.itemVarStoreOffset = p2.Offset32;
|
|
1915
|
+
lazy$1(
|
|
1916
|
+
this,
|
|
1917
|
+
`itemVarStore`,
|
|
1918
|
+
() => new AxisTable(
|
|
1919
|
+
{ offset: dict.offset + this.itemVarStoreOffset },
|
|
1920
|
+
dataview
|
|
1921
|
+
)
|
|
1922
|
+
);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
class AxisTable extends SimpleTable {
|
|
1927
|
+
constructor(dict, dataview) {
|
|
1928
|
+
const { p: p2 } = super(dict, dataview, `AxisTable`);
|
|
1929
|
+
this.baseTagListOffset = p2.Offset16;
|
|
1930
|
+
this.baseScriptListOffset = p2.Offset16;
|
|
1931
|
+
lazy$1(
|
|
1932
|
+
this,
|
|
1933
|
+
`baseTagList`,
|
|
1934
|
+
() => new BaseTagListTable(
|
|
1935
|
+
{ offset: dict.offset + this.baseTagListOffset },
|
|
1936
|
+
dataview
|
|
1937
|
+
)
|
|
1938
|
+
);
|
|
1939
|
+
lazy$1(
|
|
1940
|
+
this,
|
|
1941
|
+
`baseScriptList`,
|
|
1942
|
+
() => new BaseScriptListTable(
|
|
1943
|
+
{ offset: dict.offset + this.baseScriptListOffset },
|
|
1944
|
+
dataview
|
|
1945
|
+
)
|
|
1946
|
+
);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
class BaseTagListTable extends SimpleTable {
|
|
1950
|
+
constructor(dict, dataview) {
|
|
1951
|
+
const { p: p2 } = super(dict, dataview, `BaseTagListTable`);
|
|
1952
|
+
this.baseTagCount = p2.uint16;
|
|
1953
|
+
this.baselineTags = [...new Array(this.baseTagCount)].map(
|
|
1954
|
+
(_) => p2.tag
|
|
1955
|
+
);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
class BaseScriptListTable extends SimpleTable {
|
|
1959
|
+
constructor(dict, dataview) {
|
|
1960
|
+
const { p: p2 } = super(dict, dataview, `BaseScriptListTable`);
|
|
1961
|
+
this.baseScriptCount = p2.uint16;
|
|
1962
|
+
const recordStart = p2.currentPosition;
|
|
1963
|
+
lazy$1(this, `baseScriptRecords`, () => {
|
|
1964
|
+
p2.currentPosition = recordStart;
|
|
1965
|
+
return [...new Array(this.baseScriptCount)].map(
|
|
1966
|
+
(_) => new BaseScriptRecord(this.start, p2)
|
|
1967
|
+
);
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
class BaseScriptRecord {
|
|
1972
|
+
constructor(baseScriptListTableStart, p2) {
|
|
1973
|
+
this.baseScriptTag = p2.tag;
|
|
1974
|
+
this.baseScriptOffset = p2.Offset16;
|
|
1975
|
+
lazy$1(this, `baseScriptTable`, () => {
|
|
1976
|
+
p2.currentPosition = baseScriptListTableStart + this.baseScriptOffset;
|
|
1977
|
+
return new BaseScriptTable(p2);
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
class BaseScriptTable {
|
|
1982
|
+
constructor(p2) {
|
|
1983
|
+
this.start = p2.currentPosition;
|
|
1984
|
+
this.baseValuesOffset = p2.Offset16;
|
|
1985
|
+
this.defaultMinMaxOffset = p2.Offset16;
|
|
1986
|
+
this.baseLangSysCount = p2.uint16;
|
|
1987
|
+
this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map(
|
|
1988
|
+
(_) => new BaseLangSysRecord(this.start, p2)
|
|
1989
|
+
);
|
|
1990
|
+
lazy$1(this, `baseValues`, () => {
|
|
1991
|
+
p2.currentPosition = this.start + this.baseValuesOffset;
|
|
1992
|
+
return new BaseValuesTable(p2);
|
|
1993
|
+
});
|
|
1994
|
+
lazy$1(this, `defaultMinMax`, () => {
|
|
1995
|
+
p2.currentPosition = this.start + this.defaultMinMaxOffset;
|
|
1996
|
+
return new MinMaxTable(p2);
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
class BaseLangSysRecord {
|
|
2001
|
+
constructor(baseScriptTableStart, p2) {
|
|
2002
|
+
this.baseLangSysTag = p2.tag;
|
|
2003
|
+
this.minMaxOffset = p2.Offset16;
|
|
2004
|
+
lazy$1(this, `minMax`, () => {
|
|
2005
|
+
p2.currentPosition = baseScriptTableStart + this.minMaxOffset;
|
|
2006
|
+
return new MinMaxTable(p2);
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
class BaseValuesTable {
|
|
2011
|
+
constructor(p2) {
|
|
2012
|
+
this.parser = p2;
|
|
2013
|
+
this.start = p2.currentPosition;
|
|
2014
|
+
this.defaultBaselineIndex = p2.uint16;
|
|
2015
|
+
this.baseCoordCount = p2.uint16;
|
|
2016
|
+
this.baseCoords = [...new Array(this.baseCoordCount)].map(
|
|
2017
|
+
(_) => p2.Offset16
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
getTable(id) {
|
|
2021
|
+
this.parser.currentPosition = this.start + this.baseCoords[id];
|
|
2022
|
+
return new BaseCoordTable(this.parser);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
class MinMaxTable {
|
|
2026
|
+
constructor(p2) {
|
|
2027
|
+
this.minCoord = p2.Offset16;
|
|
2028
|
+
this.maxCoord = p2.Offset16;
|
|
2029
|
+
this.featMinMaxCount = p2.uint16;
|
|
2030
|
+
const recordStart = p2.currentPosition;
|
|
2031
|
+
lazy$1(this, `featMinMaxRecords`, () => {
|
|
2032
|
+
p2.currentPosition = recordStart;
|
|
2033
|
+
return [...new Array(this.featMinMaxCount)].map(
|
|
2034
|
+
(_) => new FeatMinMaxRecord(p2)
|
|
2035
|
+
);
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
class FeatMinMaxRecord {
|
|
2040
|
+
constructor(p2) {
|
|
2041
|
+
this.featureTableTag = p2.tag;
|
|
2042
|
+
this.minCoord = p2.Offset16;
|
|
2043
|
+
this.maxCoord = p2.Offset16;
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
class BaseCoordTable {
|
|
2047
|
+
constructor(p2) {
|
|
2048
|
+
this.baseCoordFormat = p2.uint16;
|
|
2049
|
+
this.coordinate = p2.int16;
|
|
2050
|
+
if (this.baseCoordFormat === 2) {
|
|
2051
|
+
this.referenceGlyph = p2.uint16;
|
|
2052
|
+
this.baseCoordPoint = p2.uint16;
|
|
2053
|
+
}
|
|
2054
|
+
if (this.baseCoordFormat === 3) {
|
|
2055
|
+
this.deviceTable = p2.Offset16;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
var BASE$1 = Object.freeze({ __proto__: null, BASE });
|
|
2060
|
+
class ClassDefinition {
|
|
2061
|
+
constructor(p2) {
|
|
2062
|
+
this.classFormat = p2.uint16;
|
|
2063
|
+
if (this.classFormat === 1) {
|
|
2064
|
+
this.startGlyphID = p2.uint16;
|
|
2065
|
+
this.glyphCount = p2.uint16;
|
|
2066
|
+
this.classValueArray = [...new Array(this.glyphCount)].map(
|
|
2067
|
+
(_) => p2.uint16
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
if (this.classFormat === 2) {
|
|
2071
|
+
this.classRangeCount = p2.uint16;
|
|
2072
|
+
this.classRangeRecords = [
|
|
2073
|
+
...new Array(this.classRangeCount)
|
|
2074
|
+
].map((_) => new ClassRangeRecord(p2));
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
class ClassRangeRecord {
|
|
2079
|
+
constructor(p2) {
|
|
2080
|
+
this.startGlyphID = p2.uint16;
|
|
2081
|
+
this.endGlyphID = p2.uint16;
|
|
2082
|
+
this.class = p2.uint16;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
class CoverageTable extends ParsedData {
|
|
2086
|
+
constructor(p2) {
|
|
2087
|
+
super(p2);
|
|
2088
|
+
this.coverageFormat = p2.uint16;
|
|
2089
|
+
if (this.coverageFormat === 1) {
|
|
2090
|
+
this.glyphCount = p2.uint16;
|
|
2091
|
+
this.glyphArray = [...new Array(this.glyphCount)].map(
|
|
2092
|
+
(_) => p2.uint16
|
|
2093
|
+
);
|
|
2094
|
+
}
|
|
2095
|
+
if (this.coverageFormat === 2) {
|
|
2096
|
+
this.rangeCount = p2.uint16;
|
|
2097
|
+
this.rangeRecords = [...new Array(this.rangeCount)].map(
|
|
2098
|
+
(_) => new CoverageRangeRecord(p2)
|
|
2099
|
+
);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
class CoverageRangeRecord {
|
|
2104
|
+
constructor(p2) {
|
|
2105
|
+
this.startGlyphID = p2.uint16;
|
|
2106
|
+
this.endGlyphID = p2.uint16;
|
|
2107
|
+
this.startCoverageIndex = p2.uint16;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
class ItemVariationStoreTable {
|
|
2111
|
+
constructor(table, p2) {
|
|
2112
|
+
this.table = table;
|
|
2113
|
+
this.parser = p2;
|
|
2114
|
+
this.start = p2.currentPosition;
|
|
2115
|
+
this.format = p2.uint16;
|
|
2116
|
+
this.variationRegionListOffset = p2.Offset32;
|
|
2117
|
+
this.itemVariationDataCount = p2.uint16;
|
|
2118
|
+
this.itemVariationDataOffsets = [
|
|
2119
|
+
...new Array(this.itemVariationDataCount)
|
|
2120
|
+
].map((_) => p2.Offset32);
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
class GDEF extends SimpleTable {
|
|
2124
|
+
constructor(dict, dataview) {
|
|
2125
|
+
const { p: p2 } = super(dict, dataview);
|
|
2126
|
+
this.majorVersion = p2.uint16;
|
|
2127
|
+
this.minorVersion = p2.uint16;
|
|
2128
|
+
this.glyphClassDefOffset = p2.Offset16;
|
|
2129
|
+
lazy$1(this, `glyphClassDefs`, () => {
|
|
2130
|
+
if (this.glyphClassDefOffset === 0) return void 0;
|
|
2131
|
+
p2.currentPosition = this.tableStart + this.glyphClassDefOffset;
|
|
2132
|
+
return new ClassDefinition(p2);
|
|
2133
|
+
});
|
|
2134
|
+
this.attachListOffset = p2.Offset16;
|
|
2135
|
+
lazy$1(this, `attachList`, () => {
|
|
2136
|
+
if (this.attachListOffset === 0) return void 0;
|
|
2137
|
+
p2.currentPosition = this.tableStart + this.attachListOffset;
|
|
2138
|
+
return new AttachList(p2);
|
|
2139
|
+
});
|
|
2140
|
+
this.ligCaretListOffset = p2.Offset16;
|
|
2141
|
+
lazy$1(this, `ligCaretList`, () => {
|
|
2142
|
+
if (this.ligCaretListOffset === 0) return void 0;
|
|
2143
|
+
p2.currentPosition = this.tableStart + this.ligCaretListOffset;
|
|
2144
|
+
return new LigCaretList(p2);
|
|
2145
|
+
});
|
|
2146
|
+
this.markAttachClassDefOffset = p2.Offset16;
|
|
2147
|
+
lazy$1(this, `markAttachClassDef`, () => {
|
|
2148
|
+
if (this.markAttachClassDefOffset === 0) return void 0;
|
|
2149
|
+
p2.currentPosition = this.tableStart + this.markAttachClassDefOffset;
|
|
2150
|
+
return new ClassDefinition(p2);
|
|
2151
|
+
});
|
|
2152
|
+
if (this.minorVersion >= 2) {
|
|
2153
|
+
this.markGlyphSetsDefOffset = p2.Offset16;
|
|
2154
|
+
lazy$1(this, `markGlyphSetsDef`, () => {
|
|
2155
|
+
if (this.markGlyphSetsDefOffset === 0) return void 0;
|
|
2156
|
+
p2.currentPosition = this.tableStart + this.markGlyphSetsDefOffset;
|
|
2157
|
+
return new MarkGlyphSetsTable(p2);
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
if (this.minorVersion === 3) {
|
|
2161
|
+
this.itemVarStoreOffset = p2.Offset32;
|
|
2162
|
+
lazy$1(this, `itemVarStore`, () => {
|
|
2163
|
+
if (this.itemVarStoreOffset === 0) return void 0;
|
|
2164
|
+
p2.currentPosition = this.tableStart + this.itemVarStoreOffset;
|
|
2165
|
+
return new ItemVariationStoreTable(p2);
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
class AttachList extends ParsedData {
|
|
2171
|
+
constructor(p2) {
|
|
2172
|
+
super(p2);
|
|
2173
|
+
this.coverageOffset = p2.Offset16;
|
|
2174
|
+
this.glyphCount = p2.uint16;
|
|
2175
|
+
this.attachPointOffsets = [...new Array(this.glyphCount)].map(
|
|
2176
|
+
(_) => p2.Offset16
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
getPoint(pointID) {
|
|
2180
|
+
this.parser.currentPosition = this.start + this.attachPointOffsets[pointID];
|
|
2181
|
+
return new AttachPoint(this.parser);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
class AttachPoint {
|
|
2185
|
+
constructor(p2) {
|
|
2186
|
+
this.pointCount = p2.uint16;
|
|
2187
|
+
this.pointIndices = [...new Array(this.pointCount)].map(
|
|
2188
|
+
(_) => p2.uint16
|
|
2189
|
+
);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
class LigCaretList extends ParsedData {
|
|
2193
|
+
constructor(p2) {
|
|
2194
|
+
super(p2);
|
|
2195
|
+
this.coverageOffset = p2.Offset16;
|
|
2196
|
+
lazy$1(this, `coverage`, () => {
|
|
2197
|
+
p2.currentPosition = this.start + this.coverageOffset;
|
|
2198
|
+
return new CoverageTable(p2);
|
|
2199
|
+
});
|
|
2200
|
+
this.ligGlyphCount = p2.uint16;
|
|
2201
|
+
this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map(
|
|
2202
|
+
(_) => p2.Offset16
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2205
|
+
getLigGlyph(ligGlyphID) {
|
|
2206
|
+
this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID];
|
|
2207
|
+
return new LigGlyph(this.parser);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
class LigGlyph extends ParsedData {
|
|
2211
|
+
constructor(p2) {
|
|
2212
|
+
super(p2);
|
|
2213
|
+
this.caretCount = p2.uint16;
|
|
2214
|
+
this.caretValueOffsets = [...new Array(this.caretCount)].map(
|
|
2215
|
+
(_) => p2.Offset16
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2218
|
+
getCaretValue(caretID) {
|
|
2219
|
+
this.parser.currentPosition = this.start + this.caretValueOffsets[caretID];
|
|
2220
|
+
return new CaretValue(this.parser);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
class CaretValue {
|
|
2224
|
+
constructor(p2) {
|
|
2225
|
+
this.caretValueFormat = p2.uint16;
|
|
2226
|
+
if (this.caretValueFormat === 1) {
|
|
2227
|
+
this.coordinate = p2.int16;
|
|
2228
|
+
}
|
|
2229
|
+
if (this.caretValueFormat === 2) {
|
|
2230
|
+
this.caretValuePointIndex = p2.uint16;
|
|
2231
|
+
}
|
|
2232
|
+
if (this.caretValueFormat === 3) {
|
|
2233
|
+
this.coordinate = p2.int16;
|
|
2234
|
+
this.deviceOffset = p2.Offset16;
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
class MarkGlyphSetsTable extends ParsedData {
|
|
2239
|
+
constructor(p2) {
|
|
2240
|
+
super(p2);
|
|
2241
|
+
this.markGlyphSetTableFormat = p2.uint16;
|
|
2242
|
+
this.markGlyphSetCount = p2.uint16;
|
|
2243
|
+
this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map(
|
|
2244
|
+
(_) => p2.Offset32
|
|
2245
|
+
);
|
|
2246
|
+
}
|
|
2247
|
+
getMarkGlyphSet(markGlyphSetID) {
|
|
2248
|
+
this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID];
|
|
2249
|
+
return new CoverageTable(this.parser);
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
var GDEF$1 = Object.freeze({ __proto__: null, GDEF });
|
|
2253
|
+
class ScriptList extends ParsedData {
|
|
2254
|
+
static EMPTY = { scriptCount: 0, scriptRecords: [] };
|
|
2255
|
+
constructor(p2) {
|
|
2256
|
+
super(p2);
|
|
2257
|
+
this.scriptCount = p2.uint16;
|
|
2258
|
+
this.scriptRecords = [...new Array(this.scriptCount)].map(
|
|
2259
|
+
(_) => new ScriptRecord(p2)
|
|
2260
|
+
);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
class ScriptRecord {
|
|
2264
|
+
constructor(p2) {
|
|
2265
|
+
this.scriptTag = p2.tag;
|
|
2266
|
+
this.scriptOffset = p2.Offset16;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
class ScriptTable extends ParsedData {
|
|
2270
|
+
constructor(p2) {
|
|
2271
|
+
super(p2);
|
|
2272
|
+
this.defaultLangSys = p2.Offset16;
|
|
2273
|
+
this.langSysCount = p2.uint16;
|
|
2274
|
+
this.langSysRecords = [...new Array(this.langSysCount)].map(
|
|
2275
|
+
(_) => new LangSysRecord(p2)
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
class LangSysRecord {
|
|
2280
|
+
constructor(p2) {
|
|
2281
|
+
this.langSysTag = p2.tag;
|
|
2282
|
+
this.langSysOffset = p2.Offset16;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
class LangSysTable {
|
|
2286
|
+
constructor(p2) {
|
|
2287
|
+
this.lookupOrder = p2.Offset16;
|
|
2288
|
+
this.requiredFeatureIndex = p2.uint16;
|
|
2289
|
+
this.featureIndexCount = p2.uint16;
|
|
2290
|
+
this.featureIndices = [...new Array(this.featureIndexCount)].map(
|
|
2291
|
+
(_) => p2.uint16
|
|
2292
|
+
);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
class FeatureList extends ParsedData {
|
|
2296
|
+
static EMPTY = { featureCount: 0, featureRecords: [] };
|
|
2297
|
+
constructor(p2) {
|
|
2298
|
+
super(p2);
|
|
2299
|
+
this.featureCount = p2.uint16;
|
|
2300
|
+
this.featureRecords = [...new Array(this.featureCount)].map(
|
|
2301
|
+
(_) => new FeatureRecord(p2)
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
class FeatureRecord {
|
|
2306
|
+
constructor(p2) {
|
|
2307
|
+
this.featureTag = p2.tag;
|
|
2308
|
+
this.featureOffset = p2.Offset16;
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
class FeatureTable extends ParsedData {
|
|
2312
|
+
constructor(p2) {
|
|
2313
|
+
super(p2);
|
|
2314
|
+
this.featureParams = p2.Offset16;
|
|
2315
|
+
this.lookupIndexCount = p2.uint16;
|
|
2316
|
+
this.lookupListIndices = [...new Array(this.lookupIndexCount)].map(
|
|
2317
|
+
(_) => p2.uint16
|
|
2318
|
+
);
|
|
2319
|
+
}
|
|
2320
|
+
getFeatureParams() {
|
|
2321
|
+
if (this.featureParams > 0) {
|
|
2322
|
+
const p2 = this.parser;
|
|
2323
|
+
p2.currentPosition = this.start + this.featureParams;
|
|
2324
|
+
const tag = this.featureTag;
|
|
2325
|
+
if (tag === `size`) return new Size(p2);
|
|
2326
|
+
if (tag.startsWith(`cc`)) return new CharacterVariant(p2);
|
|
2327
|
+
if (tag.startsWith(`ss`)) return new StylisticSet(p2);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
class CharacterVariant {
|
|
2332
|
+
constructor(p2) {
|
|
2333
|
+
this.format = p2.uint16;
|
|
2334
|
+
this.featUiLabelNameId = p2.uint16;
|
|
2335
|
+
this.featUiTooltipTextNameId = p2.uint16;
|
|
2336
|
+
this.sampleTextNameId = p2.uint16;
|
|
2337
|
+
this.numNamedParameters = p2.uint16;
|
|
2338
|
+
this.firstParamUiLabelNameId = p2.uint16;
|
|
2339
|
+
this.charCount = p2.uint16;
|
|
2340
|
+
this.character = [...new Array(this.charCount)].map(
|
|
2341
|
+
(_) => p2.uint24
|
|
2342
|
+
);
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
class Size {
|
|
2346
|
+
constructor(p2) {
|
|
2347
|
+
this.designSize = p2.uint16;
|
|
2348
|
+
this.subfamilyIdentifier = p2.uint16;
|
|
2349
|
+
this.subfamilyNameID = p2.uint16;
|
|
2350
|
+
this.smallEnd = p2.uint16;
|
|
2351
|
+
this.largeEnd = p2.uint16;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
class StylisticSet {
|
|
2355
|
+
constructor(p2) {
|
|
2356
|
+
this.version = p2.uint16;
|
|
2357
|
+
this.UINameID = p2.uint16;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
function undoCoverageOffsetParsing(instance) {
|
|
2361
|
+
instance.parser.currentPosition -= 2;
|
|
2362
|
+
delete instance.coverageOffset;
|
|
2363
|
+
delete instance.getCoverageTable;
|
|
2364
|
+
}
|
|
2365
|
+
class LookupType$1 extends ParsedData {
|
|
2366
|
+
constructor(p2) {
|
|
2367
|
+
super(p2);
|
|
2368
|
+
this.substFormat = p2.uint16;
|
|
2369
|
+
this.coverageOffset = p2.Offset16;
|
|
2370
|
+
}
|
|
2371
|
+
getCoverageTable() {
|
|
2372
|
+
let p2 = this.parser;
|
|
2373
|
+
p2.currentPosition = this.start + this.coverageOffset;
|
|
2374
|
+
return new CoverageTable(p2);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
class SubstLookupRecord {
|
|
2378
|
+
constructor(p2) {
|
|
2379
|
+
this.glyphSequenceIndex = p2.uint16;
|
|
2380
|
+
this.lookupListIndex = p2.uint16;
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
class LookupType1$1 extends LookupType$1 {
|
|
2384
|
+
constructor(p2) {
|
|
2385
|
+
super(p2);
|
|
2386
|
+
this.deltaGlyphID = p2.int16;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
class LookupType2$1 extends LookupType$1 {
|
|
2390
|
+
constructor(p2) {
|
|
2391
|
+
super(p2);
|
|
2392
|
+
this.sequenceCount = p2.uint16;
|
|
2393
|
+
this.sequenceOffsets = [...new Array(this.sequenceCount)].map(
|
|
2394
|
+
(_) => p2.Offset16
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
getSequence(index) {
|
|
2398
|
+
let p2 = this.parser;
|
|
2399
|
+
p2.currentPosition = this.start + this.sequenceOffsets[index];
|
|
2400
|
+
return new SequenceTable(p2);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
class SequenceTable {
|
|
2404
|
+
constructor(p2) {
|
|
2405
|
+
this.glyphCount = p2.uint16;
|
|
2406
|
+
this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
|
|
2407
|
+
(_) => p2.uint16
|
|
2408
|
+
);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
class LookupType3$1 extends LookupType$1 {
|
|
2412
|
+
constructor(p2) {
|
|
2413
|
+
super(p2);
|
|
2414
|
+
this.alternateSetCount = p2.uint16;
|
|
2415
|
+
this.alternateSetOffsets = [
|
|
2416
|
+
...new Array(this.alternateSetCount)
|
|
2417
|
+
].map((_) => p2.Offset16);
|
|
2418
|
+
}
|
|
2419
|
+
getAlternateSet(index) {
|
|
2420
|
+
let p2 = this.parser;
|
|
2421
|
+
p2.currentPosition = this.start + this.alternateSetOffsets[index];
|
|
2422
|
+
return new AlternateSetTable(p2);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
class AlternateSetTable {
|
|
2426
|
+
constructor(p2) {
|
|
2427
|
+
this.glyphCount = p2.uint16;
|
|
2428
|
+
this.alternateGlyphIDs = [...new Array(this.glyphCount)].map(
|
|
2429
|
+
(_) => p2.uint16
|
|
2430
|
+
);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
class LookupType4$1 extends LookupType$1 {
|
|
2434
|
+
constructor(p2) {
|
|
2435
|
+
super(p2);
|
|
2436
|
+
this.ligatureSetCount = p2.uint16;
|
|
2437
|
+
this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map(
|
|
2438
|
+
(_) => p2.Offset16
|
|
2439
|
+
);
|
|
2440
|
+
}
|
|
2441
|
+
getLigatureSet(index) {
|
|
2442
|
+
let p2 = this.parser;
|
|
2443
|
+
p2.currentPosition = this.start + this.ligatureSetOffsets[index];
|
|
2444
|
+
return new LigatureSetTable(p2);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
class LigatureSetTable extends ParsedData {
|
|
2448
|
+
constructor(p2) {
|
|
2449
|
+
super(p2);
|
|
2450
|
+
this.ligatureCount = p2.uint16;
|
|
2451
|
+
this.ligatureOffsets = [...new Array(this.ligatureCount)].map(
|
|
2452
|
+
(_) => p2.Offset16
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
getLigature(index) {
|
|
2456
|
+
let p2 = this.parser;
|
|
2457
|
+
p2.currentPosition = this.start + this.ligatureOffsets[index];
|
|
2458
|
+
return new LigatureTable(p2);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
class LigatureTable {
|
|
2462
|
+
constructor(p2) {
|
|
2463
|
+
this.ligatureGlyph = p2.uint16;
|
|
2464
|
+
this.componentCount = p2.uint16;
|
|
2465
|
+
this.componentGlyphIDs = [
|
|
2466
|
+
...new Array(this.componentCount - 1)
|
|
2467
|
+
].map((_) => p2.uint16);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
class LookupType5$1 extends LookupType$1 {
|
|
2471
|
+
constructor(p2) {
|
|
2472
|
+
super(p2);
|
|
2473
|
+
if (this.substFormat === 1) {
|
|
2474
|
+
this.subRuleSetCount = p2.uint16;
|
|
2475
|
+
this.subRuleSetOffsets = [
|
|
2476
|
+
...new Array(this.subRuleSetCount)
|
|
2477
|
+
].map((_) => p2.Offset16);
|
|
2478
|
+
}
|
|
2479
|
+
if (this.substFormat === 2) {
|
|
2480
|
+
this.classDefOffset = p2.Offset16;
|
|
2481
|
+
this.subClassSetCount = p2.uint16;
|
|
2482
|
+
this.subClassSetOffsets = [
|
|
2483
|
+
...new Array(this.subClassSetCount)
|
|
2484
|
+
].map((_) => p2.Offset16);
|
|
2485
|
+
}
|
|
2486
|
+
if (this.substFormat === 3) {
|
|
2487
|
+
undoCoverageOffsetParsing(this);
|
|
2488
|
+
this.glyphCount = p2.uint16;
|
|
2489
|
+
this.substitutionCount = p2.uint16;
|
|
2490
|
+
this.coverageOffsets = [...new Array(this.glyphCount)].map(
|
|
2491
|
+
(_) => p2.Offset16
|
|
2492
|
+
);
|
|
2493
|
+
this.substLookupRecords = [
|
|
2494
|
+
...new Array(this.substitutionCount)
|
|
2495
|
+
].map((_) => new SubstLookupRecord(p2));
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
getSubRuleSet(index) {
|
|
2499
|
+
if (this.substFormat !== 1)
|
|
2500
|
+
throw new Error(
|
|
2501
|
+
`lookup type 5.${this.substFormat} has no subrule sets.`
|
|
2502
|
+
);
|
|
2503
|
+
let p2 = this.parser;
|
|
2504
|
+
p2.currentPosition = this.start + this.subRuleSetOffsets[index];
|
|
2505
|
+
return new SubRuleSetTable(p2);
|
|
2506
|
+
}
|
|
2507
|
+
getSubClassSet(index) {
|
|
2508
|
+
if (this.substFormat !== 2)
|
|
2509
|
+
throw new Error(
|
|
2510
|
+
`lookup type 5.${this.substFormat} has no subclass sets.`
|
|
2511
|
+
);
|
|
2512
|
+
let p2 = this.parser;
|
|
2513
|
+
p2.currentPosition = this.start + this.subClassSetOffsets[index];
|
|
2514
|
+
return new SubClassSetTable(p2);
|
|
2515
|
+
}
|
|
2516
|
+
getCoverageTable(index) {
|
|
2517
|
+
if (this.substFormat !== 3 && !index)
|
|
2518
|
+
return super.getCoverageTable();
|
|
2519
|
+
if (!index)
|
|
2520
|
+
throw new Error(
|
|
2521
|
+
`lookup type 5.${this.substFormat} requires an coverage table index.`
|
|
2522
|
+
);
|
|
2523
|
+
let p2 = this.parser;
|
|
2524
|
+
p2.currentPosition = this.start + this.coverageOffsets[index];
|
|
2525
|
+
return new CoverageTable(p2);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
class SubRuleSetTable extends ParsedData {
|
|
2529
|
+
constructor(p2) {
|
|
2530
|
+
super(p2);
|
|
2531
|
+
this.subRuleCount = p2.uint16;
|
|
2532
|
+
this.subRuleOffsets = [...new Array(this.subRuleCount)].map(
|
|
2533
|
+
(_) => p2.Offset16
|
|
2534
|
+
);
|
|
2535
|
+
}
|
|
2536
|
+
getSubRule(index) {
|
|
2537
|
+
let p2 = this.parser;
|
|
2538
|
+
p2.currentPosition = this.start + this.subRuleOffsets[index];
|
|
2539
|
+
return new SubRuleTable(p2);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
class SubRuleTable {
|
|
2543
|
+
constructor(p2) {
|
|
2544
|
+
this.glyphCount = p2.uint16;
|
|
2545
|
+
this.substitutionCount = p2.uint16;
|
|
2546
|
+
this.inputSequence = [...new Array(this.glyphCount - 1)].map(
|
|
2547
|
+
(_) => p2.uint16
|
|
2548
|
+
);
|
|
2549
|
+
this.substLookupRecords = [
|
|
2550
|
+
...new Array(this.substitutionCount)
|
|
2551
|
+
].map((_) => new SubstLookupRecord(p2));
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
class SubClassSetTable extends ParsedData {
|
|
2555
|
+
constructor(p2) {
|
|
2556
|
+
super(p2);
|
|
2557
|
+
this.subClassRuleCount = p2.uint16;
|
|
2558
|
+
this.subClassRuleOffsets = [
|
|
2559
|
+
...new Array(this.subClassRuleCount)
|
|
2560
|
+
].map((_) => p2.Offset16);
|
|
2561
|
+
}
|
|
2562
|
+
getSubClass(index) {
|
|
2563
|
+
let p2 = this.parser;
|
|
2564
|
+
p2.currentPosition = this.start + this.subClassRuleOffsets[index];
|
|
2565
|
+
return new SubClassRuleTable(p2);
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
class SubClassRuleTable extends SubRuleTable {
|
|
2569
|
+
constructor(p2) {
|
|
2570
|
+
super(p2);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
class LookupType6$1 extends LookupType$1 {
|
|
2574
|
+
constructor(p2) {
|
|
2575
|
+
super(p2);
|
|
2576
|
+
if (this.substFormat === 1) {
|
|
2577
|
+
this.chainSubRuleSetCount = p2.uint16;
|
|
2578
|
+
this.chainSubRuleSetOffsets = [
|
|
2579
|
+
...new Array(this.chainSubRuleSetCount)
|
|
2580
|
+
].map((_) => p2.Offset16);
|
|
2581
|
+
}
|
|
2582
|
+
if (this.substFormat === 2) {
|
|
2583
|
+
this.backtrackClassDefOffset = p2.Offset16;
|
|
2584
|
+
this.inputClassDefOffset = p2.Offset16;
|
|
2585
|
+
this.lookaheadClassDefOffset = p2.Offset16;
|
|
2586
|
+
this.chainSubClassSetCount = p2.uint16;
|
|
2587
|
+
this.chainSubClassSetOffsets = [
|
|
2588
|
+
...new Array(this.chainSubClassSetCount)
|
|
2589
|
+
].map((_) => p2.Offset16);
|
|
2590
|
+
}
|
|
2591
|
+
if (this.substFormat === 3) {
|
|
2592
|
+
undoCoverageOffsetParsing(this);
|
|
2593
|
+
this.backtrackGlyphCount = p2.uint16;
|
|
2594
|
+
this.backtrackCoverageOffsets = [
|
|
2595
|
+
...new Array(this.backtrackGlyphCount)
|
|
2596
|
+
].map((_) => p2.Offset16);
|
|
2597
|
+
this.inputGlyphCount = p2.uint16;
|
|
2598
|
+
this.inputCoverageOffsets = [
|
|
2599
|
+
...new Array(this.inputGlyphCount)
|
|
2600
|
+
].map((_) => p2.Offset16);
|
|
2601
|
+
this.lookaheadGlyphCount = p2.uint16;
|
|
2602
|
+
this.lookaheadCoverageOffsets = [
|
|
2603
|
+
...new Array(this.lookaheadGlyphCount)
|
|
2604
|
+
].map((_) => p2.Offset16);
|
|
2605
|
+
this.seqLookupCount = p2.uint16;
|
|
2606
|
+
this.seqLookupRecords = [
|
|
2607
|
+
...new Array(this.substitutionCount)
|
|
2608
|
+
].map((_) => new SequenceLookupRecord(p2));
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
getChainSubRuleSet(index) {
|
|
2612
|
+
if (this.substFormat !== 1)
|
|
2613
|
+
throw new Error(
|
|
2614
|
+
`lookup type 6.${this.substFormat} has no chainsubrule sets.`
|
|
2615
|
+
);
|
|
2616
|
+
let p2 = this.parser;
|
|
2617
|
+
p2.currentPosition = this.start + this.chainSubRuleSetOffsets[index];
|
|
2618
|
+
return new ChainSubRuleSetTable(p2);
|
|
2619
|
+
}
|
|
2620
|
+
getChainSubClassSet(index) {
|
|
2621
|
+
if (this.substFormat !== 2)
|
|
2622
|
+
throw new Error(
|
|
2623
|
+
`lookup type 6.${this.substFormat} has no chainsubclass sets.`
|
|
2624
|
+
);
|
|
2625
|
+
let p2 = this.parser;
|
|
2626
|
+
p2.currentPosition = this.start + this.chainSubClassSetOffsets[index];
|
|
2627
|
+
return new ChainSubClassSetTable(p2);
|
|
2628
|
+
}
|
|
2629
|
+
getCoverageFromOffset(offset) {
|
|
2630
|
+
if (this.substFormat !== 3)
|
|
2631
|
+
throw new Error(
|
|
2632
|
+
`lookup type 6.${this.substFormat} does not use contextual coverage offsets.`
|
|
2633
|
+
);
|
|
2634
|
+
let p2 = this.parser;
|
|
2635
|
+
p2.currentPosition = this.start + offset;
|
|
2636
|
+
return new CoverageTable(p2);
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
class ChainSubRuleSetTable extends ParsedData {
|
|
2640
|
+
constructor(p2) {
|
|
2641
|
+
super(p2);
|
|
2642
|
+
this.chainSubRuleCount = p2.uint16;
|
|
2643
|
+
this.chainSubRuleOffsets = [
|
|
2644
|
+
...new Array(this.chainSubRuleCount)
|
|
2645
|
+
].map((_) => p2.Offset16);
|
|
2646
|
+
}
|
|
2647
|
+
getSubRule(index) {
|
|
2648
|
+
let p2 = this.parser;
|
|
2649
|
+
p2.currentPosition = this.start + this.chainSubRuleOffsets[index];
|
|
2650
|
+
return new ChainSubRuleTable(p2);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
class ChainSubRuleTable {
|
|
2654
|
+
constructor(p2) {
|
|
2655
|
+
this.backtrackGlyphCount = p2.uint16;
|
|
2656
|
+
this.backtrackSequence = [
|
|
2657
|
+
...new Array(this.backtrackGlyphCount)
|
|
2658
|
+
].map((_) => p2.uint16);
|
|
2659
|
+
this.inputGlyphCount = p2.uint16;
|
|
2660
|
+
this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
|
|
2661
|
+
(_) => p2.uint16
|
|
2662
|
+
);
|
|
2663
|
+
this.lookaheadGlyphCount = p2.uint16;
|
|
2664
|
+
this.lookAheadSequence = [
|
|
2665
|
+
...new Array(this.lookAheadGlyphCount)
|
|
2666
|
+
].map((_) => p2.uint16);
|
|
2667
|
+
this.substitutionCount = p2.uint16;
|
|
2668
|
+
this.substLookupRecords = [...new Array(this.SubstCount)].map(
|
|
2669
|
+
(_) => new SubstLookupRecord(p2)
|
|
2670
|
+
);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
class ChainSubClassSetTable extends ParsedData {
|
|
2674
|
+
constructor(p2) {
|
|
2675
|
+
super(p2);
|
|
2676
|
+
this.chainSubClassRuleCount = p2.uint16;
|
|
2677
|
+
this.chainSubClassRuleOffsets = [
|
|
2678
|
+
...new Array(this.chainSubClassRuleCount)
|
|
2679
|
+
].map((_) => p2.Offset16);
|
|
2680
|
+
}
|
|
2681
|
+
getSubClass(index) {
|
|
2682
|
+
let p2 = this.parser;
|
|
2683
|
+
p2.currentPosition = this.start + this.chainSubRuleOffsets[index];
|
|
2684
|
+
return new ChainSubClassRuleTable(p2);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
class ChainSubClassRuleTable {
|
|
2688
|
+
constructor(p2) {
|
|
2689
|
+
this.backtrackGlyphCount = p2.uint16;
|
|
2690
|
+
this.backtrackSequence = [
|
|
2691
|
+
...new Array(this.backtrackGlyphCount)
|
|
2692
|
+
].map((_) => p2.uint16);
|
|
2693
|
+
this.inputGlyphCount = p2.uint16;
|
|
2694
|
+
this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
|
|
2695
|
+
(_) => p2.uint16
|
|
2696
|
+
);
|
|
2697
|
+
this.lookaheadGlyphCount = p2.uint16;
|
|
2698
|
+
this.lookAheadSequence = [
|
|
2699
|
+
...new Array(this.lookAheadGlyphCount)
|
|
2700
|
+
].map((_) => p2.uint16);
|
|
2701
|
+
this.substitutionCount = p2.uint16;
|
|
2702
|
+
this.substLookupRecords = [
|
|
2703
|
+
...new Array(this.substitutionCount)
|
|
2704
|
+
].map((_) => new SequenceLookupRecord(p2));
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
class SequenceLookupRecord extends ParsedData {
|
|
2708
|
+
constructor(p2) {
|
|
2709
|
+
super(p2);
|
|
2710
|
+
this.sequenceIndex = p2.uint16;
|
|
2711
|
+
this.lookupListIndex = p2.uint16;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
class LookupType7$1 extends ParsedData {
|
|
2715
|
+
constructor(p2) {
|
|
2716
|
+
super(p2);
|
|
2717
|
+
this.substFormat = p2.uint16;
|
|
2718
|
+
this.extensionLookupType = p2.uint16;
|
|
2719
|
+
this.extensionOffset = p2.Offset32;
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
class LookupType8$1 extends LookupType$1 {
|
|
2723
|
+
constructor(p2) {
|
|
2724
|
+
super(p2);
|
|
2725
|
+
this.backtrackGlyphCount = p2.uint16;
|
|
2726
|
+
this.backtrackCoverageOffsets = [
|
|
2727
|
+
...new Array(this.backtrackGlyphCount)
|
|
2728
|
+
].map((_) => p2.Offset16);
|
|
2729
|
+
this.lookaheadGlyphCount = p2.uint16;
|
|
2730
|
+
this.lookaheadCoverageOffsets = [
|
|
2731
|
+
new Array(this.lookaheadGlyphCount)
|
|
2732
|
+
].map((_) => p2.Offset16);
|
|
2733
|
+
this.glyphCount = p2.uint16;
|
|
2734
|
+
this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
|
|
2735
|
+
(_) => p2.uint16
|
|
2736
|
+
);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
var GSUBtables = {
|
|
2740
|
+
buildSubtable: function(type, p2) {
|
|
2741
|
+
const subtable = new [
|
|
2742
|
+
void 0,
|
|
2743
|
+
LookupType1$1,
|
|
2744
|
+
LookupType2$1,
|
|
2745
|
+
LookupType3$1,
|
|
2746
|
+
LookupType4$1,
|
|
2747
|
+
LookupType5$1,
|
|
2748
|
+
LookupType6$1,
|
|
2749
|
+
LookupType7$1,
|
|
2750
|
+
LookupType8$1
|
|
2751
|
+
][type](p2);
|
|
2752
|
+
subtable.type = type;
|
|
2753
|
+
return subtable;
|
|
2754
|
+
}
|
|
2755
|
+
};
|
|
2756
|
+
class LookupType extends ParsedData {
|
|
2757
|
+
constructor(p2) {
|
|
2758
|
+
super(p2);
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
class LookupType1 extends LookupType {
|
|
2762
|
+
constructor(p2) {
|
|
2763
|
+
super(p2);
|
|
2764
|
+
console.log(`lookup type 1`);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
class LookupType2 extends LookupType {
|
|
2768
|
+
constructor(p2) {
|
|
2769
|
+
super(p2);
|
|
2770
|
+
console.log(`lookup type 2`);
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
class LookupType3 extends LookupType {
|
|
2774
|
+
constructor(p2) {
|
|
2775
|
+
super(p2);
|
|
2776
|
+
console.log(`lookup type 3`);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
class LookupType4 extends LookupType {
|
|
2780
|
+
constructor(p2) {
|
|
2781
|
+
super(p2);
|
|
2782
|
+
console.log(`lookup type 4`);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
class LookupType5 extends LookupType {
|
|
2786
|
+
constructor(p2) {
|
|
2787
|
+
super(p2);
|
|
2788
|
+
console.log(`lookup type 5`);
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
class LookupType6 extends LookupType {
|
|
2792
|
+
constructor(p2) {
|
|
2793
|
+
super(p2);
|
|
2794
|
+
console.log(`lookup type 6`);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
class LookupType7 extends LookupType {
|
|
2798
|
+
constructor(p2) {
|
|
2799
|
+
super(p2);
|
|
2800
|
+
console.log(`lookup type 7`);
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
class LookupType8 extends LookupType {
|
|
2804
|
+
constructor(p2) {
|
|
2805
|
+
super(p2);
|
|
2806
|
+
console.log(`lookup type 8`);
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
class LookupType9 extends LookupType {
|
|
2810
|
+
constructor(p2) {
|
|
2811
|
+
super(p2);
|
|
2812
|
+
console.log(`lookup type 9`);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
var GPOStables = {
|
|
2816
|
+
buildSubtable: function(type, p2) {
|
|
2817
|
+
const subtable = new [
|
|
2818
|
+
void 0,
|
|
2819
|
+
LookupType1,
|
|
2820
|
+
LookupType2,
|
|
2821
|
+
LookupType3,
|
|
2822
|
+
LookupType4,
|
|
2823
|
+
LookupType5,
|
|
2824
|
+
LookupType6,
|
|
2825
|
+
LookupType7,
|
|
2826
|
+
LookupType8,
|
|
2827
|
+
LookupType9
|
|
2828
|
+
][type](p2);
|
|
2829
|
+
subtable.type = type;
|
|
2830
|
+
return subtable;
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
class LookupList extends ParsedData {
|
|
2834
|
+
static EMPTY = { lookupCount: 0, lookups: [] };
|
|
2835
|
+
constructor(p2) {
|
|
2836
|
+
super(p2);
|
|
2837
|
+
this.lookupCount = p2.uint16;
|
|
2838
|
+
this.lookups = [...new Array(this.lookupCount)].map(
|
|
2839
|
+
(_) => p2.Offset16
|
|
2840
|
+
);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
class LookupTable extends ParsedData {
|
|
2844
|
+
constructor(p2, type) {
|
|
2845
|
+
super(p2);
|
|
2846
|
+
this.ctType = type;
|
|
2847
|
+
this.lookupType = p2.uint16;
|
|
2848
|
+
this.lookupFlag = p2.uint16;
|
|
2849
|
+
this.subTableCount = p2.uint16;
|
|
2850
|
+
this.subtableOffsets = [...new Array(this.subTableCount)].map(
|
|
2851
|
+
(_) => p2.Offset16
|
|
2852
|
+
);
|
|
2853
|
+
this.markFilteringSet = p2.uint16;
|
|
2854
|
+
}
|
|
2855
|
+
get rightToLeft() {
|
|
2856
|
+
return this.lookupFlag & true;
|
|
2857
|
+
}
|
|
2858
|
+
get ignoreBaseGlyphs() {
|
|
2859
|
+
return this.lookupFlag & true;
|
|
2860
|
+
}
|
|
2861
|
+
get ignoreLigatures() {
|
|
2862
|
+
return this.lookupFlag & true;
|
|
2863
|
+
}
|
|
2864
|
+
get ignoreMarks() {
|
|
2865
|
+
return this.lookupFlag & true;
|
|
2866
|
+
}
|
|
2867
|
+
get useMarkFilteringSet() {
|
|
2868
|
+
return this.lookupFlag & true;
|
|
2869
|
+
}
|
|
2870
|
+
get markAttachmentType() {
|
|
2871
|
+
return this.lookupFlag & true;
|
|
2872
|
+
}
|
|
2873
|
+
getSubTable(index) {
|
|
2874
|
+
const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables;
|
|
2875
|
+
this.parser.currentPosition = this.start + this.subtableOffsets[index];
|
|
2876
|
+
return builder.buildSubtable(this.lookupType, this.parser);
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
class CommonLayoutTable extends SimpleTable {
|
|
2880
|
+
constructor(dict, dataview, name2) {
|
|
2881
|
+
const { p: p2, tableStart } = super(dict, dataview, name2);
|
|
2882
|
+
this.majorVersion = p2.uint16;
|
|
2883
|
+
this.minorVersion = p2.uint16;
|
|
2884
|
+
this.scriptListOffset = p2.Offset16;
|
|
2885
|
+
this.featureListOffset = p2.Offset16;
|
|
2886
|
+
this.lookupListOffset = p2.Offset16;
|
|
2887
|
+
if (this.majorVersion === 1 && this.minorVersion === 1) {
|
|
2888
|
+
this.featureVariationsOffset = p2.Offset32;
|
|
2889
|
+
}
|
|
2890
|
+
const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset);
|
|
2891
|
+
lazy$1(this, `scriptList`, () => {
|
|
2892
|
+
if (no_content) return ScriptList.EMPTY;
|
|
2893
|
+
p2.currentPosition = tableStart + this.scriptListOffset;
|
|
2894
|
+
return new ScriptList(p2);
|
|
2895
|
+
});
|
|
2896
|
+
lazy$1(this, `featureList`, () => {
|
|
2897
|
+
if (no_content) return FeatureList.EMPTY;
|
|
2898
|
+
p2.currentPosition = tableStart + this.featureListOffset;
|
|
2899
|
+
return new FeatureList(p2);
|
|
2900
|
+
});
|
|
2901
|
+
lazy$1(this, `lookupList`, () => {
|
|
2902
|
+
if (no_content) return LookupList.EMPTY;
|
|
2903
|
+
p2.currentPosition = tableStart + this.lookupListOffset;
|
|
2904
|
+
return new LookupList(p2);
|
|
2905
|
+
});
|
|
2906
|
+
if (this.featureVariationsOffset) {
|
|
2907
|
+
lazy$1(this, `featureVariations`, () => {
|
|
2908
|
+
if (no_content) return FeatureVariations.EMPTY;
|
|
2909
|
+
p2.currentPosition = tableStart + this.featureVariationsOffset;
|
|
2910
|
+
return new FeatureVariations(p2);
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
getSupportedScripts() {
|
|
2915
|
+
return this.scriptList.scriptRecords.map((r) => r.scriptTag);
|
|
2916
|
+
}
|
|
2917
|
+
getScriptTable(scriptTag) {
|
|
2918
|
+
let record = this.scriptList.scriptRecords.find(
|
|
2919
|
+
(r) => r.scriptTag === scriptTag
|
|
2920
|
+
);
|
|
2921
|
+
this.parser.currentPosition = this.scriptList.start + record.scriptOffset;
|
|
2922
|
+
let table = new ScriptTable(this.parser);
|
|
2923
|
+
table.scriptTag = scriptTag;
|
|
2924
|
+
return table;
|
|
2925
|
+
}
|
|
2926
|
+
ensureScriptTable(arg) {
|
|
2927
|
+
if (typeof arg === "string") {
|
|
2928
|
+
return this.getScriptTable(arg);
|
|
2929
|
+
}
|
|
2930
|
+
return arg;
|
|
2931
|
+
}
|
|
2932
|
+
getSupportedLangSys(scriptTable) {
|
|
2933
|
+
scriptTable = this.ensureScriptTable(scriptTable);
|
|
2934
|
+
const hasDefault = scriptTable.defaultLangSys !== 0;
|
|
2935
|
+
const supported = scriptTable.langSysRecords.map(
|
|
2936
|
+
(l) => l.langSysTag
|
|
2937
|
+
);
|
|
2938
|
+
if (hasDefault) supported.unshift(`dflt`);
|
|
2939
|
+
return supported;
|
|
2940
|
+
}
|
|
2941
|
+
getDefaultLangSysTable(scriptTable) {
|
|
2942
|
+
scriptTable = this.ensureScriptTable(scriptTable);
|
|
2943
|
+
let offset = scriptTable.defaultLangSys;
|
|
2944
|
+
if (offset !== 0) {
|
|
2945
|
+
this.parser.currentPosition = scriptTable.start + offset;
|
|
2946
|
+
let table = new LangSysTable(this.parser);
|
|
2947
|
+
table.langSysTag = ``;
|
|
2948
|
+
table.defaultForScript = scriptTable.scriptTag;
|
|
2949
|
+
return table;
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
getLangSysTable(scriptTable, langSysTag = `dflt`) {
|
|
2953
|
+
if (langSysTag === `dflt`)
|
|
2954
|
+
return this.getDefaultLangSysTable(scriptTable);
|
|
2955
|
+
scriptTable = this.ensureScriptTable(scriptTable);
|
|
2956
|
+
let record = scriptTable.langSysRecords.find(
|
|
2957
|
+
(l) => l.langSysTag === langSysTag
|
|
2958
|
+
);
|
|
2959
|
+
this.parser.currentPosition = scriptTable.start + record.langSysOffset;
|
|
2960
|
+
let table = new LangSysTable(this.parser);
|
|
2961
|
+
table.langSysTag = langSysTag;
|
|
2962
|
+
return table;
|
|
2963
|
+
}
|
|
2964
|
+
getFeatures(langSysTable) {
|
|
2965
|
+
return langSysTable.featureIndices.map(
|
|
2966
|
+
(index) => this.getFeature(index)
|
|
2967
|
+
);
|
|
2968
|
+
}
|
|
2969
|
+
getFeature(indexOrTag) {
|
|
2970
|
+
let record;
|
|
2971
|
+
if (parseInt(indexOrTag) == indexOrTag) {
|
|
2972
|
+
record = this.featureList.featureRecords[indexOrTag];
|
|
2973
|
+
} else {
|
|
2974
|
+
record = this.featureList.featureRecords.find(
|
|
2975
|
+
(f) => f.featureTag === indexOrTag
|
|
2976
|
+
);
|
|
2977
|
+
}
|
|
2978
|
+
if (!record) return;
|
|
2979
|
+
this.parser.currentPosition = this.featureList.start + record.featureOffset;
|
|
2980
|
+
let table = new FeatureTable(this.parser);
|
|
2981
|
+
table.featureTag = record.featureTag;
|
|
2982
|
+
return table;
|
|
2983
|
+
}
|
|
2984
|
+
getLookups(featureTable) {
|
|
2985
|
+
return featureTable.lookupListIndices.map(
|
|
2986
|
+
(index) => this.getLookup(index)
|
|
2987
|
+
);
|
|
2988
|
+
}
|
|
2989
|
+
getLookup(lookupIndex, type) {
|
|
2990
|
+
let lookupOffset = this.lookupList.lookups[lookupIndex];
|
|
2991
|
+
this.parser.currentPosition = this.lookupList.start + lookupOffset;
|
|
2992
|
+
return new LookupTable(this.parser, type);
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
class GSUB extends CommonLayoutTable {
|
|
2996
|
+
constructor(dict, dataview) {
|
|
2997
|
+
super(dict, dataview, `GSUB`);
|
|
2998
|
+
}
|
|
2999
|
+
getLookup(lookupIndex) {
|
|
3000
|
+
return super.getLookup(lookupIndex, `GSUB`);
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
var GSUB$1 = Object.freeze({ __proto__: null, GSUB });
|
|
3004
|
+
class GPOS extends CommonLayoutTable {
|
|
3005
|
+
constructor(dict, dataview) {
|
|
3006
|
+
super(dict, dataview, `GPOS`);
|
|
3007
|
+
}
|
|
3008
|
+
getLookup(lookupIndex) {
|
|
3009
|
+
return super.getLookup(lookupIndex, `GPOS`);
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
var GPOS$1 = Object.freeze({ __proto__: null, GPOS });
|
|
3013
|
+
class SVG extends SimpleTable {
|
|
3014
|
+
constructor(dict, dataview) {
|
|
3015
|
+
const { p: p2 } = super(dict, dataview);
|
|
3016
|
+
this.version = p2.uint16;
|
|
3017
|
+
this.offsetToSVGDocumentList = p2.Offset32;
|
|
3018
|
+
p2.currentPosition = this.tableStart + this.offsetToSVGDocumentList;
|
|
3019
|
+
this.documentList = new SVGDocumentList(p2);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
class SVGDocumentList extends ParsedData {
|
|
3023
|
+
constructor(p2) {
|
|
3024
|
+
super(p2);
|
|
3025
|
+
this.numEntries = p2.uint16;
|
|
3026
|
+
this.documentRecords = [...new Array(this.numEntries)].map(
|
|
3027
|
+
(_) => new SVGDocumentRecord(p2)
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3030
|
+
getDocument(documentID) {
|
|
3031
|
+
let record = this.documentRecords[documentID];
|
|
3032
|
+
if (!record) return "";
|
|
3033
|
+
let offset = this.start + record.svgDocOffset;
|
|
3034
|
+
this.parser.currentPosition = offset;
|
|
3035
|
+
return this.parser.readBytes(record.svgDocLength);
|
|
3036
|
+
}
|
|
3037
|
+
getDocumentForGlyph(glyphID) {
|
|
3038
|
+
let id = this.documentRecords.findIndex(
|
|
3039
|
+
(d) => d.startGlyphID <= glyphID && glyphID <= d.endGlyphID
|
|
3040
|
+
);
|
|
3041
|
+
if (id === -1) return "";
|
|
3042
|
+
return this.getDocument(id);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
class SVGDocumentRecord {
|
|
3046
|
+
constructor(p2) {
|
|
3047
|
+
this.startGlyphID = p2.uint16;
|
|
3048
|
+
this.endGlyphID = p2.uint16;
|
|
3049
|
+
this.svgDocOffset = p2.Offset32;
|
|
3050
|
+
this.svgDocLength = p2.uint32;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
var SVG$1 = Object.freeze({ __proto__: null, SVG });
|
|
3054
|
+
class fvar extends SimpleTable {
|
|
3055
|
+
constructor(dict, dataview) {
|
|
3056
|
+
const { p: p2 } = super(dict, dataview);
|
|
3057
|
+
this.majorVersion = p2.uint16;
|
|
3058
|
+
this.minorVersion = p2.uint16;
|
|
3059
|
+
this.axesArrayOffset = p2.Offset16;
|
|
3060
|
+
p2.uint16;
|
|
3061
|
+
this.axisCount = p2.uint16;
|
|
3062
|
+
this.axisSize = p2.uint16;
|
|
3063
|
+
this.instanceCount = p2.uint16;
|
|
3064
|
+
this.instanceSize = p2.uint16;
|
|
3065
|
+
const axisStart = this.tableStart + this.axesArrayOffset;
|
|
3066
|
+
lazy$1(this, `axes`, () => {
|
|
3067
|
+
p2.currentPosition = axisStart;
|
|
3068
|
+
return [...new Array(this.axisCount)].map(
|
|
3069
|
+
(_) => new VariationAxisRecord(p2)
|
|
3070
|
+
);
|
|
3071
|
+
});
|
|
3072
|
+
const instanceStart = axisStart + this.axisCount * this.axisSize;
|
|
3073
|
+
lazy$1(this, `instances`, () => {
|
|
3074
|
+
let instances = [];
|
|
3075
|
+
for (let i = 0; i < this.instanceCount; i++) {
|
|
3076
|
+
p2.currentPosition = instanceStart + i * this.instanceSize;
|
|
3077
|
+
instances.push(
|
|
3078
|
+
new InstanceRecord(p2, this.axisCount, this.instanceSize)
|
|
3079
|
+
);
|
|
3080
|
+
}
|
|
3081
|
+
return instances;
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
getSupportedAxes() {
|
|
3085
|
+
return this.axes.map((a) => a.tag);
|
|
3086
|
+
}
|
|
3087
|
+
getAxis(name2) {
|
|
3088
|
+
return this.axes.find((a) => a.tag === name2);
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
class VariationAxisRecord {
|
|
3092
|
+
constructor(p2) {
|
|
3093
|
+
this.tag = p2.tag;
|
|
3094
|
+
this.minValue = p2.fixed;
|
|
3095
|
+
this.defaultValue = p2.fixed;
|
|
3096
|
+
this.maxValue = p2.fixed;
|
|
3097
|
+
this.flags = p2.flags(16);
|
|
3098
|
+
this.axisNameID = p2.uint16;
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
class InstanceRecord {
|
|
3102
|
+
constructor(p2, axisCount, size) {
|
|
3103
|
+
let start = p2.currentPosition;
|
|
3104
|
+
this.subfamilyNameID = p2.uint16;
|
|
3105
|
+
p2.uint16;
|
|
3106
|
+
this.coordinates = [...new Array(axisCount)].map(
|
|
3107
|
+
(_) => p2.fixed
|
|
3108
|
+
);
|
|
3109
|
+
if (p2.currentPosition - start < size) {
|
|
3110
|
+
this.postScriptNameID = p2.uint16;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
var fvar$1 = Object.freeze({ __proto__: null, fvar });
|
|
3115
|
+
class cvt extends SimpleTable {
|
|
3116
|
+
constructor(dict, dataview) {
|
|
3117
|
+
const { p: p2 } = super(dict, dataview);
|
|
3118
|
+
const n = dict.length / 2;
|
|
3119
|
+
lazy$1(
|
|
3120
|
+
this,
|
|
3121
|
+
`items`,
|
|
3122
|
+
() => [...new Array(n)].map((_) => p2.fword)
|
|
3123
|
+
);
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
var cvt$1 = Object.freeze({ __proto__: null, cvt });
|
|
3127
|
+
class fpgm extends SimpleTable {
|
|
3128
|
+
constructor(dict, dataview) {
|
|
3129
|
+
const { p: p2 } = super(dict, dataview);
|
|
3130
|
+
lazy$1(
|
|
3131
|
+
this,
|
|
3132
|
+
`instructions`,
|
|
3133
|
+
() => [...new Array(dict.length)].map((_) => p2.uint8)
|
|
3134
|
+
);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
var fpgm$1 = Object.freeze({ __proto__: null, fpgm });
|
|
3138
|
+
class gasp extends SimpleTable {
|
|
3139
|
+
constructor(dict, dataview) {
|
|
3140
|
+
const { p: p2 } = super(dict, dataview);
|
|
3141
|
+
this.version = p2.uint16;
|
|
3142
|
+
this.numRanges = p2.uint16;
|
|
3143
|
+
const getter = () => [...new Array(this.numRanges)].map(
|
|
3144
|
+
(_) => new GASPRange(p2)
|
|
3145
|
+
);
|
|
3146
|
+
lazy$1(this, `gaspRanges`, getter);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
class GASPRange {
|
|
3150
|
+
constructor(p2) {
|
|
3151
|
+
this.rangeMaxPPEM = p2.uint16;
|
|
3152
|
+
this.rangeGaspBehavior = p2.uint16;
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
var gasp$1 = Object.freeze({ __proto__: null, gasp });
|
|
3156
|
+
class glyf extends SimpleTable {
|
|
3157
|
+
constructor(dict, dataview) {
|
|
3158
|
+
super(dict, dataview);
|
|
3159
|
+
}
|
|
3160
|
+
getGlyphData(offset, length) {
|
|
3161
|
+
this.parser.currentPosition = this.tableStart + offset;
|
|
3162
|
+
return this.parser.readBytes(length);
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
var glyf$1 = Object.freeze({ __proto__: null, glyf });
|
|
3166
|
+
class loca extends SimpleTable {
|
|
3167
|
+
constructor(dict, dataview, tables) {
|
|
3168
|
+
const { p: p2 } = super(dict, dataview);
|
|
3169
|
+
const n = tables.maxp.numGlyphs + 1;
|
|
3170
|
+
if (tables.head.indexToLocFormat === 0) {
|
|
3171
|
+
this.x2 = true;
|
|
3172
|
+
lazy$1(
|
|
3173
|
+
this,
|
|
3174
|
+
`offsets`,
|
|
3175
|
+
() => [...new Array(n)].map((_) => p2.Offset16)
|
|
3176
|
+
);
|
|
3177
|
+
} else {
|
|
3178
|
+
lazy$1(
|
|
3179
|
+
this,
|
|
3180
|
+
`offsets`,
|
|
3181
|
+
() => [...new Array(n)].map((_) => p2.Offset32)
|
|
3182
|
+
);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
getGlyphDataOffsetAndLength(glyphID) {
|
|
3186
|
+
let offset = this.offsets[glyphID] * this.x2 ? 2 : 1;
|
|
3187
|
+
let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1;
|
|
3188
|
+
return { offset, length: nextOffset - offset };
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
var loca$1 = Object.freeze({ __proto__: null, loca });
|
|
3192
|
+
class prep extends SimpleTable {
|
|
3193
|
+
constructor(dict, dataview) {
|
|
3194
|
+
const { p: p2 } = super(dict, dataview);
|
|
3195
|
+
lazy$1(
|
|
3196
|
+
this,
|
|
3197
|
+
`instructions`,
|
|
3198
|
+
() => [...new Array(dict.length)].map((_) => p2.uint8)
|
|
3199
|
+
);
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
var prep$1 = Object.freeze({ __proto__: null, prep });
|
|
3203
|
+
class CFF extends SimpleTable {
|
|
3204
|
+
constructor(dict, dataview) {
|
|
3205
|
+
const { p: p2 } = super(dict, dataview);
|
|
3206
|
+
lazy$1(this, `data`, () => p2.readBytes());
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
var CFF$1 = Object.freeze({ __proto__: null, CFF });
|
|
3210
|
+
class CFF2 extends SimpleTable {
|
|
3211
|
+
constructor(dict, dataview) {
|
|
3212
|
+
const { p: p2 } = super(dict, dataview);
|
|
3213
|
+
lazy$1(this, `data`, () => p2.readBytes());
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
var CFF2$1 = Object.freeze({ __proto__: null, CFF2 });
|
|
3217
|
+
class VORG extends SimpleTable {
|
|
3218
|
+
constructor(dict, dataview) {
|
|
3219
|
+
const { p: p2 } = super(dict, dataview);
|
|
3220
|
+
this.majorVersion = p2.uint16;
|
|
3221
|
+
this.minorVersion = p2.uint16;
|
|
3222
|
+
this.defaultVertOriginY = p2.int16;
|
|
3223
|
+
this.numVertOriginYMetrics = p2.uint16;
|
|
3224
|
+
lazy$1(
|
|
3225
|
+
this,
|
|
3226
|
+
`vertORiginYMetrics`,
|
|
3227
|
+
() => [...new Array(this.numVertOriginYMetrics)].map(
|
|
3228
|
+
(_) => new VertOriginYMetric(p2)
|
|
3229
|
+
)
|
|
3230
|
+
);
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
class VertOriginYMetric {
|
|
3234
|
+
constructor(p2) {
|
|
3235
|
+
this.glyphIndex = p2.uint16;
|
|
3236
|
+
this.vertOriginY = p2.int16;
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
var VORG$1 = Object.freeze({ __proto__: null, VORG });
|
|
3240
|
+
class BitmapSize {
|
|
3241
|
+
constructor(p2) {
|
|
3242
|
+
this.indexSubTableArrayOffset = p2.Offset32;
|
|
3243
|
+
this.indexTablesSize = p2.uint32;
|
|
3244
|
+
this.numberofIndexSubTables = p2.uint32;
|
|
3245
|
+
this.colorRef = p2.uint32;
|
|
3246
|
+
this.hori = new SbitLineMetrics(p2);
|
|
3247
|
+
this.vert = new SbitLineMetrics(p2);
|
|
3248
|
+
this.startGlyphIndex = p2.uint16;
|
|
3249
|
+
this.endGlyphIndex = p2.uint16;
|
|
3250
|
+
this.ppemX = p2.uint8;
|
|
3251
|
+
this.ppemY = p2.uint8;
|
|
3252
|
+
this.bitDepth = p2.uint8;
|
|
3253
|
+
this.flags = p2.int8;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
class BitmapScale {
|
|
3257
|
+
constructor(p2) {
|
|
3258
|
+
this.hori = new SbitLineMetrics(p2);
|
|
3259
|
+
this.vert = new SbitLineMetrics(p2);
|
|
3260
|
+
this.ppemX = p2.uint8;
|
|
3261
|
+
this.ppemY = p2.uint8;
|
|
3262
|
+
this.substitutePpemX = p2.uint8;
|
|
3263
|
+
this.substitutePpemY = p2.uint8;
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
class SbitLineMetrics {
|
|
3267
|
+
constructor(p2) {
|
|
3268
|
+
this.ascender = p2.int8;
|
|
3269
|
+
this.descender = p2.int8;
|
|
3270
|
+
this.widthMax = p2.uint8;
|
|
3271
|
+
this.caretSlopeNumerator = p2.int8;
|
|
3272
|
+
this.caretSlopeDenominator = p2.int8;
|
|
3273
|
+
this.caretOffset = p2.int8;
|
|
3274
|
+
this.minOriginSB = p2.int8;
|
|
3275
|
+
this.minAdvanceSB = p2.int8;
|
|
3276
|
+
this.maxBeforeBL = p2.int8;
|
|
3277
|
+
this.minAfterBL = p2.int8;
|
|
3278
|
+
this.pad1 = p2.int8;
|
|
3279
|
+
this.pad2 = p2.int8;
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
class EBLC extends SimpleTable {
|
|
3283
|
+
constructor(dict, dataview, name2) {
|
|
3284
|
+
const { p: p2 } = super(dict, dataview, name2);
|
|
3285
|
+
this.majorVersion = p2.uint16;
|
|
3286
|
+
this.minorVersion = p2.uint16;
|
|
3287
|
+
this.numSizes = p2.uint32;
|
|
3288
|
+
lazy$1(
|
|
3289
|
+
this,
|
|
3290
|
+
`bitMapSizes`,
|
|
3291
|
+
() => [...new Array(this.numSizes)].map(
|
|
3292
|
+
(_) => new BitmapSize(p2)
|
|
3293
|
+
)
|
|
3294
|
+
);
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
var EBLC$1 = Object.freeze({ __proto__: null, EBLC });
|
|
3298
|
+
class EBDT extends SimpleTable {
|
|
3299
|
+
constructor(dict, dataview, name2) {
|
|
3300
|
+
const { p: p2 } = super(dict, dataview, name2);
|
|
3301
|
+
this.majorVersion = p2.uint16;
|
|
3302
|
+
this.minorVersion = p2.uint16;
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
var EBDT$1 = Object.freeze({ __proto__: null, EBDT });
|
|
3306
|
+
class EBSC extends SimpleTable {
|
|
3307
|
+
constructor(dict, dataview) {
|
|
3308
|
+
const { p: p2 } = super(dict, dataview);
|
|
3309
|
+
this.majorVersion = p2.uint16;
|
|
3310
|
+
this.minorVersion = p2.uint16;
|
|
3311
|
+
this.numSizes = p2.uint32;
|
|
3312
|
+
lazy$1(
|
|
3313
|
+
this,
|
|
3314
|
+
`bitmapScales`,
|
|
3315
|
+
() => [...new Array(this.numSizes)].map(
|
|
3316
|
+
(_) => new BitmapScale(p2)
|
|
3317
|
+
)
|
|
3318
|
+
);
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
var EBSC$1 = Object.freeze({ __proto__: null, EBSC });
|
|
3322
|
+
class CBLC extends EBLC {
|
|
3323
|
+
constructor(dict, dataview) {
|
|
3324
|
+
super(dict, dataview, `CBLC`);
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
var CBLC$1 = Object.freeze({ __proto__: null, CBLC });
|
|
3328
|
+
class CBDT extends EBDT {
|
|
3329
|
+
constructor(dict, dataview) {
|
|
3330
|
+
super(dict, dataview, `CBDT`);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
var CBDT$1 = Object.freeze({ __proto__: null, CBDT });
|
|
3334
|
+
class sbix extends SimpleTable {
|
|
3335
|
+
constructor(dict, dataview) {
|
|
3336
|
+
const { p: p2 } = super(dict, dataview);
|
|
3337
|
+
this.version = p2.uint16;
|
|
3338
|
+
this.flags = p2.flags(16);
|
|
3339
|
+
this.numStrikes = p2.uint32;
|
|
3340
|
+
lazy$1(
|
|
3341
|
+
this,
|
|
3342
|
+
`strikeOffsets`,
|
|
3343
|
+
() => [...new Array(this.numStrikes)].map((_) => p2.Offset32)
|
|
3344
|
+
);
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
var sbix$1 = Object.freeze({ __proto__: null, sbix });
|
|
3348
|
+
class COLR extends SimpleTable {
|
|
3349
|
+
constructor(dict, dataview) {
|
|
3350
|
+
const { p: p2 } = super(dict, dataview);
|
|
3351
|
+
this.version = p2.uint16;
|
|
3352
|
+
this.numBaseGlyphRecords = p2.uint16;
|
|
3353
|
+
this.baseGlyphRecordsOffset = p2.Offset32;
|
|
3354
|
+
this.layerRecordsOffset = p2.Offset32;
|
|
3355
|
+
this.numLayerRecords = p2.uint16;
|
|
3356
|
+
}
|
|
3357
|
+
getBaseGlyphRecord(glyphID) {
|
|
3358
|
+
let start = this.tableStart + this.baseGlyphRecordsOffset;
|
|
3359
|
+
this.parser.currentPosition = start;
|
|
3360
|
+
let first = new BaseGlyphRecord(this.parser);
|
|
3361
|
+
let firstID = first.gID;
|
|
3362
|
+
let end = this.tableStart + this.layerRecordsOffset - 6;
|
|
3363
|
+
this.parser.currentPosition = end;
|
|
3364
|
+
let last = new BaseGlyphRecord(this.parser);
|
|
3365
|
+
let lastID = last.gID;
|
|
3366
|
+
if (firstID === glyphID) return first;
|
|
3367
|
+
if (lastID === glyphID) return last;
|
|
3368
|
+
while (true) {
|
|
3369
|
+
if (start === end) break;
|
|
3370
|
+
let mid = start + (end - start) / 12;
|
|
3371
|
+
this.parser.currentPosition = mid;
|
|
3372
|
+
let middle = new BaseGlyphRecord(this.parser);
|
|
3373
|
+
let midID = middle.gID;
|
|
3374
|
+
if (midID === glyphID) return middle;
|
|
3375
|
+
else if (midID > glyphID) {
|
|
3376
|
+
end = mid;
|
|
3377
|
+
} else if (midID < glyphID) {
|
|
3378
|
+
start = mid;
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
return false;
|
|
3382
|
+
}
|
|
3383
|
+
getLayers(glyphID) {
|
|
3384
|
+
let record = this.getBaseGlyphRecord(glyphID);
|
|
3385
|
+
this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex;
|
|
3386
|
+
return [...new Array(record.numLayers)].map(
|
|
3387
|
+
(_) => new LayerRecord(p)
|
|
3388
|
+
);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
class BaseGlyphRecord {
|
|
3392
|
+
constructor(p2) {
|
|
3393
|
+
this.gID = p2.uint16;
|
|
3394
|
+
this.firstLayerIndex = p2.uint16;
|
|
3395
|
+
this.numLayers = p2.uint16;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
class LayerRecord {
|
|
3399
|
+
constructor(p2) {
|
|
3400
|
+
this.gID = p2.uint16;
|
|
3401
|
+
this.paletteIndex = p2.uint16;
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
var COLR$1 = Object.freeze({ __proto__: null, COLR });
|
|
3405
|
+
class CPAL extends SimpleTable {
|
|
3406
|
+
constructor(dict, dataview) {
|
|
3407
|
+
const { p: p2 } = super(dict, dataview);
|
|
3408
|
+
this.version = p2.uint16;
|
|
3409
|
+
this.numPaletteEntries = p2.uint16;
|
|
3410
|
+
const numPalettes = this.numPalettes = p2.uint16;
|
|
3411
|
+
this.numColorRecords = p2.uint16;
|
|
3412
|
+
this.offsetFirstColorRecord = p2.Offset32;
|
|
3413
|
+
this.colorRecordIndices = [...new Array(this.numPalettes)].map(
|
|
3414
|
+
(_) => p2.uint16
|
|
3415
|
+
);
|
|
3416
|
+
lazy$1(this, `colorRecords`, () => {
|
|
3417
|
+
p2.currentPosition = this.tableStart + this.offsetFirstColorRecord;
|
|
3418
|
+
return [...new Array(this.numColorRecords)].map(
|
|
3419
|
+
(_) => new ColorRecord(p2)
|
|
3420
|
+
);
|
|
3421
|
+
});
|
|
3422
|
+
if (this.version === 1) {
|
|
3423
|
+
this.offsetPaletteTypeArray = p2.Offset32;
|
|
3424
|
+
this.offsetPaletteLabelArray = p2.Offset32;
|
|
3425
|
+
this.offsetPaletteEntryLabelArray = p2.Offset32;
|
|
3426
|
+
lazy$1(this, `paletteTypeArray`, () => {
|
|
3427
|
+
p2.currentPosition = this.tableStart + this.offsetPaletteTypeArray;
|
|
3428
|
+
return new PaletteTypeArray(p2, numPalettes);
|
|
3429
|
+
});
|
|
3430
|
+
lazy$1(this, `paletteLabelArray`, () => {
|
|
3431
|
+
p2.currentPosition = this.tableStart + this.offsetPaletteLabelArray;
|
|
3432
|
+
return new PaletteLabelsArray(p2, numPalettes);
|
|
3433
|
+
});
|
|
3434
|
+
lazy$1(this, `paletteEntryLabelArray`, () => {
|
|
3435
|
+
p2.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray;
|
|
3436
|
+
return new PaletteEntryLabelArray(p2, numPalettes);
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
class ColorRecord {
|
|
3442
|
+
constructor(p2) {
|
|
3443
|
+
this.blue = p2.uint8;
|
|
3444
|
+
this.green = p2.uint8;
|
|
3445
|
+
this.red = p2.uint8;
|
|
3446
|
+
this.alpha = p2.uint8;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
class PaletteTypeArray {
|
|
3450
|
+
constructor(p2, numPalettes) {
|
|
3451
|
+
this.paletteTypes = [...new Array(numPalettes)].map(
|
|
3452
|
+
(_) => p2.uint32
|
|
3453
|
+
);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
class PaletteLabelsArray {
|
|
3457
|
+
constructor(p2, numPalettes) {
|
|
3458
|
+
this.paletteLabels = [...new Array(numPalettes)].map(
|
|
3459
|
+
(_) => p2.uint16
|
|
3460
|
+
);
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
class PaletteEntryLabelArray {
|
|
3464
|
+
constructor(p2, numPalettes) {
|
|
3465
|
+
this.paletteEntryLabels = [...new Array(numPalettes)].map(
|
|
3466
|
+
(_) => p2.uint16
|
|
3467
|
+
);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
var CPAL$1 = Object.freeze({ __proto__: null, CPAL });
|
|
3471
|
+
class DSIG extends SimpleTable {
|
|
3472
|
+
constructor(dict, dataview) {
|
|
3473
|
+
const { p: p2 } = super(dict, dataview);
|
|
3474
|
+
this.version = p2.uint32;
|
|
3475
|
+
this.numSignatures = p2.uint16;
|
|
3476
|
+
this.flags = p2.uint16;
|
|
3477
|
+
this.signatureRecords = [...new Array(this.numSignatures)].map(
|
|
3478
|
+
(_) => new SignatureRecord(p2)
|
|
3479
|
+
);
|
|
3480
|
+
}
|
|
3481
|
+
getData(signatureID) {
|
|
3482
|
+
const record = this.signatureRecords[signatureID];
|
|
3483
|
+
this.parser.currentPosition = this.tableStart + record.offset;
|
|
3484
|
+
return new SignatureBlockFormat1(this.parser);
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
class SignatureRecord {
|
|
3488
|
+
constructor(p2) {
|
|
3489
|
+
this.format = p2.uint32;
|
|
3490
|
+
this.length = p2.uint32;
|
|
3491
|
+
this.offset = p2.Offset32;
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
class SignatureBlockFormat1 {
|
|
3495
|
+
constructor(p2) {
|
|
3496
|
+
p2.uint16;
|
|
3497
|
+
p2.uint16;
|
|
3498
|
+
this.signatureLength = p2.uint32;
|
|
3499
|
+
this.signature = p2.readBytes(this.signatureLength);
|
|
3500
|
+
}
|
|
3501
|
+
}
|
|
3502
|
+
var DSIG$1 = Object.freeze({ __proto__: null, DSIG });
|
|
3503
|
+
class hdmx extends SimpleTable {
|
|
3504
|
+
constructor(dict, dataview, tables) {
|
|
3505
|
+
const { p: p2 } = super(dict, dataview);
|
|
3506
|
+
const numGlyphs = tables.hmtx.numGlyphs;
|
|
3507
|
+
this.version = p2.uint16;
|
|
3508
|
+
this.numRecords = p2.int16;
|
|
3509
|
+
this.sizeDeviceRecord = p2.int32;
|
|
3510
|
+
this.records = [...new Array(numRecords)].map(
|
|
3511
|
+
(_) => new DeviceRecord(p2, numGlyphs)
|
|
3512
|
+
);
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
class DeviceRecord {
|
|
3516
|
+
constructor(p2, numGlyphs) {
|
|
3517
|
+
this.pixelSize = p2.uint8;
|
|
3518
|
+
this.maxWidth = p2.uint8;
|
|
3519
|
+
this.widths = p2.readBytes(numGlyphs);
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
var hdmx$1 = Object.freeze({ __proto__: null, hdmx });
|
|
3523
|
+
class kern extends SimpleTable {
|
|
3524
|
+
constructor(dict, dataview) {
|
|
3525
|
+
const { p: p2 } = super(dict, dataview);
|
|
3526
|
+
this.version = p2.uint16;
|
|
3527
|
+
this.nTables = p2.uint16;
|
|
3528
|
+
lazy$1(this, `tables`, () => {
|
|
3529
|
+
let offset = this.tableStart + 4;
|
|
3530
|
+
const tables = [];
|
|
3531
|
+
for (let i = 0; i < this.nTables; i++) {
|
|
3532
|
+
p2.currentPosition = offset;
|
|
3533
|
+
let subtable = new KernSubTable(p2);
|
|
3534
|
+
tables.push(subtable);
|
|
3535
|
+
offset += subtable;
|
|
3536
|
+
}
|
|
3537
|
+
return tables;
|
|
3538
|
+
});
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
class KernSubTable {
|
|
3542
|
+
constructor(p2) {
|
|
3543
|
+
this.version = p2.uint16;
|
|
3544
|
+
this.length = p2.uint16;
|
|
3545
|
+
this.coverage = p2.flags(8);
|
|
3546
|
+
this.format = p2.uint8;
|
|
3547
|
+
if (this.format === 0) {
|
|
3548
|
+
this.nPairs = p2.uint16;
|
|
3549
|
+
this.searchRange = p2.uint16;
|
|
3550
|
+
this.entrySelector = p2.uint16;
|
|
3551
|
+
this.rangeShift = p2.uint16;
|
|
3552
|
+
lazy$1(
|
|
3553
|
+
this,
|
|
3554
|
+
`pairs`,
|
|
3555
|
+
() => [...new Array(this.nPairs)].map((_) => new Pair(p2))
|
|
3556
|
+
);
|
|
3557
|
+
}
|
|
3558
|
+
if (this.format === 2) {
|
|
3559
|
+
console.warn(
|
|
3560
|
+
`Kern subtable format 2 is not supported: this parser currently only parses universal table data.`
|
|
3561
|
+
);
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
get horizontal() {
|
|
3565
|
+
return this.coverage[0];
|
|
3566
|
+
}
|
|
3567
|
+
get minimum() {
|
|
3568
|
+
return this.coverage[1];
|
|
3569
|
+
}
|
|
3570
|
+
get crossstream() {
|
|
3571
|
+
return this.coverage[2];
|
|
3572
|
+
}
|
|
3573
|
+
get override() {
|
|
3574
|
+
return this.coverage[3];
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
class Pair {
|
|
3578
|
+
constructor(p2) {
|
|
3579
|
+
this.left = p2.uint16;
|
|
3580
|
+
this.right = p2.uint16;
|
|
3581
|
+
this.value = p2.fword;
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
var kern$1 = Object.freeze({ __proto__: null, kern });
|
|
3585
|
+
class LTSH extends SimpleTable {
|
|
3586
|
+
constructor(dict, dataview) {
|
|
3587
|
+
const { p: p2 } = super(dict, dataview);
|
|
3588
|
+
this.version = p2.uint16;
|
|
3589
|
+
this.numGlyphs = p2.uint16;
|
|
3590
|
+
this.yPels = p2.readBytes(this.numGlyphs);
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
var LTSH$1 = Object.freeze({ __proto__: null, LTSH });
|
|
3594
|
+
class MERG extends SimpleTable {
|
|
3595
|
+
constructor(dict, dataview) {
|
|
3596
|
+
const { p: p2 } = super(dict, dataview);
|
|
3597
|
+
this.version = p2.uint16;
|
|
3598
|
+
this.mergeClassCount = p2.uint16;
|
|
3599
|
+
this.mergeDataOffset = p2.Offset16;
|
|
3600
|
+
this.classDefCount = p2.uint16;
|
|
3601
|
+
this.offsetToClassDefOffsets = p2.Offset16;
|
|
3602
|
+
lazy$1(
|
|
3603
|
+
this,
|
|
3604
|
+
`mergeEntryMatrix`,
|
|
3605
|
+
() => [...new Array(this.mergeClassCount)].map(
|
|
3606
|
+
(_) => p2.readBytes(this.mergeClassCount)
|
|
3607
|
+
)
|
|
3608
|
+
);
|
|
3609
|
+
console.warn(`Full MERG parsing is currently not supported.`);
|
|
3610
|
+
console.warn(
|
|
3611
|
+
`If you need this table parsed, please file an issue, or better yet, a PR.`
|
|
3612
|
+
);
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
var MERG$1 = Object.freeze({ __proto__: null, MERG });
|
|
3616
|
+
class meta extends SimpleTable {
|
|
3617
|
+
constructor(dict, dataview) {
|
|
3618
|
+
const { p: p2 } = super(dict, dataview);
|
|
3619
|
+
this.version = p2.uint32;
|
|
3620
|
+
this.flags = p2.uint32;
|
|
3621
|
+
p2.uint32;
|
|
3622
|
+
this.dataMapsCount = p2.uint32;
|
|
3623
|
+
this.dataMaps = [...new Array(this.dataMapsCount)].map(
|
|
3624
|
+
(_) => new DataMap(this.tableStart, p2)
|
|
3625
|
+
);
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
class DataMap {
|
|
3629
|
+
constructor(tableStart, p2) {
|
|
3630
|
+
this.tableStart = tableStart;
|
|
3631
|
+
this.parser = p2;
|
|
3632
|
+
this.tag = p2.tag;
|
|
3633
|
+
this.dataOffset = p2.Offset32;
|
|
3634
|
+
this.dataLength = p2.uint32;
|
|
3635
|
+
}
|
|
3636
|
+
getData() {
|
|
3637
|
+
this.parser.currentField = this.tableStart + this.dataOffset;
|
|
3638
|
+
return this.parser.readBytes(this.dataLength);
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
var meta$1 = Object.freeze({ __proto__: null, meta });
|
|
3642
|
+
class PCLT extends SimpleTable {
|
|
3643
|
+
constructor(dict, dataview) {
|
|
3644
|
+
super(dict, dataview);
|
|
3645
|
+
console.warn(
|
|
3646
|
+
`This font uses a PCLT table, which is currently not supported by this parser.`
|
|
3647
|
+
);
|
|
3648
|
+
console.warn(
|
|
3649
|
+
`If you need this table parsed, please file an issue, or better yet, a PR.`
|
|
3650
|
+
);
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
var PCLT$1 = Object.freeze({ __proto__: null, PCLT });
|
|
3654
|
+
class VDMX extends SimpleTable {
|
|
3655
|
+
constructor(dict, dataview) {
|
|
3656
|
+
const { p: p2 } = super(dict, dataview);
|
|
3657
|
+
this.version = p2.uint16;
|
|
3658
|
+
this.numRecs = p2.uint16;
|
|
3659
|
+
this.numRatios = p2.uint16;
|
|
3660
|
+
this.ratRanges = [...new Array(this.numRatios)].map(
|
|
3661
|
+
(_) => new RatioRange(p2)
|
|
3662
|
+
);
|
|
3663
|
+
this.offsets = [...new Array(this.numRatios)].map(
|
|
3664
|
+
(_) => p2.Offset16
|
|
3665
|
+
);
|
|
3666
|
+
this.VDMXGroups = [...new Array(this.numRecs)].map(
|
|
3667
|
+
(_) => new VDMXGroup(p2)
|
|
3668
|
+
);
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
class RatioRange {
|
|
3672
|
+
constructor(p2) {
|
|
3673
|
+
this.bCharSet = p2.uint8;
|
|
3674
|
+
this.xRatio = p2.uint8;
|
|
3675
|
+
this.yStartRatio = p2.uint8;
|
|
3676
|
+
this.yEndRatio = p2.uint8;
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
class VDMXGroup {
|
|
3680
|
+
constructor(p2) {
|
|
3681
|
+
this.recs = p2.uint16;
|
|
3682
|
+
this.startsz = p2.uint8;
|
|
3683
|
+
this.endsz = p2.uint8;
|
|
3684
|
+
this.records = [...new Array(this.recs)].map(
|
|
3685
|
+
(_) => new vTable(p2)
|
|
3686
|
+
);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
class vTable {
|
|
3690
|
+
constructor(p2) {
|
|
3691
|
+
this.yPelHeight = p2.uint16;
|
|
3692
|
+
this.yMax = p2.int16;
|
|
3693
|
+
this.yMin = p2.int16;
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
var VDMX$1 = Object.freeze({ __proto__: null, VDMX });
|
|
3697
|
+
class vhea extends SimpleTable {
|
|
3698
|
+
constructor(dict, dataview) {
|
|
3699
|
+
const { p: p2 } = super(dict, dataview);
|
|
3700
|
+
this.version = p2.fixed;
|
|
3701
|
+
this.ascent = this.vertTypoAscender = p2.int16;
|
|
3702
|
+
this.descent = this.vertTypoDescender = p2.int16;
|
|
3703
|
+
this.lineGap = this.vertTypoLineGap = p2.int16;
|
|
3704
|
+
this.advanceHeightMax = p2.int16;
|
|
3705
|
+
this.minTopSideBearing = p2.int16;
|
|
3706
|
+
this.minBottomSideBearing = p2.int16;
|
|
3707
|
+
this.yMaxExtent = p2.int16;
|
|
3708
|
+
this.caretSlopeRise = p2.int16;
|
|
3709
|
+
this.caretSlopeRun = p2.int16;
|
|
3710
|
+
this.caretOffset = p2.int16;
|
|
3711
|
+
this.reserved = p2.int16;
|
|
3712
|
+
this.reserved = p2.int16;
|
|
3713
|
+
this.reserved = p2.int16;
|
|
3714
|
+
this.reserved = p2.int16;
|
|
3715
|
+
this.metricDataFormat = p2.int16;
|
|
3716
|
+
this.numOfLongVerMetrics = p2.uint16;
|
|
3717
|
+
p2.verifyLength();
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
var vhea$1 = Object.freeze({ __proto__: null, vhea });
|
|
3721
|
+
class vmtx extends SimpleTable {
|
|
3722
|
+
constructor(dict, dataview, tables) {
|
|
3723
|
+
super(dict, dataview);
|
|
3724
|
+
const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics;
|
|
3725
|
+
const numGlyphs = tables.maxp.numGlyphs;
|
|
3726
|
+
const metricsStart = p.currentPosition;
|
|
3727
|
+
lazy(this, `vMetrics`, () => {
|
|
3728
|
+
p.currentPosition = metricsStart;
|
|
3729
|
+
return [...new Array(numOfLongVerMetrics)].map(
|
|
3730
|
+
(_) => new LongVertMetric(p.uint16, p.int16)
|
|
3731
|
+
);
|
|
3732
|
+
});
|
|
3733
|
+
if (numOfLongVerMetrics < numGlyphs) {
|
|
3734
|
+
const tsbStart = metricsStart + numOfLongVerMetrics * 4;
|
|
3735
|
+
lazy(this, `topSideBearings`, () => {
|
|
3736
|
+
p.currentPosition = tsbStart;
|
|
3737
|
+
return [...new Array(numGlyphs - numOfLongVerMetrics)].map(
|
|
3738
|
+
(_) => p.int16
|
|
3739
|
+
);
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
class LongVertMetric {
|
|
3745
|
+
constructor(h, b) {
|
|
3746
|
+
this.advanceHeight = h;
|
|
3747
|
+
this.topSideBearing = b;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
var vmtx$1 = Object.freeze({ __proto__: null, vmtx });
|
|
3751
|
+
export {
|
|
3752
|
+
Font
|
|
3753
|
+
};
|
|
3754
|
+
//# sourceMappingURL=lib-font.browser.js.map
|