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