zhui-plus 1.0.0 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of zhui-plus might be problematic. Click here for more details.

Files changed (820) hide show
  1. package/dist/Heatmap.js +689 -0
  2. package/dist/WSPlayer/PlaySDKInterface.js +1 -0
  3. package/dist/WSPlayer/WSPlayer.js +1 -0
  4. package/dist/WSPlayer/audioTalkWorker.js +1 -0
  5. package/dist/WSPlayer/commonThread/libH264Enc.js +21 -0
  6. package/dist/WSPlayer/commonThread/libH264Enc.wasm +0 -0
  7. package/dist/WSPlayer/commonThread/libIVSDrawer.js +21 -0
  8. package/dist/WSPlayer/commonThread/libIVSDrawer.wasm +0 -0
  9. package/dist/WSPlayer/commonThread/libRenderEngine.js +21 -0
  10. package/dist/WSPlayer/commonThread/libRenderEngine.wasm +0 -0
  11. package/dist/WSPlayer/commonThread/libmavasp_litepacket.data +50 -0
  12. package/dist/WSPlayer/commonThread/libmavasp_litepacket.js +21 -0
  13. package/dist/WSPlayer/commonThread/libmavasp_litepacket.wasm +0 -0
  14. package/dist/WSPlayer/icon/IotComboBackGround-alarm.png +0 -0
  15. package/dist/WSPlayer/icon/IotComboBackGround.png +0 -0
  16. package/dist/WSPlayer/icon/RecordHover.svg +13 -0
  17. package/dist/WSPlayer/icon/RecordNormal.svg +13 -0
  18. package/dist/WSPlayer/icon/Recording.svg +15 -0
  19. package/dist/WSPlayer/icon/arrow-b.svg +9 -0
  20. package/dist/WSPlayer/icon/arrow-l.svg +9 -0
  21. package/dist/WSPlayer/icon/arrow-lb.svg +10 -0
  22. package/dist/WSPlayer/icon/arrow-lt.svg +10 -0
  23. package/dist/WSPlayer/icon/arrow-r.svg +9 -0
  24. package/dist/WSPlayer/icon/arrow-rb.svg +10 -0
  25. package/dist/WSPlayer/icon/arrow-rt.svg +10 -0
  26. package/dist/WSPlayer/icon/arrow-t.svg +9 -0
  27. package/dist/WSPlayer/icon/close-all-hover.svg +18 -0
  28. package/dist/WSPlayer/icon/close-all.svg +18 -0
  29. package/dist/WSPlayer/icon/close.svg +16 -0
  30. package/dist/WSPlayer/icon/close_hover.svg +16 -0
  31. package/dist/WSPlayer/icon/default.png +0 -0
  32. package/dist/WSPlayer/icon/draw-triangle_off.svg +14 -0
  33. package/dist/WSPlayer/icon/draw-triangle_off_hover.svg +14 -0
  34. package/dist/WSPlayer/icon/draw-triangle_on.svg +15 -0
  35. package/dist/WSPlayer/icon/draw-triangle_on_hover.svg +15 -0
  36. package/dist/WSPlayer/icon/drops.png +0 -0
  37. package/dist/WSPlayer/icon/fullscreen-hover.svg +13 -0
  38. package/dist/WSPlayer/icon/fullscreen.svg +13 -0
  39. package/dist/WSPlayer/icon/hide-pantilt-on.svg +13 -0
  40. package/dist/WSPlayer/icon/hide-pantilt.svg +13 -0
  41. package/dist/WSPlayer/icon/mobile-speed-control-icon.svg +13 -0
  42. package/dist/WSPlayer/icon/more.svg +13 -0
  43. package/dist/WSPlayer/icon/play-h.png +0 -0
  44. package/dist/WSPlayer/icon/play-n.png +0 -0
  45. package/dist/WSPlayer/icon/play-p.png +0 -0
  46. package/dist/WSPlayer/icon/ptz-icon1.svg +4 -0
  47. package/dist/WSPlayer/icon/ptz-icon2.svg +13 -0
  48. package/dist/WSPlayer/icon/ptz-icon3.svg +10 -0
  49. package/dist/WSPlayer/icon/ptz-icon4.svg +10 -0
  50. package/dist/WSPlayer/icon/ptz-icon5.svg +12 -0
  51. package/dist/WSPlayer/icon/ptz-icon6.svg +14 -0
  52. package/dist/WSPlayer/icon/ptz-select-hover.svg +3 -0
  53. package/dist/WSPlayer/icon/ptz-select.svg +3 -0
  54. package/dist/WSPlayer/icon/record_pause.svg +5 -0
  55. package/dist/WSPlayer/icon/record_play.svg +5 -0
  56. package/dist/WSPlayer/icon/refresh-replay.svg +11 -0
  57. package/dist/WSPlayer/icon/refresh-replay_hover.svg +11 -0
  58. package/dist/WSPlayer/icon/screen-more-icon.svg +15 -0
  59. package/dist/WSPlayer/icon/screen_1.svg +11 -0
  60. package/dist/WSPlayer/icon/screen_16.svg +18 -0
  61. package/dist/WSPlayer/icon/screen_16_hover.svg +18 -0
  62. package/dist/WSPlayer/icon/screen_1_hover.svg +11 -0
  63. package/dist/WSPlayer/icon/screen_2.svg +18 -0
  64. package/dist/WSPlayer/icon/screen_25.svg +19 -0
  65. package/dist/WSPlayer/icon/screen_25_hover.svg +19 -0
  66. package/dist/WSPlayer/icon/screen_2_hover.svg +18 -0
  67. package/dist/WSPlayer/icon/screen_3.svg +13 -0
  68. package/dist/WSPlayer/icon/screen_3_hover.svg +13 -0
  69. package/dist/WSPlayer/icon/screen_4.svg +12 -0
  70. package/dist/WSPlayer/icon/screen_4_hover.svg +12 -0
  71. package/dist/WSPlayer/icon/screen_6.svg +16 -0
  72. package/dist/WSPlayer/icon/screen_6_hover.svg +16 -0
  73. package/dist/WSPlayer/icon/screen_8.svg +18 -0
  74. package/dist/WSPlayer/icon/screen_8_hover.svg +18 -0
  75. package/dist/WSPlayer/icon/screen_9.svg +17 -0
  76. package/dist/WSPlayer/icon/screen_9_hover.svg +17 -0
  77. package/dist/WSPlayer/icon/screen_custom_division.svg +9 -0
  78. package/dist/WSPlayer/icon/screen_custom_division_hover.svg +9 -0
  79. package/dist/WSPlayer/icon/screen_custom_division_merge.svg +3 -0
  80. package/dist/WSPlayer/icon/screen_custom_division_split.svg +6 -0
  81. package/dist/WSPlayer/icon/snapshot.svg +38 -0
  82. package/dist/WSPlayer/icon/snapshot_hover.svg +38 -0
  83. package/dist/WSPlayer/icon/speed_left.svg +15 -0
  84. package/dist/WSPlayer/icon/speed_right.svg +15 -0
  85. package/dist/WSPlayer/icon/spread.png +0 -0
  86. package/dist/WSPlayer/icon/tag-left-alarm.png +0 -0
  87. package/dist/WSPlayer/icon/tag-left-normal.png +0 -0
  88. package/dist/WSPlayer/icon/tag-middle-alarm.png +0 -0
  89. package/dist/WSPlayer/icon/tag-middle-normal.png +0 -0
  90. package/dist/WSPlayer/icon/tag-right-alarm.png +0 -0
  91. package/dist/WSPlayer/icon/tag-right-normal.png +0 -0
  92. package/dist/WSPlayer/icon/talk-off-hover.svg +11 -0
  93. package/dist/WSPlayer/icon/talk-off.svg +11 -0
  94. package/dist/WSPlayer/icon/talk-on.svg +9 -0
  95. package/dist/WSPlayer/icon/voice-have.svg +43 -0
  96. package/dist/WSPlayer/icon/voice-have_hover.svg +43 -0
  97. package/dist/WSPlayer/icon/voice-null.svg +38 -0
  98. package/dist/WSPlayer/icon/voice-null_hover.svg +38 -0
  99. package/dist/WSPlayer/icon/ws-ctrl-ellipsis-hover.svg +14 -0
  100. package/dist/WSPlayer/icon/ws-ctrl-ellipsis.svg +14 -0
  101. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-b-bg.png +0 -0
  102. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-bg.png +0 -0
  103. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-l-bg.png +0 -0
  104. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-lb-bg.png +0 -0
  105. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-lt-bg.png +0 -0
  106. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-r-bg.png +0 -0
  107. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-rb-bg.png +0 -0
  108. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-rt-bg.png +0 -0
  109. package/dist/WSPlayer/icon/wsplayer-mobile-pantilt-t-bg.png +0 -0
  110. package/dist/WSPlayer/jquery-3.6.0.min.js +2 -0
  111. package/dist/WSPlayer/multiThread/libStreamClient.js +21 -0
  112. package/dist/WSPlayer/multiThread/libStreamClient.wasm +0 -0
  113. package/dist/WSPlayer/multiThread/libStreamClient.worker.js +1 -0
  114. package/dist/WSPlayer/multiThread/libplay.data +0 -0
  115. package/dist/WSPlayer/multiThread/libplay.js +1 -0
  116. package/dist/WSPlayer/multiThread/libplay.wasm +0 -0
  117. package/dist/WSPlayer/multiThread/libplay.worker.js +1 -0
  118. package/dist/WSPlayer/player.css +1490 -0
  119. package/dist/WSPlayer/singleThread/VideoDecodeWorker.js +1439 -0
  120. package/dist/WSPlayer/singleThread/libStreamClient.js +21 -0
  121. package/dist/WSPlayer/singleThread/libStreamClient.wasm +0 -0
  122. package/dist/WSPlayer/singleThread/libplay.data +0 -0
  123. package/dist/WSPlayer/singleThread/libplay.js +1 -0
  124. package/dist/WSPlayer/singleThread/libplay.wasm +0 -0
  125. package/dist/WSPlayer/window.division.css +80 -0
  126. package/dist/index.js +467 -0
  127. package/dist/locale/af.js +193 -0
  128. package/dist/locale/af.min.js +3 -0
  129. package/dist/locale/af.min.js.map +1 -0
  130. package/dist/locale/af.min.mjs +3 -0
  131. package/dist/locale/af.min.mjs.map +1 -0
  132. package/dist/locale/af.mjs +186 -0
  133. package/dist/locale/ar-eg.js +193 -0
  134. package/dist/locale/ar-eg.min.js +3 -0
  135. package/dist/locale/ar-eg.min.js.map +1 -0
  136. package/dist/locale/ar-eg.min.mjs +3 -0
  137. package/dist/locale/ar-eg.min.mjs.map +1 -0
  138. package/dist/locale/ar-eg.mjs +186 -0
  139. package/dist/locale/ar.js +193 -0
  140. package/dist/locale/ar.min.js +3 -0
  141. package/dist/locale/ar.min.js.map +1 -0
  142. package/dist/locale/ar.min.mjs +3 -0
  143. package/dist/locale/ar.min.mjs.map +1 -0
  144. package/dist/locale/ar.mjs +186 -0
  145. package/dist/locale/az.js +194 -0
  146. package/dist/locale/az.min.js +3 -0
  147. package/dist/locale/az.min.js.map +1 -0
  148. package/dist/locale/az.min.mjs +3 -0
  149. package/dist/locale/az.min.mjs.map +1 -0
  150. package/dist/locale/az.mjs +187 -0
  151. package/dist/locale/bg.js +193 -0
  152. package/dist/locale/bg.min.js +3 -0
  153. package/dist/locale/bg.min.js.map +1 -0
  154. package/dist/locale/bg.min.mjs +3 -0
  155. package/dist/locale/bg.min.mjs.map +1 -0
  156. package/dist/locale/bg.mjs +186 -0
  157. package/dist/locale/bn.js +193 -0
  158. package/dist/locale/bn.min.js +3 -0
  159. package/dist/locale/bn.min.js.map +1 -0
  160. package/dist/locale/bn.min.mjs +3 -0
  161. package/dist/locale/bn.min.mjs.map +1 -0
  162. package/dist/locale/bn.mjs +186 -0
  163. package/dist/locale/ca.js +193 -0
  164. package/dist/locale/ca.min.js +3 -0
  165. package/dist/locale/ca.min.js.map +1 -0
  166. package/dist/locale/ca.min.mjs +3 -0
  167. package/dist/locale/ca.min.mjs.map +1 -0
  168. package/dist/locale/ca.mjs +186 -0
  169. package/dist/locale/ckb.js +193 -0
  170. package/dist/locale/ckb.min.js +3 -0
  171. package/dist/locale/ckb.min.js.map +1 -0
  172. package/dist/locale/ckb.min.mjs +3 -0
  173. package/dist/locale/ckb.min.mjs.map +1 -0
  174. package/dist/locale/ckb.mjs +186 -0
  175. package/dist/locale/cs.js +195 -0
  176. package/dist/locale/cs.min.js +3 -0
  177. package/dist/locale/cs.min.js.map +1 -0
  178. package/dist/locale/cs.min.mjs +3 -0
  179. package/dist/locale/cs.min.mjs.map +1 -0
  180. package/dist/locale/cs.mjs +188 -0
  181. package/dist/locale/da.js +193 -0
  182. package/dist/locale/da.min.js +3 -0
  183. package/dist/locale/da.min.js.map +1 -0
  184. package/dist/locale/da.min.mjs +3 -0
  185. package/dist/locale/da.min.mjs.map +1 -0
  186. package/dist/locale/da.mjs +186 -0
  187. package/dist/locale/de.js +195 -0
  188. package/dist/locale/de.min.js +3 -0
  189. package/dist/locale/de.min.js.map +1 -0
  190. package/dist/locale/de.min.mjs +3 -0
  191. package/dist/locale/de.min.mjs.map +1 -0
  192. package/dist/locale/de.mjs +188 -0
  193. package/dist/locale/el.js +193 -0
  194. package/dist/locale/el.min.js +3 -0
  195. package/dist/locale/el.min.js.map +1 -0
  196. package/dist/locale/el.min.mjs +3 -0
  197. package/dist/locale/el.min.mjs.map +1 -0
  198. package/dist/locale/el.mjs +186 -0
  199. package/dist/locale/en.js +193 -0
  200. package/dist/locale/en.min.js +3 -0
  201. package/dist/locale/en.min.js.map +1 -0
  202. package/dist/locale/en.min.mjs +3 -0
  203. package/dist/locale/en.min.mjs.map +1 -0
  204. package/dist/locale/en.mjs +186 -0
  205. package/dist/locale/eo.js +193 -0
  206. package/dist/locale/eo.min.js +3 -0
  207. package/dist/locale/eo.min.js.map +1 -0
  208. package/dist/locale/eo.min.mjs +3 -0
  209. package/dist/locale/eo.min.mjs.map +1 -0
  210. package/dist/locale/eo.mjs +186 -0
  211. package/dist/locale/es.js +193 -0
  212. package/dist/locale/es.min.js +3 -0
  213. package/dist/locale/es.min.js.map +1 -0
  214. package/dist/locale/es.min.mjs +3 -0
  215. package/dist/locale/es.min.mjs.map +1 -0
  216. package/dist/locale/es.mjs +186 -0
  217. package/dist/locale/et.js +193 -0
  218. package/dist/locale/et.min.js +3 -0
  219. package/dist/locale/et.min.js.map +1 -0
  220. package/dist/locale/et.min.mjs +3 -0
  221. package/dist/locale/et.min.mjs.map +1 -0
  222. package/dist/locale/et.mjs +186 -0
  223. package/dist/locale/eu.js +193 -0
  224. package/dist/locale/eu.min.js +3 -0
  225. package/dist/locale/eu.min.js.map +1 -0
  226. package/dist/locale/eu.min.mjs +3 -0
  227. package/dist/locale/eu.min.mjs.map +1 -0
  228. package/dist/locale/eu.mjs +186 -0
  229. package/dist/locale/fa.js +193 -0
  230. package/dist/locale/fa.min.js +3 -0
  231. package/dist/locale/fa.min.js.map +1 -0
  232. package/dist/locale/fa.min.mjs +3 -0
  233. package/dist/locale/fa.min.mjs.map +1 -0
  234. package/dist/locale/fa.mjs +186 -0
  235. package/dist/locale/fi.js +193 -0
  236. package/dist/locale/fi.min.js +3 -0
  237. package/dist/locale/fi.min.js.map +1 -0
  238. package/dist/locale/fi.min.mjs +3 -0
  239. package/dist/locale/fi.min.mjs.map +1 -0
  240. package/dist/locale/fi.mjs +186 -0
  241. package/dist/locale/fr.js +193 -0
  242. package/dist/locale/fr.min.js +3 -0
  243. package/dist/locale/fr.min.js.map +1 -0
  244. package/dist/locale/fr.min.mjs +3 -0
  245. package/dist/locale/fr.min.mjs.map +1 -0
  246. package/dist/locale/fr.mjs +186 -0
  247. package/dist/locale/he.js +193 -0
  248. package/dist/locale/he.min.js +3 -0
  249. package/dist/locale/he.min.js.map +1 -0
  250. package/dist/locale/he.min.mjs +3 -0
  251. package/dist/locale/he.min.mjs.map +1 -0
  252. package/dist/locale/he.mjs +186 -0
  253. package/dist/locale/hi.js +193 -0
  254. package/dist/locale/hi.min.js +3 -0
  255. package/dist/locale/hi.min.js.map +1 -0
  256. package/dist/locale/hi.min.mjs +3 -0
  257. package/dist/locale/hi.min.mjs.map +1 -0
  258. package/dist/locale/hi.mjs +186 -0
  259. package/dist/locale/hr.js +193 -0
  260. package/dist/locale/hr.min.js +3 -0
  261. package/dist/locale/hr.min.js.map +1 -0
  262. package/dist/locale/hr.min.mjs +3 -0
  263. package/dist/locale/hr.min.mjs.map +1 -0
  264. package/dist/locale/hr.mjs +186 -0
  265. package/dist/locale/hu.js +193 -0
  266. package/dist/locale/hu.min.js +3 -0
  267. package/dist/locale/hu.min.js.map +1 -0
  268. package/dist/locale/hu.min.mjs +3 -0
  269. package/dist/locale/hu.min.mjs.map +1 -0
  270. package/dist/locale/hu.mjs +186 -0
  271. package/dist/locale/hy-am.js +193 -0
  272. package/dist/locale/hy-am.min.js +3 -0
  273. package/dist/locale/hy-am.min.js.map +1 -0
  274. package/dist/locale/hy-am.min.mjs +3 -0
  275. package/dist/locale/hy-am.min.mjs.map +1 -0
  276. package/dist/locale/hy-am.mjs +186 -0
  277. package/dist/locale/id.js +193 -0
  278. package/dist/locale/id.min.js +3 -0
  279. package/dist/locale/id.min.js.map +1 -0
  280. package/dist/locale/id.min.mjs +3 -0
  281. package/dist/locale/id.min.mjs.map +1 -0
  282. package/dist/locale/id.mjs +186 -0
  283. package/dist/locale/it.js +193 -0
  284. package/dist/locale/it.min.js +3 -0
  285. package/dist/locale/it.min.js.map +1 -0
  286. package/dist/locale/it.min.mjs +3 -0
  287. package/dist/locale/it.min.mjs.map +1 -0
  288. package/dist/locale/it.mjs +186 -0
  289. package/dist/locale/ja.js +193 -0
  290. package/dist/locale/ja.min.js +3 -0
  291. package/dist/locale/ja.min.js.map +1 -0
  292. package/dist/locale/ja.min.mjs +3 -0
  293. package/dist/locale/ja.min.mjs.map +1 -0
  294. package/dist/locale/ja.mjs +186 -0
  295. package/dist/locale/kk.js +193 -0
  296. package/dist/locale/kk.min.js +3 -0
  297. package/dist/locale/kk.min.js.map +1 -0
  298. package/dist/locale/kk.min.mjs +3 -0
  299. package/dist/locale/kk.min.mjs.map +1 -0
  300. package/dist/locale/kk.mjs +186 -0
  301. package/dist/locale/km.js +193 -0
  302. package/dist/locale/km.min.js +3 -0
  303. package/dist/locale/km.min.js.map +1 -0
  304. package/dist/locale/km.min.mjs +3 -0
  305. package/dist/locale/km.min.mjs.map +1 -0
  306. package/dist/locale/km.mjs +186 -0
  307. package/dist/locale/ko.js +193 -0
  308. package/dist/locale/ko.min.js +3 -0
  309. package/dist/locale/ko.min.js.map +1 -0
  310. package/dist/locale/ko.min.mjs +3 -0
  311. package/dist/locale/ko.min.mjs.map +1 -0
  312. package/dist/locale/ko.mjs +186 -0
  313. package/dist/locale/ku.js +193 -0
  314. package/dist/locale/ku.min.js +3 -0
  315. package/dist/locale/ku.min.js.map +1 -0
  316. package/dist/locale/ku.min.mjs +3 -0
  317. package/dist/locale/ku.min.mjs.map +1 -0
  318. package/dist/locale/ku.mjs +186 -0
  319. package/dist/locale/ky.js +193 -0
  320. package/dist/locale/ky.min.js +3 -0
  321. package/dist/locale/ky.min.js.map +1 -0
  322. package/dist/locale/ky.min.mjs +3 -0
  323. package/dist/locale/ky.min.mjs.map +1 -0
  324. package/dist/locale/ky.mjs +186 -0
  325. package/dist/locale/lo.js +193 -0
  326. package/dist/locale/lo.min.js +3 -0
  327. package/dist/locale/lo.min.js.map +1 -0
  328. package/dist/locale/lo.min.mjs +3 -0
  329. package/dist/locale/lo.min.mjs.map +1 -0
  330. package/dist/locale/lo.mjs +186 -0
  331. package/dist/locale/lt.js +193 -0
  332. package/dist/locale/lt.min.js +3 -0
  333. package/dist/locale/lt.min.js.map +1 -0
  334. package/dist/locale/lt.min.mjs +3 -0
  335. package/dist/locale/lt.min.mjs.map +1 -0
  336. package/dist/locale/lt.mjs +186 -0
  337. package/dist/locale/lv.js +193 -0
  338. package/dist/locale/lv.min.js +3 -0
  339. package/dist/locale/lv.min.js.map +1 -0
  340. package/dist/locale/lv.min.mjs +3 -0
  341. package/dist/locale/lv.min.mjs.map +1 -0
  342. package/dist/locale/lv.mjs +186 -0
  343. package/dist/locale/mg.js +193 -0
  344. package/dist/locale/mg.min.js +3 -0
  345. package/dist/locale/mg.min.js.map +1 -0
  346. package/dist/locale/mg.min.mjs +3 -0
  347. package/dist/locale/mg.min.mjs.map +1 -0
  348. package/dist/locale/mg.mjs +186 -0
  349. package/dist/locale/mn.js +193 -0
  350. package/dist/locale/mn.min.js +3 -0
  351. package/dist/locale/mn.min.js.map +1 -0
  352. package/dist/locale/mn.min.mjs +3 -0
  353. package/dist/locale/mn.min.mjs.map +1 -0
  354. package/dist/locale/mn.mjs +186 -0
  355. package/dist/locale/ms.js +195 -0
  356. package/dist/locale/ms.min.js +3 -0
  357. package/dist/locale/ms.min.js.map +1 -0
  358. package/dist/locale/ms.min.mjs +3 -0
  359. package/dist/locale/ms.min.mjs.map +1 -0
  360. package/dist/locale/ms.mjs +188 -0
  361. package/dist/locale/my.js +193 -0
  362. package/dist/locale/my.min.js +3 -0
  363. package/dist/locale/my.min.js.map +1 -0
  364. package/dist/locale/my.min.mjs +3 -0
  365. package/dist/locale/my.min.mjs.map +1 -0
  366. package/dist/locale/my.mjs +186 -0
  367. package/dist/locale/nb-no.js +193 -0
  368. package/dist/locale/nb-no.min.js +3 -0
  369. package/dist/locale/nb-no.min.js.map +1 -0
  370. package/dist/locale/nb-no.min.mjs +3 -0
  371. package/dist/locale/nb-no.min.mjs.map +1 -0
  372. package/dist/locale/nb-no.mjs +186 -0
  373. package/dist/locale/nl.js +193 -0
  374. package/dist/locale/nl.min.js +3 -0
  375. package/dist/locale/nl.min.js.map +1 -0
  376. package/dist/locale/nl.min.mjs +3 -0
  377. package/dist/locale/nl.min.mjs.map +1 -0
  378. package/dist/locale/nl.mjs +186 -0
  379. package/dist/locale/no.js +193 -0
  380. package/dist/locale/no.min.js +3 -0
  381. package/dist/locale/no.min.js.map +1 -0
  382. package/dist/locale/no.min.mjs +3 -0
  383. package/dist/locale/no.min.mjs.map +1 -0
  384. package/dist/locale/no.mjs +186 -0
  385. package/dist/locale/pa.js +193 -0
  386. package/dist/locale/pa.min.js +3 -0
  387. package/dist/locale/pa.min.js.map +1 -0
  388. package/dist/locale/pa.min.mjs +3 -0
  389. package/dist/locale/pa.min.mjs.map +1 -0
  390. package/dist/locale/pa.mjs +186 -0
  391. package/dist/locale/pl.js +193 -0
  392. package/dist/locale/pl.min.js +3 -0
  393. package/dist/locale/pl.min.js.map +1 -0
  394. package/dist/locale/pl.min.mjs +3 -0
  395. package/dist/locale/pl.min.mjs.map +1 -0
  396. package/dist/locale/pl.mjs +186 -0
  397. package/dist/locale/pt-br.js +193 -0
  398. package/dist/locale/pt-br.min.js +3 -0
  399. package/dist/locale/pt-br.min.js.map +1 -0
  400. package/dist/locale/pt-br.min.mjs +3 -0
  401. package/dist/locale/pt-br.min.mjs.map +1 -0
  402. package/dist/locale/pt-br.mjs +186 -0
  403. package/dist/locale/pt.js +193 -0
  404. package/dist/locale/pt.min.js +3 -0
  405. package/dist/locale/pt.min.js.map +1 -0
  406. package/dist/locale/pt.min.mjs +3 -0
  407. package/dist/locale/pt.min.mjs.map +1 -0
  408. package/dist/locale/pt.mjs +186 -0
  409. package/dist/locale/ro.js +193 -0
  410. package/dist/locale/ro.min.js +3 -0
  411. package/dist/locale/ro.min.js.map +1 -0
  412. package/dist/locale/ro.min.mjs +3 -0
  413. package/dist/locale/ro.min.mjs.map +1 -0
  414. package/dist/locale/ro.mjs +186 -0
  415. package/dist/locale/ru.js +193 -0
  416. package/dist/locale/ru.min.js +3 -0
  417. package/dist/locale/ru.min.js.map +1 -0
  418. package/dist/locale/ru.min.mjs +3 -0
  419. package/dist/locale/ru.min.mjs.map +1 -0
  420. package/dist/locale/ru.mjs +186 -0
  421. package/dist/locale/sk.js +195 -0
  422. package/dist/locale/sk.min.js +3 -0
  423. package/dist/locale/sk.min.js.map +1 -0
  424. package/dist/locale/sk.min.mjs +3 -0
  425. package/dist/locale/sk.min.mjs.map +1 -0
  426. package/dist/locale/sk.mjs +188 -0
  427. package/dist/locale/sl.js +193 -0
  428. package/dist/locale/sl.min.js +3 -0
  429. package/dist/locale/sl.min.js.map +1 -0
  430. package/dist/locale/sl.min.mjs +3 -0
  431. package/dist/locale/sl.min.mjs.map +1 -0
  432. package/dist/locale/sl.mjs +186 -0
  433. package/dist/locale/sr.js +193 -0
  434. package/dist/locale/sr.min.js +3 -0
  435. package/dist/locale/sr.min.js.map +1 -0
  436. package/dist/locale/sr.min.mjs +3 -0
  437. package/dist/locale/sr.min.mjs.map +1 -0
  438. package/dist/locale/sr.mjs +186 -0
  439. package/dist/locale/sv.js +193 -0
  440. package/dist/locale/sv.min.js +3 -0
  441. package/dist/locale/sv.min.js.map +1 -0
  442. package/dist/locale/sv.min.mjs +3 -0
  443. package/dist/locale/sv.min.mjs.map +1 -0
  444. package/dist/locale/sv.mjs +186 -0
  445. package/dist/locale/sw.js +193 -0
  446. package/dist/locale/sw.min.js +3 -0
  447. package/dist/locale/sw.min.js.map +1 -0
  448. package/dist/locale/sw.min.mjs +3 -0
  449. package/dist/locale/sw.min.mjs.map +1 -0
  450. package/dist/locale/sw.mjs +186 -0
  451. package/dist/locale/ta.js +193 -0
  452. package/dist/locale/ta.min.js +3 -0
  453. package/dist/locale/ta.min.js.map +1 -0
  454. package/dist/locale/ta.min.mjs +3 -0
  455. package/dist/locale/ta.min.mjs.map +1 -0
  456. package/dist/locale/ta.mjs +186 -0
  457. package/dist/locale/te.js +193 -0
  458. package/dist/locale/te.min.js +3 -0
  459. package/dist/locale/te.min.js.map +1 -0
  460. package/dist/locale/te.min.mjs +3 -0
  461. package/dist/locale/te.min.mjs.map +1 -0
  462. package/dist/locale/te.mjs +186 -0
  463. package/dist/locale/th.js +193 -0
  464. package/dist/locale/th.min.js +3 -0
  465. package/dist/locale/th.min.js.map +1 -0
  466. package/dist/locale/th.min.mjs +3 -0
  467. package/dist/locale/th.min.mjs.map +1 -0
  468. package/dist/locale/th.mjs +186 -0
  469. package/dist/locale/tk.js +193 -0
  470. package/dist/locale/tk.min.js +3 -0
  471. package/dist/locale/tk.min.js.map +1 -0
  472. package/dist/locale/tk.min.mjs +3 -0
  473. package/dist/locale/tk.min.mjs.map +1 -0
  474. package/dist/locale/tk.mjs +186 -0
  475. package/dist/locale/tr.js +193 -0
  476. package/dist/locale/tr.min.js +3 -0
  477. package/dist/locale/tr.min.js.map +1 -0
  478. package/dist/locale/tr.min.mjs +3 -0
  479. package/dist/locale/tr.min.mjs.map +1 -0
  480. package/dist/locale/tr.mjs +186 -0
  481. package/dist/locale/ug-cn.js +193 -0
  482. package/dist/locale/ug-cn.min.js +3 -0
  483. package/dist/locale/ug-cn.min.js.map +1 -0
  484. package/dist/locale/ug-cn.min.mjs +3 -0
  485. package/dist/locale/ug-cn.min.mjs.map +1 -0
  486. package/dist/locale/ug-cn.mjs +186 -0
  487. package/dist/locale/uk.js +193 -0
  488. package/dist/locale/uk.min.js +3 -0
  489. package/dist/locale/uk.min.js.map +1 -0
  490. package/dist/locale/uk.min.mjs +3 -0
  491. package/dist/locale/uk.min.mjs.map +1 -0
  492. package/dist/locale/uk.mjs +186 -0
  493. package/dist/locale/uz-uz.js +193 -0
  494. package/dist/locale/uz-uz.min.js +3 -0
  495. package/dist/locale/uz-uz.min.js.map +1 -0
  496. package/dist/locale/uz-uz.min.mjs +3 -0
  497. package/dist/locale/uz-uz.min.mjs.map +1 -0
  498. package/dist/locale/uz-uz.mjs +186 -0
  499. package/dist/locale/vi.js +193 -0
  500. package/dist/locale/vi.min.js +3 -0
  501. package/dist/locale/vi.min.js.map +1 -0
  502. package/dist/locale/vi.min.mjs +3 -0
  503. package/dist/locale/vi.min.mjs.map +1 -0
  504. package/dist/locale/vi.mjs +186 -0
  505. package/dist/locale/zh-cn.js +193 -0
  506. package/dist/locale/zh-cn.min.js +3 -0
  507. package/dist/locale/zh-cn.min.js.map +1 -0
  508. package/dist/locale/zh-cn.min.mjs +3 -0
  509. package/dist/locale/zh-cn.min.mjs.map +1 -0
  510. package/dist/locale/zh-cn.mjs +186 -0
  511. package/dist/locale/zh-hk.js +193 -0
  512. package/dist/locale/zh-hk.min.js +3 -0
  513. package/dist/locale/zh-hk.min.js.map +1 -0
  514. package/dist/locale/zh-hk.min.mjs +3 -0
  515. package/dist/locale/zh-hk.min.mjs.map +1 -0
  516. package/dist/locale/zh-hk.mjs +186 -0
  517. package/dist/locale/zh-mo.js +193 -0
  518. package/dist/locale/zh-mo.min.js +3 -0
  519. package/dist/locale/zh-mo.min.js.map +1 -0
  520. package/dist/locale/zh-mo.min.mjs +3 -0
  521. package/dist/locale/zh-mo.min.mjs.map +1 -0
  522. package/dist/locale/zh-mo.mjs +186 -0
  523. package/dist/locale/zh-tw.js +193 -0
  524. package/dist/locale/zh-tw.min.js +3 -0
  525. package/dist/locale/zh-tw.min.js.map +1 -0
  526. package/dist/locale/zh-tw.min.mjs +3 -0
  527. package/dist/locale/zh-tw.min.mjs.map +1 -0
  528. package/dist/locale/zh-tw.mjs +186 -0
  529. package/dist/style.css +1 -1
  530. package/dist/test/demo.docx +0 -0
  531. package/dist/test/demo.et +0 -0
  532. package/dist/test/demo.ofd +0 -0
  533. package/dist/test/demo.pdf +0 -0
  534. package/dist/test/test.ofd +0 -0
  535. package/dist/test/unzip.ofd +0 -0
  536. package/dist/test/zip.ofd +0 -0
  537. package/dist/types/auto-imports.d.ts +9 -0
  538. package/dist/types/components.d.ts +55 -0
  539. package/dist/zhui-plus.cjs.js +1 -0
  540. package/dist/zhui-plus.es.js +2 -0
  541. package/dist/zhui.svg +1 -0
  542. package/package.json +90 -4
  543. package/packages/components/AI/index.ts +10 -0
  544. package/packages/components/AI/src/zh-aiChat.vue +841 -0
  545. package/packages/components/badge/__tests__/badge.test.ts +38 -0
  546. package/packages/components/badge/index.ts +10 -0
  547. package/packages/components/badge/src/zh-badge.vue +86 -0
  548. package/packages/components/badge/style.scss +1 -0
  549. package/packages/components/button/__tests__/button.test.ts +94 -0
  550. package/packages/components/button/__tests__/buttonGroup.test.ts +46 -0
  551. package/packages/components/button/index.ts +11 -0
  552. package/packages/components/button/src/zh-button-group.vue +50 -0
  553. package/packages/components/button/src/zh-button.vue +152 -0
  554. package/packages/components/button/style/index.css +140 -0
  555. package/packages/components/charts/geo.json +11147 -0
  556. package/packages/components/charts/index.ts +35 -0
  557. package/packages/components/charts/src/zh-barChart.vue +97 -0
  558. package/packages/components/charts/src/zh-baseChart.vue +196 -0
  559. package/packages/components/charts/src/zh-lineBarChart.vue +113 -0
  560. package/packages/components/charts/src/zh-lineChart.vue +93 -0
  561. package/packages/components/charts/src/zh-mapChart.vue +214 -0
  562. package/packages/components/charts/src/zh-pictorialBar.vue +72 -0
  563. package/packages/components/charts/src/zh-pieChart.vue +67 -0
  564. package/packages/components/charts/src/zh-radarChart.vue +131 -0
  565. package/packages/components/charts/src/zh-scatterChart.vue +152 -0
  566. package/packages/components/chat/index.ts +10 -0
  567. package/packages/components/chat/src/zh-chat.vue +889 -0
  568. package/packages/components/container/index.ts +18 -0
  569. package/packages/components/container/src/zh-aside.vue +34 -0
  570. package/packages/components/container/src/zh-container.vue +45 -0
  571. package/packages/components/container/src/zh-footer.vue +33 -0
  572. package/packages/components/container/src/zh-header.vue +34 -0
  573. package/packages/components/container/src/zh-main.vue +26 -0
  574. package/packages/components/directive/focus.ts +14 -0
  575. package/packages/components/directive/idCard.ts +12 -0
  576. package/packages/components/directive/index.ts +19 -0
  577. package/packages/components/directive/number.ts +10 -0
  578. package/packages/components/directive/permission.ts +57 -0
  579. package/packages/components/directive/phone.ts +12 -0
  580. package/packages/components/drawer/index.ts +10 -0
  581. package/packages/components/drawer/src/zh-drawer.vue +78 -0
  582. package/packages/components/drawer/style/animation.scss +35 -0
  583. package/packages/components/drawer/style/index.scss +52 -0
  584. package/packages/components/drawer/style/media.scss +6 -0
  585. package/packages/components/fileViewer/index.ts +9 -0
  586. package/packages/components/fileViewer/src/liteofd/annotLayer.ts +203 -0
  587. package/packages/components/fileViewer/src/liteofd/asn1js/LICENSE +15 -0
  588. package/packages/components/fileViewer/src/liteofd/asn1js/README.md +108 -0
  589. package/packages/components/fileViewer/src/liteofd/asn1js/asn1.js +627 -0
  590. package/packages/components/fileViewer/src/liteofd/asn1js/base64.js +103 -0
  591. package/packages/components/fileViewer/src/liteofd/asn1js/defs.js +138 -0
  592. package/packages/components/fileViewer/src/liteofd/asn1js/dumpASN1.js +79 -0
  593. package/packages/components/fileViewer/src/liteofd/asn1js/hex.js +69 -0
  594. package/packages/components/fileViewer/src/liteofd/asn1js/int10.js +106 -0
  595. package/packages/components/fileViewer/src/liteofd/asn1js/oids.js +2725 -0
  596. package/packages/components/fileViewer/src/liteofd/asn1js/rfcdef.js +10377 -0
  597. package/packages/components/fileViewer/src/liteofd/attrType.ts +173 -0
  598. package/packages/components/fileViewer/src/liteofd/contentLayer.ts +203 -0
  599. package/packages/components/fileViewer/src/liteofd/elements/AnnotationPathSvg.ts +122 -0
  600. package/packages/components/fileViewer/src/liteofd/elements/BaseSvg.ts +6 -0
  601. package/packages/components/fileViewer/src/liteofd/elements/ImageSvg.ts +212 -0
  602. package/packages/components/fileViewer/src/liteofd/elements/PathSvg.ts +460 -0
  603. package/packages/components/fileViewer/src/liteofd/elements/SignatureElement.ts +231 -0
  604. package/packages/components/fileViewer/src/liteofd/elements/TextSvg.ts +235 -0
  605. package/packages/components/fileViewer/src/liteofd/elements/ofdAnnotationElement.ts +133 -0
  606. package/packages/components/fileViewer/src/liteofd/elements/ofdPageContainer.ts +183 -0
  607. package/packages/components/fileViewer/src/liteofd/elements/ofdPageRender.ts +71 -0
  608. package/packages/components/fileViewer/src/liteofd/elements/signObject.json +10084 -0
  609. package/packages/components/fileViewer/src/liteofd/elements/signature.json +381 -0
  610. package/packages/components/fileViewer/src/liteofd/font/arithmetic_decoder.js +182 -0
  611. package/packages/components/fileViewer/src/liteofd/font/ascii_85_stream.js +98 -0
  612. package/packages/components/fileViewer/src/liteofd/font/ascii_hex_stream.js +79 -0
  613. package/packages/components/fileViewer/src/liteofd/font/base_stream.js +110 -0
  614. package/packages/components/fileViewer/src/liteofd/font/bidi.js +440 -0
  615. package/packages/components/fileViewer/src/liteofd/font/binary_cmap.js +326 -0
  616. package/packages/components/fileViewer/src/liteofd/font/calibri_factors.js +309 -0
  617. package/packages/components/fileViewer/src/liteofd/font/ccitt.js +1059 -0
  618. package/packages/components/fileViewer/src/liteofd/font/ccitt_stream.js +60 -0
  619. package/packages/components/fileViewer/src/liteofd/font/cff_font.js +139 -0
  620. package/packages/components/fileViewer/src/liteofd/font/cff_parser.js +1940 -0
  621. package/packages/components/fileViewer/src/liteofd/font/charsets.js +119 -0
  622. package/packages/components/fileViewer/src/liteofd/font/chunked_stream.js +94 -0
  623. package/packages/components/fileViewer/src/liteofd/font/cmap.js +726 -0
  624. package/packages/components/fileViewer/src/liteofd/font/colorspace.js +1336 -0
  625. package/packages/components/fileViewer/src/liteofd/font/core_utils.js +636 -0
  626. package/packages/components/fileViewer/src/liteofd/font/decode_stream.js +177 -0
  627. package/packages/components/fileViewer/src/liteofd/font/differences.js +906 -0
  628. package/packages/components/fileViewer/src/liteofd/font/encodings.js +301 -0
  629. package/packages/components/fileViewer/src/liteofd/font/flate_stream.js +413 -0
  630. package/packages/components/fileViewer/src/liteofd/font/font_loader.js +455 -0
  631. package/packages/components/fileViewer/src/liteofd/font/font_renderer.js +900 -0
  632. package/packages/components/fileViewer/src/liteofd/font/font_substitutions.js +553 -0
  633. package/packages/components/fileViewer/src/liteofd/font/fonts copy.js +3391 -0
  634. package/packages/components/fileViewer/src/liteofd/font/fonts.js +3585 -0
  635. package/packages/components/fileViewer/src/liteofd/font/fonts_utils.js +178 -0
  636. package/packages/components/fileViewer/src/liteofd/font/function.js +1241 -0
  637. package/packages/components/fileViewer/src/liteofd/font/glyf.js +701 -0
  638. package/packages/components/fileViewer/src/liteofd/font/glyphlist.js +4557 -0
  639. package/packages/components/fileViewer/src/liteofd/font/helvetica_factors.js +352 -0
  640. package/packages/components/fileViewer/src/liteofd/font/image.js +986 -0
  641. package/packages/components/fileViewer/src/liteofd/font/image_resizer.js +398 -0
  642. package/packages/components/fileViewer/src/liteofd/font/image_utils.js +286 -0
  643. package/packages/components/fileViewer/src/liteofd/font/jbig2_stream.js +74 -0
  644. package/packages/components/fileViewer/src/liteofd/font/jpeg_stream.js +106 -0
  645. package/packages/components/fileViewer/src/liteofd/font/jpg.js +1590 -0
  646. package/packages/components/fileViewer/src/liteofd/font/jpx.js +2349 -0
  647. package/packages/components/fileViewer/src/liteofd/font/jpx_stream.js +87 -0
  648. package/packages/components/fileViewer/src/liteofd/font/liberationsans_widths.js +429 -0
  649. package/packages/components/fileViewer/src/liteofd/font/lzw_stream.js +150 -0
  650. package/packages/components/fileViewer/src/liteofd/font/metrics.d.ts +1 -0
  651. package/packages/components/fileViewer/src/liteofd/font/metrics.js +3057 -0
  652. package/packages/components/fileViewer/src/liteofd/font/murmurhash3.js +135 -0
  653. package/packages/components/fileViewer/src/liteofd/font/myriadpro_factors.js +291 -0
  654. package/packages/components/fileViewer/src/liteofd/font/ofd_stream.js +402 -0
  655. package/packages/components/fileViewer/src/liteofd/font/opentype_file_builder.js +154 -0
  656. package/packages/components/fileViewer/src/liteofd/font/parser.js +1409 -0
  657. package/packages/components/fileViewer/src/liteofd/font/pattern.js +1005 -0
  658. package/packages/components/fileViewer/src/liteofd/font/predictor_stream.js +234 -0
  659. package/packages/components/fileViewer/src/liteofd/font/primitives.js +354 -0
  660. package/packages/components/fileViewer/src/liteofd/font/properties.json +2110 -0
  661. package/packages/components/fileViewer/src/liteofd/font/ps_parser.js +268 -0
  662. package/packages/components/fileViewer/src/liteofd/font/run_length_stream.js +61 -0
  663. package/packages/components/fileViewer/src/liteofd/font/segoeui_factors.js +308 -0
  664. package/packages/components/fileViewer/src/liteofd/font/standard_fonts.js +915 -0
  665. package/packages/components/fileViewer/src/liteofd/font/stream.js +99 -0
  666. package/packages/components/fileViewer/src/liteofd/font/to_unicode_map.js +111 -0
  667. package/packages/components/fileViewer/src/liteofd/font/translatedFont.js +3125 -0
  668. package/packages/components/fileViewer/src/liteofd/font/type1_font.js +443 -0
  669. package/packages/components/fileViewer/src/liteofd/font/type1_parser.js +804 -0
  670. package/packages/components/fileViewer/src/liteofd/font/unicode.js +274 -0
  671. package/packages/components/fileViewer/src/liteofd/font/util.js +1159 -0
  672. package/packages/components/fileViewer/src/liteofd/font/xfa_fonts.js +296 -0
  673. package/packages/components/fileViewer/src/liteofd/jbig2/arithmetic_decoder.js +183 -0
  674. package/packages/components/fileViewer/src/liteofd/jbig2/ccitt.js +1070 -0
  675. package/packages/components/fileViewer/src/liteofd/jbig2/core_utils.js +180 -0
  676. package/packages/components/fileViewer/src/liteofd/jbig2/is_node.js +27 -0
  677. package/packages/components/fileViewer/src/liteofd/jbig2/jbig2.js +2589 -0
  678. package/packages/components/fileViewer/src/liteofd/jbig2/jbig2_stream.js +81 -0
  679. package/packages/components/fileViewer/src/liteofd/jbig2/primitives.js +371 -0
  680. package/packages/components/fileViewer/src/liteofd/jbig2/stream.js +1348 -0
  681. package/packages/components/fileViewer/src/liteofd/jbig2/util.js +970 -0
  682. package/packages/components/fileViewer/src/liteofd/layer.ts +12 -0
  683. package/packages/components/fileViewer/src/liteofd/liteOfd.ts +185 -0
  684. package/packages/components/fileViewer/src/liteofd/ofdActions.ts +29 -0
  685. package/packages/components/fileViewer/src/liteofd/ofdCanvas.ts +19 -0
  686. package/packages/components/fileViewer/src/liteofd/ofdData.ts +28 -0
  687. package/packages/components/fileViewer/src/liteofd/ofdDocument.ts +109 -0
  688. package/packages/components/fileViewer/src/liteofd/ofdFont.ts +425 -0
  689. package/packages/components/fileViewer/src/liteofd/ofdRender.ts +259 -0
  690. package/packages/components/fileViewer/src/liteofd/ofdWriter.ts +142 -0
  691. package/packages/components/fileViewer/src/liteofd/ofdtools.ts +43 -0
  692. package/packages/components/fileViewer/src/liteofd/parser.ts +499 -0
  693. package/packages/components/fileViewer/src/liteofd/promiseCapability.ts +47 -0
  694. package/packages/components/fileViewer/src/liteofd/utils/commonFont.ts +15 -0
  695. package/packages/components/fileViewer/src/liteofd/utils/elementUtils.ts +362 -0
  696. package/packages/components/fileViewer/src/liteofd/utils/jsonToXml.ts +95 -0
  697. package/packages/components/fileViewer/src/liteofd/utils/ofdUtils.ts +301 -0
  698. package/packages/components/fileViewer/src/liteofd/utils/signatureUtil.ts +246 -0
  699. package/packages/components/fileViewer/src/liteofd/utils/sm3.ts +235 -0
  700. package/packages/components/fileViewer/src/liteofd/utils/utils.ts +489 -0
  701. package/packages/components/fileViewer/src/liteofd/utils/verify_signature_util.ts +41 -0
  702. package/packages/components/fileViewer/src/ofd/CircleLoading.vue +64 -0
  703. package/packages/components/fileViewer/src/ofd/OfdPreview.vue +456 -0
  704. package/packages/components/fileViewer/src/ofd/OfdViewer.vue +211 -0
  705. package/packages/components/fileViewer/src/ofd/PageIndicator.vue +88 -0
  706. package/packages/components/fileViewer/src/ofd/RatioIndicator.vue +271 -0
  707. package/packages/components/fileViewer/src/ofd/ToolTip.vue +81 -0
  708. package/packages/components/fileViewer/src/zh-fileViewer.vue +426 -0
  709. package/packages/components/form/index.ts +11 -0
  710. package/packages/components/form/src/zh-form-item.vue +299 -0
  711. package/packages/components/form/src/zh-form.vue +90 -0
  712. package/packages/components/hideNumber/index.ts +9 -0
  713. package/packages/components/hideNumber/src/zh-hide-number.vue +37 -0
  714. package/packages/components/icon/index.ts +10 -0
  715. package/packages/components/icon/src/zh-icon.vue +32 -0
  716. package/packages/components/image/index.ts +9 -0
  717. package/packages/components/image/src/zh-image.vue +245 -0
  718. package/packages/components/index.ts +112 -0
  719. package/packages/components/input/index.ts +10 -0
  720. package/packages/components/input/src/input.com.ts +30 -0
  721. package/packages/components/input/src/input.type.ts +1 -0
  722. package/packages/components/input/src/zh-input.vue +92 -0
  723. package/packages/components/input/style/index.scss +30 -0
  724. package/packages/components/layout/index.ts +12 -0
  725. package/packages/components/layout/src/zh-col.tsx +81 -0
  726. package/packages/components/layout/src/zh-row.tsx +58 -0
  727. package/packages/components/layout/style/row.scss +6 -0
  728. package/packages/components/map/index.ts +18 -0
  729. package/packages/components/map/src/zh-amap.vue +999 -0
  730. package/packages/components/map/src/zh-bmap.vue +1578 -0
  731. package/packages/components/map/src/zh-omap.vue +1522 -0
  732. package/packages/components/map/src/zh-smap.vue +1555 -0
  733. package/packages/components/map/src/zh-tmap.vue +1058 -0
  734. package/packages/components/message/index.ts +8 -0
  735. package/packages/components/message/src/data.com.ts +61 -0
  736. package/packages/components/message/src/message-icon.vue +60 -0
  737. package/packages/components/message/src/message.ts +89 -0
  738. package/packages/components/message/src/message.type.ts +40 -0
  739. package/packages/components/message/src/zh-message.vue +133 -0
  740. package/packages/components/message-box/index.ts +12 -0
  741. package/packages/components/message-box/src/messageBox.help.ts +40 -0
  742. package/packages/components/message-box/src/messageBox.ts +126 -0
  743. package/packages/components/message-box/src/zh-message-box.vue +94 -0
  744. package/packages/components/message-box/style/index.css +29 -0
  745. package/packages/components/noData/index.ts +9 -0
  746. package/packages/components/noData/src/zh-no-data.vue +42 -0
  747. package/packages/components/operationColumn/index.ts +9 -0
  748. package/packages/components/operationColumn/src/zh-operationColumn.vue +113 -0
  749. package/packages/components/provider/index.ts +11 -0
  750. package/packages/components/provider/src/zh-authControl.vue +28 -0
  751. package/packages/components/provider/src/zh-authProvider.vue +36 -0
  752. package/packages/components/qrcode/index.ts +9 -0
  753. package/packages/components/qrcode/src/zh-qrcode.vue +271 -0
  754. package/packages/components/radio/index.ts +10 -0
  755. package/packages/components/radio/src/zh-radio.vue +86 -0
  756. package/packages/components/searchForm/index.ts +9 -0
  757. package/packages/components/searchForm/src/zh-search-form.vue +340 -0
  758. package/packages/components/signature/index.ts +10 -0
  759. package/packages/components/signature/src/zh-signature.vue +355 -0
  760. package/packages/components/switch/index.ts +10 -0
  761. package/packages/components/switch/src/zh-switch.vue +162 -0
  762. package/packages/components/table/index.ts +10 -0
  763. package/packages/components/table/src/types.ts +62 -0
  764. package/packages/components/table/src/zh-table.vue +220 -0
  765. package/packages/components/upload/index.ts +15 -0
  766. package/packages/components/upload/src/zh-cupload.vue +147 -0
  767. package/packages/components/upload/src/zh-upload.vue +258 -0
  768. package/packages/components/upload/src/zh-uploadCard.vue +176 -0
  769. package/packages/components/upload/src/zh-uploadDialog.vue +165 -0
  770. package/packages/components/videoPlayer/index.ts +12 -0
  771. package/packages/components/videoPlayer/src/PlayerManager.js +706 -0
  772. package/packages/components/videoPlayer/src/api.js +354 -0
  773. package/packages/components/videoPlayer/src/errorHandler.ts +39 -0
  774. package/packages/components/videoPlayer/src/resourceLoader.ts +68 -0
  775. package/packages/components/videoPlayer/src/useDahuaPlayer.ts +242 -0
  776. package/packages/components/videoPlayer/src/zh-dhPlayer.vue +119 -0
  777. package/packages/components/videoPlayer/src/zh-hlsPlayer.vue +575 -0
  778. package/packages/resolver/index.ts +324 -0
  779. package/packages/styles/_element.scss +324 -0
  780. package/packages/styles/_variable.scss +136 -0
  781. package/packages/styles/index.scss +3 -0
  782. package/packages/tokens/tokens.ts +2 -0
  783. package/packages/types/form.ts +205 -0
  784. package/packages/types/index.ts +4 -0
  785. package/packages/types/player.ts +80 -0
  786. package/packages/types/provider.ts +4 -0
  787. package/packages/types/searchForm.ts +24 -0
  788. package/packages/utils/common/__tests__/common.test.ts +12 -0
  789. package/packages/utils/common/common.ts +68 -0
  790. package/packages/utils/constant.ts +12 -0
  791. package/packages/utils/copy.ts +20 -0
  792. package/packages/utils/data.ts +62 -0
  793. package/packages/utils/echarts/echarts.ts +34 -0
  794. package/packages/utils/event.ts +37 -0
  795. package/packages/utils/hooks/__tests__/hooks.test.ts +24 -0
  796. package/packages/utils/hooks/data.ts +100 -0
  797. package/packages/utils/hooks/hooks.util.ts +39 -0
  798. package/packages/utils/hooks/index.ts +1 -0
  799. package/packages/utils/hooks/useBreakpoint.ts +89 -0
  800. package/packages/utils/hooks/useEcharts.ts +56 -0
  801. package/packages/utils/hooks/useEventListener.ts +57 -0
  802. package/packages/utils/hooks/useLegendProcessor.ts +92 -0
  803. package/packages/utils/hooks/usePermission.ts +22 -0
  804. package/packages/utils/hooks/useTimeout.ts +45 -0
  805. package/packages/utils/is.ts +79 -0
  806. package/packages/utils/utils.ts +136 -0
  807. package/packages/utils/vue/util-modal.vue +61 -0
  808. package/types/auto-imports.d.ts +9 -0
  809. package/types/component.d.ts +6 -0
  810. package/types/components.d.ts +131 -0
  811. package/types/defaults.d.ts +5 -0
  812. package/types/el-components.d.ts +23 -0
  813. package/types/global.d.ts +130 -0
  814. package/types/index.d.ts +11 -0
  815. package/types/zh-components.d.ts +23 -0
  816. package/types/zhui.d.ts +76 -0
  817. package/.idea/workspace.xml +0 -72
  818. package/README.md +0 -1
  819. package/dist/zh-ui.es.js +0 -56706
  820. package/dist/zh-ui.umd.js +0 -67
@@ -0,0 +1,3125 @@
1
+ // 转换后的字体数据
2
+ import { CMapCompressionType, FormatError, OPS, shadow, Util, warn, PromiseCapability, assert, AbortException, FONT_IDENTITY_MATRIX, stringToPDFString, TextRenderingMode } from "./util.js"
3
+ import { ImageResizer } from "./image_resizer.js"
4
+ import { LocalColorSpaceCache, LocalGStateCache, LocalImageCache, LocalTilingPatternCache, RegionalImageCache } from "./image_utils.js"
5
+ import { isPDFFunction, PDFFunctionFactory } from "./function.js"
6
+ import { Dict, isName, Name, Ref, RefSet } from "./primitives.js"
7
+ import { getFontNameToFileMap, getSerifFonts, getStandardFontName, getStdFontMap, getSymbolsFonts, isKnownFontName } from "./standard_fonts.js"
8
+ import { NullStream, Stream } from "./stream.js"
9
+ import { ColorSpace } from "./colorspace.js"
10
+ import { DecodeStream } from "./decode_stream.js"
11
+ import { BaseStream } from "./base_stream.js"
12
+ import { ErrorFont, Font } from "./fonts.js"
13
+ import { getTilingPatternIR, Pattern } from "./pattern.js"
14
+ import { FontFlags } from "./fonts_utils.js"
15
+ import { getFontSubstitution } from "./font_substitutions.js"
16
+ import { getXfaFontName, getXfaFontDict } from "./xfa_fonts.js"
17
+ import { CMapFactory, IdentityCMap } from "./cmap.js"
18
+ import { bidi } from "./bidi.js"
19
+ import { getEncoding, MacRomanEncoding, StandardEncoding, SymbolSetEncoding, WinAnsiEncoding, ZapfDingbatsEncoding } from "./encodings.js"
20
+ import { getGlyphsUnicode } from "./glyphlist.js"
21
+ import { getUnicodeForGlyph } from "./unicode.js"
22
+ import { IdentityToUnicodeMap, ToUnicodeMap } from "./to_unicode_map.js"
23
+ import { getMetrics } from "./metrics.js"
24
+ import { MurmurHash3_64 } from "./murmurhash3.js"
25
+ import { PDFImage } from "./image.js"
26
+
27
+ const PatternType = {
28
+ TILING: 1,
29
+ SHADING: 2,
30
+ };
31
+
32
+ const deferred = Promise.resolve();
33
+
34
+ const DefaultPartialEvaluatorOptions = Object.freeze({
35
+ maxImageSize: -1,
36
+ disableFontFace: false,
37
+ ignoreErrors: false,
38
+ isEvalSupported: true,
39
+ isOffscreenCanvasSupported: false,
40
+ canvasMaxAreaInBytes: -1,
41
+ fontExtraProperties: false,
42
+ useSystemFonts: true,
43
+ cMapUrl: null,
44
+ standardFontDataUrl: null
45
+ })
46
+
47
+
48
+ // Convert PDF blend mode names to HTML5 blend mode names.
49
+ function normalizeBlendMode(value, parsingArray = false) {
50
+ if (Array.isArray(value)) {
51
+ // Use the first *supported* BM value in the Array (fixes issue11279.pdf).
52
+ for (const val of value) {
53
+ const maybeBM = normalizeBlendMode(val, /* parsingArray = */ true);
54
+ if (maybeBM) {
55
+ return maybeBM;
56
+ }
57
+ }
58
+ warn(`Unsupported blend mode Array: ${value}`);
59
+ return "source-over";
60
+ }
61
+
62
+ if (!(value instanceof Name)) {
63
+ if (parsingArray) {
64
+ return null;
65
+ }
66
+ return "source-over";
67
+ }
68
+ switch (value.name) {
69
+ case "Normal":
70
+ case "Compatible":
71
+ return "source-over";
72
+ case "Multiply":
73
+ return "multiply";
74
+ case "Screen":
75
+ return "screen";
76
+ case "Overlay":
77
+ return "overlay";
78
+ case "Darken":
79
+ return "darken";
80
+ case "Lighten":
81
+ return "lighten";
82
+ case "ColorDodge":
83
+ return "color-dodge";
84
+ case "ColorBurn":
85
+ return "color-burn";
86
+ case "HardLight":
87
+ return "hard-light";
88
+ case "SoftLight":
89
+ return "soft-light";
90
+ case "Difference":
91
+ return "difference";
92
+ case "Exclusion":
93
+ return "exclusion";
94
+ case "Hue":
95
+ return "hue";
96
+ case "Saturation":
97
+ return "saturation";
98
+ case "Color":
99
+ return "color";
100
+ case "Luminosity":
101
+ return "luminosity";
102
+ }
103
+ if (parsingArray) {
104
+ return null;
105
+ }
106
+ warn(`Unsupported blend mode: ${value.name}`);
107
+ return "source-over";
108
+ }
109
+
110
+ class PartialEvaluator {
111
+ constructor( { xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, standardFontDataCache, globalImageCache, systemFontCache, options = null } ) {
112
+ this.xref = xref
113
+ this.handler = handler
114
+ this.pageIndex = pageIndex
115
+ this.idFactory = idFactory
116
+ this.fontCache = fontCache
117
+ this.builtInCMapCache = builtInCMapCache
118
+ this.standardFontDataCache = standardFontDataCache
119
+ this.globalImageCache = globalImageCache
120
+ this.systemFontCache = systemFontCache
121
+ this.options = options || DefaultPartialEvaluatorOptions
122
+ this.parsingType3Font = false
123
+
124
+ this._regionalImageCache = new RegionalImageCache()
125
+ this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this)
126
+ ImageResizer.setMaxArea(this.options.canvasMaxAreaInBytes)
127
+ }
128
+
129
+ /**
130
+ * Since Functions are only cached (locally) by reference, we can share one
131
+ * `PDFFunctionFactory` instance within this `PartialEvaluator` instance.
132
+ */
133
+ get _pdfFunctionFactory() {
134
+ const pdfFunctionFactory = new PDFFunctionFactory({
135
+ xref: this.xref,
136
+ isEvalSupported: this.options.isEvalSupported
137
+ })
138
+ return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory)
139
+ }
140
+
141
+ clone( newOptions = null ) {
142
+ const newEvaluator = Object.create(this)
143
+ newEvaluator.options = Object.assign(
144
+ Object.create(null),
145
+ this.options,
146
+ newOptions
147
+ )
148
+ return newEvaluator
149
+ }
150
+
151
+ async fetchBuiltInCMap( name ) {
152
+ const cachedData = this.builtInCMapCache.get(name)
153
+ if ( cachedData ) {
154
+ return cachedData
155
+ }
156
+ let data
157
+
158
+ if ( this.options.cMapUrl !== null ) {
159
+ // Only compressed CMaps are (currently) supported here.
160
+ const url = `${ this.options.cMapUrl }${ name }.bcmap`
161
+ const response = await fetch(url)
162
+ if ( !response.ok ) {
163
+ throw new Error(
164
+ `fetchBuiltInCMap: failed to fetch file "${ url }" with "${ response.statusText }".`
165
+ )
166
+ }
167
+ data = {
168
+ cMapData: new Uint8Array(await response.arrayBuffer()),
169
+ compressionType: CMapCompressionType.BINARY
170
+ }
171
+ } else {
172
+ // Get the data on the main-thread instead.
173
+ data = await this.handler.sendWithPromise("FetchBuiltInCMap", { name })
174
+ }
175
+
176
+ if ( data.compressionType !== CMapCompressionType.NONE ) {
177
+ // Given the size of uncompressed CMaps, only cache compressed ones.
178
+ this.builtInCMapCache.set(name, data)
179
+ }
180
+ return data
181
+ }
182
+
183
+ async fetchStandardFontData( name ) {
184
+ const cachedData = this.standardFontDataCache.get(name)
185
+ if ( cachedData ) {
186
+ return new Stream(cachedData)
187
+ }
188
+
189
+ // The symbol fonts are not consistent across platforms, always load the
190
+ // standard font data for them.
191
+ if (
192
+ this.options.useSystemFonts &&
193
+ name !== "Symbol" &&
194
+ name !== "ZapfDingbats"
195
+ ) {
196
+ return null
197
+ }
198
+
199
+ const standardFontNameToFileName = getFontNameToFileMap(),
200
+ filename = standardFontNameToFileName[name]
201
+ let data
202
+
203
+ if ( this.options.standardFontDataUrl !== null ) {
204
+ const url = `${ this.options.standardFontDataUrl }${ filename }`
205
+ const response = await fetch(url)
206
+ if ( !response.ok ) {
207
+ warn(
208
+ `fetchStandardFontData: failed to fetch file "${ url }" with "${ response.statusText }".`
209
+ )
210
+ } else {
211
+ data = new Uint8Array(await response.arrayBuffer())
212
+ }
213
+ } else {
214
+ // Get the data on the main-thread instead.
215
+ try {
216
+ data = await this.handler.sendWithPromise("FetchStandardFontData", {
217
+ filename
218
+ })
219
+ } catch (e) {
220
+ warn(
221
+ `fetchStandardFontData: failed to fetch file "${ filename }" with "${ e }".`
222
+ )
223
+ }
224
+ }
225
+
226
+ if ( !data ) {
227
+ return null
228
+ }
229
+ // Cache the "raw" standard font data, to avoid fetching it repeatedly
230
+ // (see e.g. issue 11399).
231
+ this.standardFontDataCache.set(name, data)
232
+
233
+ return new Stream(data)
234
+ }
235
+
236
+ async buildFormXObject(
237
+ resources,
238
+ xobj,
239
+ smask,
240
+ operatorList,
241
+ task,
242
+ initialState,
243
+ localColorSpaceCache
244
+ ) {
245
+ const dict = xobj.dict
246
+ const matrix = dict.getArray("Matrix")
247
+ let bbox = dict.getArray("BBox")
248
+ bbox =
249
+ Array.isArray(bbox) && bbox.length === 4
250
+ ? Util.normalizeRect(bbox)
251
+ : null
252
+
253
+ let optionalContent, groupOptions
254
+ if ( dict.has("OC") ) {
255
+ optionalContent = await this.parseMarkedContentProps(
256
+ dict.get("OC"),
257
+ resources
258
+ )
259
+ }
260
+ if ( optionalContent !== undefined ) {
261
+ operatorList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent])
262
+ }
263
+ const group = dict.get("Group")
264
+ if ( group ) {
265
+ groupOptions = {
266
+ matrix,
267
+ bbox,
268
+ smask,
269
+ isolated: false,
270
+ knockout: false
271
+ }
272
+
273
+ const groupSubtype = group.get("S")
274
+ let colorSpace = null
275
+ if ( isName(groupSubtype, "Transparency") ) {
276
+ groupOptions.isolated = group.get("I") || false
277
+ groupOptions.knockout = group.get("K") || false
278
+ if ( group.has("CS") ) {
279
+ const cs = group.getRaw("CS")
280
+
281
+ const cachedColorSpace = ColorSpace.getCached(
282
+ cs,
283
+ this.xref,
284
+ localColorSpaceCache
285
+ )
286
+ if ( cachedColorSpace ) {
287
+ colorSpace = cachedColorSpace
288
+ } else {
289
+ colorSpace = await this.parseColorSpace({
290
+ cs,
291
+ resources,
292
+ localColorSpaceCache
293
+ })
294
+ }
295
+ }
296
+ }
297
+
298
+ if ( smask?.backdrop ) {
299
+ colorSpace ||= ColorSpace.singletons.rgb
300
+ smask.backdrop = colorSpace.getRgb(smask.backdrop, 0)
301
+ }
302
+
303
+ operatorList.addOp(OPS.beginGroup, [groupOptions])
304
+ }
305
+
306
+ // If it's a group, a new canvas will be created that is the size of the
307
+ // bounding box and translated to the correct position so we don't need to
308
+ // apply the bounding box to it.
309
+ const args = group ? [matrix, null] : [matrix, bbox]
310
+ operatorList.addOp(OPS.paintFormXObjectBegin, args)
311
+
312
+ await this.getOperatorList({
313
+ stream: xobj,
314
+ task,
315
+ resources: dict.get("Resources") || resources,
316
+ operatorList,
317
+ initialState
318
+ })
319
+ operatorList.addOp(OPS.paintFormXObjectEnd, [])
320
+
321
+ if ( group ) {
322
+ operatorList.addOp(OPS.endGroup, [groupOptions])
323
+ }
324
+
325
+ if ( optionalContent !== undefined ) {
326
+ operatorList.addOp(OPS.endMarkedContent, [])
327
+ }
328
+ }
329
+
330
+ _sendImgData( objId, imgData, cacheGlobally = false ) {
331
+ const transfers = imgData ? [imgData.bitmap || imgData.data.buffer] : null
332
+
333
+ if ( this.parsingType3Font || cacheGlobally ) {
334
+ return this.handler.send(
335
+ "commonobj",
336
+ [objId, "Image", imgData],
337
+ transfers
338
+ )
339
+ }
340
+ return this.handler.send(
341
+ "obj",
342
+ [objId, this.pageIndex, "Image", imgData],
343
+ transfers
344
+ )
345
+ }
346
+
347
+ async buildPaintImageXObject( {
348
+ resources,
349
+ image,
350
+ isInline = false,
351
+ operatorList,
352
+ cacheKey,
353
+ localImageCache,
354
+ localColorSpaceCache
355
+ } ) {
356
+ const dict = image.dict
357
+ const imageRef = dict.objId
358
+ const w = dict.get("W", "Width")
359
+ const h = dict.get("H", "Height")
360
+
361
+ if ( !(w && typeof w === "number") || !(h && typeof h === "number") ) {
362
+ warn("Image dimensions are missing, or not numbers.")
363
+ return
364
+ }
365
+ const maxImageSize = this.options.maxImageSize
366
+ if ( maxImageSize !== -1 && w * h > maxImageSize ) {
367
+ const msg = "Image exceeded maximum allowed size and was removed."
368
+
369
+ if ( this.options.ignoreErrors ) {
370
+ warn(msg)
371
+ return
372
+ }
373
+ throw new Error(msg)
374
+ }
375
+
376
+ let optionalContent
377
+ if ( dict.has("OC") ) {
378
+ optionalContent = await this.parseMarkedContentProps(
379
+ dict.get("OC"),
380
+ resources
381
+ )
382
+ }
383
+
384
+ const imageMask = dict.get("IM", "ImageMask") || false
385
+ let imgData, args
386
+ if ( imageMask ) {
387
+ // This depends on a tmpCanvas being filled with the
388
+ // current fillStyle, such that processing the pixel
389
+ // data can't be done here. Instead of creating a
390
+ // complete PDFImage, only read the information needed
391
+ // for later.
392
+ const interpolate = dict.get("I", "Interpolate")
393
+ const bitStrideLength = (w + 7) >> 3
394
+ const imgArray = image.getBytes(bitStrideLength * h)
395
+ const decode = dict.getArray("D", "Decode")
396
+
397
+ if ( this.parsingType3Font ) {
398
+ imgData = PDFImage.createRawMask({
399
+ imgArray,
400
+ width: w,
401
+ height: h,
402
+ imageIsFromDecodeStream: image instanceof DecodeStream,
403
+ inverseDecode: decode?.[0] > 0,
404
+ interpolate
405
+ })
406
+
407
+ imgData.cached = !!cacheKey
408
+ args = [imgData]
409
+
410
+ operatorList.addImageOps(
411
+ OPS.paintImageMaskXObject,
412
+ args,
413
+ optionalContent
414
+ )
415
+
416
+ if ( cacheKey ) {
417
+ const cacheData = {
418
+ fn: OPS.paintImageMaskXObject,
419
+ args,
420
+ optionalContent
421
+ }
422
+ localImageCache.set(cacheKey, imageRef, cacheData)
423
+
424
+ if ( imageRef ) {
425
+ this._regionalImageCache.set(
426
+ /* name = */ null,
427
+ imageRef,
428
+ cacheData
429
+ )
430
+ }
431
+ }
432
+ return
433
+ }
434
+
435
+ imgData = await PDFImage.createMask({
436
+ imgArray,
437
+ width: w,
438
+ height: h,
439
+ imageIsFromDecodeStream: image instanceof DecodeStream,
440
+ inverseDecode: decode?.[0] > 0,
441
+ interpolate,
442
+ isOffscreenCanvasSupported: this.options.isOffscreenCanvasSupported
443
+ })
444
+
445
+ if ( imgData.isSingleOpaquePixel ) {
446
+ // Handles special case of mainly LaTeX documents which use image
447
+ // masks to draw lines with the current fill style.
448
+ operatorList.addImageOps(
449
+ OPS.paintSolidColorImageMask,
450
+ [],
451
+ optionalContent
452
+ )
453
+
454
+ if ( cacheKey ) {
455
+ const cacheData = {
456
+ fn: OPS.paintSolidColorImageMask,
457
+ args: [],
458
+ optionalContent
459
+ }
460
+ localImageCache.set(cacheKey, imageRef, cacheData)
461
+
462
+ if ( imageRef ) {
463
+ this._regionalImageCache.set(
464
+ /* name = */ null,
465
+ imageRef,
466
+ cacheData
467
+ )
468
+ }
469
+ }
470
+ return
471
+ }
472
+
473
+ const objId = `mask_${ this.idFactory.createObjId() }`
474
+ operatorList.addDependency(objId)
475
+
476
+ imgData.dataLen = imgData.bitmap
477
+ ? imgData.width * imgData.height * 4
478
+ : imgData.data.length
479
+ this._sendImgData(objId, imgData)
480
+
481
+ args = [
482
+ {
483
+ data: objId,
484
+ width: imgData.width,
485
+ height: imgData.height,
486
+ interpolate: imgData.interpolate,
487
+ count: 1
488
+ }
489
+ ]
490
+ operatorList.addImageOps(
491
+ OPS.paintImageMaskXObject,
492
+ args,
493
+ optionalContent
494
+ )
495
+
496
+ if ( cacheKey ) {
497
+ const cacheData = {
498
+ fn: OPS.paintImageMaskXObject,
499
+ args,
500
+ optionalContent
501
+ }
502
+ localImageCache.set(cacheKey, imageRef, cacheData)
503
+
504
+ if ( imageRef ) {
505
+ this._regionalImageCache.set(/* name = */ null, imageRef, cacheData)
506
+ }
507
+ }
508
+ return
509
+ }
510
+
511
+ const SMALL_IMAGE_DIMENSIONS = 200
512
+ // Inlining small images into the queue as RGB data
513
+ if (
514
+ isInline &&
515
+ !dict.has("SMask") &&
516
+ !dict.has("Mask") &&
517
+ w + h < SMALL_IMAGE_DIMENSIONS
518
+ ) {
519
+ const imageObj = new PDFImage({
520
+ xref: this.xref,
521
+ res: resources,
522
+ image,
523
+ isInline,
524
+ pdfFunctionFactory: this._pdfFunctionFactory,
525
+ localColorSpaceCache
526
+ })
527
+ // We force the use of RGBA_32BPP images here, because we can't handle
528
+ // any other kind.
529
+ imgData = await imageObj.createImageData(
530
+ /* forceRGBA = */ true,
531
+ /* isOffscreenCanvasSupported = */ false
532
+ )
533
+ operatorList.isOffscreenCanvasSupported =
534
+ this.options.isOffscreenCanvasSupported
535
+ operatorList.addImageOps(
536
+ OPS.paintInlineImageXObject,
537
+ [imgData],
538
+ optionalContent
539
+ )
540
+ return
541
+ }
542
+
543
+ // If there is no imageMask, create the PDFImage and a lot
544
+ // of image processing can be done here.
545
+ let objId = `img_${ this.idFactory.createObjId() }`,
546
+ cacheGlobally = false
547
+
548
+ if ( this.parsingType3Font ) {
549
+ objId = `${ this.idFactory.getDocId() }_type3_${ objId }`
550
+ } else if ( cacheKey && imageRef ) {
551
+ cacheGlobally = this.globalImageCache.shouldCache(
552
+ imageRef,
553
+ this.pageIndex
554
+ )
555
+
556
+ if ( cacheGlobally ) {
557
+ assert( !isInline, "Cannot cache an inline image globally.")
558
+
559
+ objId = `${ this.idFactory.getDocId() }_${ objId }`
560
+ }
561
+ }
562
+
563
+ // Ensure that the dependency is added before the image is decoded.
564
+ operatorList.addDependency(objId)
565
+ args = [objId, w, h]
566
+ operatorList.addImageOps(OPS.paintImageXObject, args, optionalContent)
567
+
568
+ // For large images, at least 500x500 in size, that we'll cache globally
569
+ // check if the image is still cached locally on the main-thread to avoid
570
+ // having to re-parse the image (since that can be slow).
571
+ if ( cacheGlobally && w * h > 250000 ) {
572
+ const localLength = await this.handler.sendWithPromise("commonobj", [
573
+ objId,
574
+ "CopyLocalImage",
575
+ { imageRef }
576
+ ])
577
+
578
+ if ( localLength ) {
579
+ this.globalImageCache.setData(imageRef, {
580
+ objId,
581
+ fn: OPS.paintImageXObject,
582
+ args,
583
+ optionalContent,
584
+ byteSize: 0 // Temporary entry, to avoid `setData` returning early.
585
+ })
586
+ this.globalImageCache.addByteSize(imageRef, localLength)
587
+ return
588
+ }
589
+ }
590
+
591
+ PDFImage.buildImage({
592
+ xref: this.xref,
593
+ res: resources,
594
+ image,
595
+ isInline,
596
+ pdfFunctionFactory: this._pdfFunctionFactory,
597
+ localColorSpaceCache
598
+ })
599
+ .then(async imageObj => {
600
+ imgData = await imageObj.createImageData(
601
+ /* forceRGBA = */ false,
602
+ /* isOffscreenCanvasSupported = */ this.options
603
+ .isOffscreenCanvasSupported
604
+ )
605
+ imgData.dataLen = imgData.bitmap
606
+ ? imgData.width * imgData.height * 4
607
+ : imgData.data.length
608
+ imgData.ref = imageRef
609
+
610
+ if ( cacheGlobally ) {
611
+ this.globalImageCache.addByteSize(imageRef, imgData.dataLen)
612
+ }
613
+ return this._sendImgData(objId, imgData, cacheGlobally)
614
+ })
615
+ .catch(reason => {
616
+ warn(`Unable to decode image "${ objId }": "${ reason }".`)
617
+
618
+ return this._sendImgData(objId, /* imgData = */ null, cacheGlobally)
619
+ })
620
+
621
+ if ( cacheKey ) {
622
+ const cacheData = {
623
+ fn: OPS.paintImageXObject,
624
+ args,
625
+ optionalContent
626
+ }
627
+ localImageCache.set(cacheKey, imageRef, cacheData)
628
+
629
+ if ( imageRef ) {
630
+ this._regionalImageCache.set(/* name = */ null, imageRef, cacheData)
631
+
632
+ if ( cacheGlobally ) {
633
+ this.globalImageCache.setData(imageRef, {
634
+ objId,
635
+ fn: OPS.paintImageXObject,
636
+ args,
637
+ optionalContent,
638
+ byteSize: 0 // Temporary entry, note `addByteSize` above.
639
+ })
640
+ }
641
+ }
642
+ }
643
+ }
644
+
645
+ handleSMask(
646
+ smask,
647
+ resources,
648
+ operatorList,
649
+ task,
650
+ stateManager,
651
+ localColorSpaceCache
652
+ ) {
653
+ const smaskContent = smask.get("G")
654
+ const smaskOptions = {
655
+ subtype: smask.get("S").name,
656
+ backdrop: smask.get("BC")
657
+ }
658
+
659
+ // The SMask might have a alpha/luminosity value transfer function --
660
+ // we will build a map of integer values in range 0..255 to be fast.
661
+ const transferObj = smask.get("TR")
662
+ if ( isPDFFunction(transferObj) ) {
663
+ const transferFn = this._pdfFunctionFactory.create(transferObj)
664
+ const transferMap = new Uint8Array(256)
665
+ const tmp = new Float32Array(1)
666
+ for (let i = 0; i < 256; i++) {
667
+ tmp[0] = i / 255
668
+ transferFn(tmp, 0, tmp, 0)
669
+ transferMap[i] = (tmp[0] * 255) | 0
670
+ }
671
+ smaskOptions.transferMap = transferMap
672
+ }
673
+
674
+ return this.buildFormXObject(
675
+ resources,
676
+ smaskContent,
677
+ smaskOptions,
678
+ operatorList,
679
+ task,
680
+ stateManager.state.clone(),
681
+ localColorSpaceCache
682
+ )
683
+ }
684
+
685
+ handleTransferFunction( tr ) {
686
+ let transferArray
687
+ if ( Array.isArray(tr) ) {
688
+ transferArray = tr
689
+ } else if ( isPDFFunction(tr) ) {
690
+ transferArray = [tr]
691
+ } else {
692
+ return null // Not a valid transfer function entry.
693
+ }
694
+
695
+ const transferMaps = []
696
+ let numFns = 0,
697
+ numEffectfulFns = 0
698
+ for (const entry of transferArray) {
699
+ const transferObj = this.xref.fetchIfRef(entry)
700
+ numFns++
701
+
702
+ if ( isName(transferObj, "Identity") ) {
703
+ transferMaps.push(null)
704
+ continue
705
+ } else if ( !isPDFFunction(transferObj) ) {
706
+ return null // Not a valid transfer function object.
707
+ }
708
+
709
+ const transferFn = this._pdfFunctionFactory.create(transferObj)
710
+ const transferMap = new Uint8Array(256),
711
+ tmp = new Float32Array(1)
712
+ for (let j = 0; j < 256; j++) {
713
+ tmp[0] = j / 255
714
+ transferFn(tmp, 0, tmp, 0)
715
+ transferMap[j] = (tmp[0] * 255) | 0
716
+ }
717
+ transferMaps.push(transferMap)
718
+ numEffectfulFns++
719
+ }
720
+
721
+ if ( !(numFns === 1 || numFns === 4) ) {
722
+ return null // Only 1 or 4 functions are supported, by the specification.
723
+ }
724
+ if ( numEffectfulFns === 0 ) {
725
+ return null // Only /Identity transfer functions found, which are no-ops.
726
+ }
727
+ return transferMaps
728
+ }
729
+
730
+ handleTilingType(
731
+ fn,
732
+ color,
733
+ resources,
734
+ pattern,
735
+ patternDict,
736
+ operatorList,
737
+ task,
738
+ localTilingPatternCache
739
+ ) {
740
+ // Create an IR of the pattern code.
741
+ const tilingOpList = new OperatorList()
742
+ // Merge the available resources, to prevent issues when the patternDict
743
+ // is missing some /Resources entries (fixes issue6541.pdf).
744
+ const patternResources = Dict.merge({
745
+ xref: this.xref,
746
+ dictArray: [patternDict.get("Resources"), resources]
747
+ })
748
+
749
+ return this.getOperatorList({
750
+ stream: pattern,
751
+ task,
752
+ resources: patternResources,
753
+ operatorList: tilingOpList
754
+ })
755
+ .then(function() {
756
+ const operatorListIR = tilingOpList.getIR()
757
+ const tilingPatternIR = getTilingPatternIR(
758
+ operatorListIR,
759
+ patternDict,
760
+ color
761
+ )
762
+ // Add the dependencies to the parent operator list so they are
763
+ // resolved before the sub operator list is executed synchronously.
764
+ operatorList.addDependencies(tilingOpList.dependencies)
765
+ operatorList.addOp(fn, tilingPatternIR)
766
+
767
+ if ( patternDict.objId ) {
768
+ localTilingPatternCache.set(/* name = */ null, patternDict.objId, {
769
+ operatorListIR,
770
+ dict: patternDict
771
+ })
772
+ }
773
+ })
774
+ .catch(reason => {
775
+ if ( reason instanceof AbortException ) {
776
+ return
777
+ }
778
+ if ( this.options.ignoreErrors ) {
779
+ warn(`handleTilingType - ignoring pattern: "${ reason }".`)
780
+ return
781
+ }
782
+ throw reason
783
+ })
784
+ }
785
+
786
+ async handleSetFont(
787
+ resources,
788
+ fontArgs,
789
+ fontRef,
790
+ operatorList,
791
+ task,
792
+ state,
793
+ fallbackFontDict = null,
794
+ cssFontInfo = null
795
+ ) {
796
+ const fontName = fontArgs?.[0] instanceof Name ? fontArgs[0].name : null
797
+
798
+ if ( resources.objId === "6R" ) {
799
+ // 加载sans-bold的字体
800
+ // debugger
801
+ }
802
+ // 这里translated的data数据就是读取出来的字体数据,和liteofd中直接读取出来的文件内容一样了,看接下来怎么处理
803
+ // 包装后的TranslatedFont对象,里面的font就是字体数据
804
+ let translated = await this.loadFont(
805
+ fontName,
806
+ fontRef,
807
+ resources,
808
+ fallbackFontDict,
809
+ cssFontInfo
810
+ )
811
+
812
+ if ( translated.font.isType3Font ) {
813
+ try {
814
+ await translated.loadType3Data(this, resources, task)
815
+ // Add the dependencies to the parent operatorList so they are
816
+ // resolved before Type3 operatorLists are executed synchronously.
817
+ operatorList.addDependencies(translated.type3Dependencies)
818
+ } catch (reason) {
819
+ translated = new TranslatedFont({
820
+ loadedName: "g_font_error",
821
+ font: new ErrorFont(`Type3 font load error: ${ reason }`),
822
+ dict: translated.font,
823
+ evaluatorOptions: this.options
824
+ })
825
+ }
826
+ }
827
+ // zxlog("evaluator.js handleSetFont ", fontName)
828
+ state.font = translated.font
829
+ // 这里发送的是一个commobj的对象方法,是处理Font的
830
+ translated.send(this.handler)
831
+ return translated.loadedName
832
+ }
833
+
834
+ handleText( chars, state ) {
835
+ const font = state.font
836
+ // 这里是将字体的字形转换到对应的吗
837
+ if ( state.font.name === "TACTGM+NimbusRomNo9L-Medi" ) debugger
838
+ const glyphs = font.charsToGlyphs(chars)
839
+
840
+ if ( font.data ) {
841
+ const isAddToPathSet = !!(
842
+ state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG
843
+ )
844
+ if (
845
+ isAddToPathSet ||
846
+ state.fillColorSpace.name === "Pattern" ||
847
+ font.disableFontFace ||
848
+ this.options.disableFontFace
849
+ ) {
850
+ PartialEvaluator.buildFontPaths(
851
+ font,
852
+ glyphs,
853
+ this.handler,
854
+ this.options
855
+ )
856
+ }
857
+ }
858
+ // zxlog("evaluator.js handleText ", glyphs);
859
+ return glyphs
860
+ }
861
+
862
+ ensureStateFont( state ) {
863
+ if ( state.font ) {
864
+ return
865
+ }
866
+ const reason = new FormatError(
867
+ "Missing setFont (Tf) operator before text rendering operator."
868
+ )
869
+
870
+ if ( this.options.ignoreErrors ) {
871
+ warn(`ensureStateFont: "${ reason }".`)
872
+ return
873
+ }
874
+ throw reason
875
+ }
876
+
877
+ async setGState( { resources, gState, operatorList, cacheKey, task, stateManager, localGStateCache, localColorSpaceCache } ) {
878
+ const gStateRef = gState.objId
879
+ let isSimpleGState = true
880
+ // This array holds the converted/processed state data.
881
+ const gStateObj = []
882
+ let promise = Promise.resolve()
883
+ for (const key of gState.getKeys()) {
884
+ const value = gState.get(key)
885
+ switch (key) {
886
+ case "Type":
887
+ break
888
+ case "LW":
889
+ case "LC":
890
+ case "LJ":
891
+ case "ML":
892
+ case "D":
893
+ case "RI":
894
+ case "FL":
895
+ case "CA":
896
+ case "ca":
897
+ gStateObj.push([key, value])
898
+ break
899
+ case "Font":
900
+ isSimpleGState = false
901
+
902
+ promise = promise.then(() =>
903
+ this.handleSetFont(
904
+ resources,
905
+ null,
906
+ value[0],
907
+ operatorList,
908
+ task,
909
+ stateManager.state
910
+ ).then(function( loadedName ) {
911
+ operatorList.addDependency(loadedName)
912
+ gStateObj.push([key, [loadedName, value[1]]])
913
+ })
914
+ )
915
+ break
916
+ case "BM":
917
+ gStateObj.push([key, normalizeBlendMode(value)])
918
+ break
919
+ case "SMask":
920
+ if ( isName(value, "None") ) {
921
+ gStateObj.push([key, false])
922
+ break
923
+ }
924
+ if ( value instanceof Dict ) {
925
+ isSimpleGState = false
926
+
927
+ promise = promise.then(() =>
928
+ this.handleSMask(
929
+ value,
930
+ resources,
931
+ operatorList,
932
+ task,
933
+ stateManager,
934
+ localColorSpaceCache
935
+ )
936
+ )
937
+ gStateObj.push([key, true])
938
+ } else {
939
+ warn("Unsupported SMask type")
940
+ }
941
+ break
942
+ case "TR":
943
+ const transferMaps = this.handleTransferFunction(value)
944
+ gStateObj.push([key, transferMaps])
945
+ break
946
+ // Only generate info log messages for the following since
947
+ // they are unlikely to have a big impact on the rendering.
948
+ case "OP":
949
+ case "op":
950
+ case "OPM":
951
+ case "BG":
952
+ case "BG2":
953
+ case "UCR":
954
+ case "UCR2":
955
+ case "TR2":
956
+ case "HT":
957
+ case "SM":
958
+ case "SA":
959
+ case "AIS":
960
+ case "TK":
961
+ // TODO implement these operators.
962
+ // info("graphic state operator " + key)
963
+ break
964
+ default:
965
+ // info("Unknown graphic state operator " + key)
966
+ break
967
+ }
968
+ }
969
+ await promise
970
+
971
+ if ( gStateObj.length > 0 ) {
972
+ operatorList.addOp(OPS.setGState, [gStateObj])
973
+ }
974
+
975
+ if ( isSimpleGState ) {
976
+ localGStateCache.set(cacheKey, gStateRef, gStateObj)
977
+ }
978
+ }
979
+
980
+ loadFont(
981
+ fontName,
982
+ font,
983
+ resources,
984
+ fallbackFontDict = null,
985
+ cssFontInfo = null
986
+ ) {
987
+ // eslint-disable-next-line arrow-body-style
988
+ // debugger
989
+ // 加载字体,将文件中的本地字体加载出来,这里的加载字体是要将字体转为glyph吗,显示的时候
990
+ const errorFont = async () => new TranslatedFont({
991
+ loadedName: "g_font_error",
992
+ font: new ErrorFont(`Font "${ fontName }" is not available.`),
993
+ dict: font,
994
+ evaluatorOptions: this.options
995
+ })
996
+
997
+ let fontRef
998
+ if ( font ) {
999
+ // Loading by ref.
1000
+ if ( font instanceof Ref ) {
1001
+ fontRef = font
1002
+ }
1003
+ } else {
1004
+ // Loading by name.
1005
+ const fontRes = resources.get("Font") // 获取字体资源,拿到字体在文件中的引用位置的map,比如4
1006
+ // 0,就是4 0 的交叉表中数据位置
1007
+ if ( fontRes ) {
1008
+ fontRef = fontRes.getRaw(fontName)
1009
+ }
1010
+ }
1011
+ if ( fontRef ) { // 字体的位置引用 num:4 gen:0 表示位置在4 0的字体
1012
+ if ( this.parsingType3Font && this.type3FontRefs.has(fontRef) ) {
1013
+ return errorFont()
1014
+ }
1015
+
1016
+ if ( this.fontCache.has(fontRef) ) {
1017
+ return this.fontCache.get(fontRef)
1018
+ }
1019
+ // 这里fontRef拿到了也有一个ToUnicode是字体的渲染字符
1020
+ font = this.xref.fetchIfRef(fontRef) // 拿到交叉表对应的字体数据,也就是i交叉表已经把数据解析了,这里是拿到对应4R位置的数据,也就是字体的font数据了
1021
+ }
1022
+
1023
+ if ( !(font instanceof Dict) ) {
1024
+ if ( !this.options.ignoreErrors && !this.parsingType3Font ) {
1025
+ warn(`Font "${ fontName }" is not available.`)
1026
+ return errorFont()
1027
+ }
1028
+ warn(
1029
+ `Font "${ fontName }" is not available -- attempting to fallback to a default font.`
1030
+ )
1031
+
1032
+ // Falling back to a default font to avoid completely broken rendering,
1033
+ // but note that there're no guarantees that things will look "correct".
1034
+ font = fallbackFontDict || PartialEvaluator.fallbackFontDict
1035
+ }
1036
+ // zxlog("evaluator.js loadFont", fontName, font, resources);
1037
+
1038
+ // We are holding `font.cacheKey` references only for `fontRef`s that
1039
+ // are not actually `Ref`s, but rather `Dict`s. See explanation below.
1040
+ if ( font.cacheKey && this.fontCache.has(font.cacheKey) ) {
1041
+ return this.fontCache.get(font.cacheKey)
1042
+ }
1043
+
1044
+ const fontCapability = new PromiseCapability()
1045
+
1046
+ let preEvaluatedFont
1047
+ try {
1048
+ preEvaluatedFont = this.preEvaluateFont(font) // 这里是将Font的字典预处理,加载为字体对象的第一步执行应该是
1049
+ // 对字体数据做了处理,拿到了hash是字体的内容,做了一次hash计算的处理,看看是什么样的数据
1050
+ if ( preEvaluatedFont.baseDict.objId === "6R" ) {
1051
+ // 这里的9R表示字体的跟字典的id,这里的9R是"AAAAAE+DejaVuSans-Bold"的字体
1052
+ // debugger
1053
+ }
1054
+ preEvaluatedFont.cssFontInfo = cssFontInfo
1055
+ } catch (reason) {
1056
+ warn(`loadFont - preEvaluateFont failed: "${ reason }".`)
1057
+ return errorFont()
1058
+ }
1059
+ const { descriptor, hash } = preEvaluatedFont
1060
+
1061
+ const fontRefIsRef = fontRef instanceof Ref
1062
+ let fontID
1063
+
1064
+ if ( hash && descriptor instanceof Dict ) {
1065
+ // 相当于给descriptor添加一个fontAliases,就是把字体的数据做成hash字符串来标记
1066
+ const fontAliases = (descriptor.fontAliases ||= Object.create(null))
1067
+ // 相当于把字体计算出一个hash值,来表示特定的字体,防止字体冲突?
1068
+ if ( fontAliases[hash] ) {
1069
+ const aliasFontRef = fontAliases[hash].aliasRef
1070
+ if ( fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef) ) {
1071
+ this.fontCache.putAlias(fontRef, aliasFontRef)
1072
+ return this.fontCache.get(fontRef)
1073
+ }
1074
+ } else {
1075
+ fontAliases[hash] = {
1076
+ fontID: this.idFactory.createFontId() // 根据字体顺序创造使用一个id
1077
+ }
1078
+ }
1079
+
1080
+ if ( fontRefIsRef ) {
1081
+ fontAliases[hash].aliasRef = fontRef
1082
+ }
1083
+ fontID = fontAliases[hash].fontID
1084
+ } else {
1085
+ fontID = this.idFactory.createFontId()
1086
+ }
1087
+ assert(
1088
+ fontID?.startsWith("f"),
1089
+ "The \"fontID\" must be (correctly) defined."
1090
+ )
1091
+
1092
+ // Workaround for bad PDF generators that reference fonts incorrectly,
1093
+ // where `fontRef` is a `Dict` rather than a `Ref` (fixes bug946506.pdf).
1094
+ // In this case we cannot put the font into `this.fontCache` (which is
1095
+ // a `RefSetCache`), since it's not possible to use a `Dict` as a key.
1096
+ //
1097
+ // However, if we don't cache the font it's not possible to remove it
1098
+ // when `cleanup` is triggered from the API, which causes issues on
1099
+ // subsequent rendering operations (see issue7403.pdf) and would force us
1100
+ // to unnecessarily load the same fonts over and over.
1101
+ //
1102
+ // Instead, we cheat a bit by using a modified `fontID` as a key in
1103
+ // `this.fontCache`, to allow the font to be cached.
1104
+ // NOTE: This works because `RefSetCache` calls `toString()` on provided
1105
+ // keys. Also, since `fontRef` is used when getting cached fonts,
1106
+ // we'll not accidentally match fonts cached with the `fontID`.
1107
+ if ( fontRefIsRef ) {
1108
+ this.fontCache.put(fontRef, fontCapability.promise) // 添加字体的缓存,用来获取字体数据,这里使用了一个异步的promise的对象来处理
1109
+ } else {
1110
+ font.cacheKey = `cacheKey_${ fontID }`
1111
+ this.fontCache.put(font.cacheKey, fontCapability.promise)
1112
+ }
1113
+
1114
+ // Keep track of each font we translated so the caller can
1115
+ // load them asynchronously before calling display on a page.
1116
+ font.loadedName = `${ this.idFactory.getDocId() }_${ fontID }`
1117
+ // 转换为Font对象,这里加载完数据应该还是对数据做了处理,不然和直接加载完是不一样的,所以需要看看怎么处理,需要处理一下字体
1118
+ if ( preEvaluatedFont.baseDict.objId === "6R" ) {
1119
+ // 这里的9R表示字体的跟字典的id,这里的9R是"AAAAAE+DejaVuSans-Bold"的字体
1120
+ // debugger
1121
+ }
1122
+ // translateFont就是将PDF中的字体数据提取,然后转换成对应字体,比如Type1Font的字体
1123
+ // 然后将Type1Font的字体进行压缩CFF,之后再组装成为一个OTF的字体,保存再translatedFont的data
1124
+ // 数据里面就是OTF的数据,二进制数据组
1125
+ this.translateFont(preEvaluatedFont)
1126
+ .then(translatedFont => {
1127
+ // 这里是将字体转换之后的字体,就是再加载了原始的文件中的字体之后,经过转换形成的字体
1128
+ // 再将解析后的字体包装成TranslatedFont对象,这样就完成了字体的全部解析
1129
+ fontCapability.resolve(
1130
+ new TranslatedFont({
1131
+ loadedName: font.loadedName,
1132
+ font: translatedFont,
1133
+ dict: font,
1134
+ evaluatorOptions: this.options
1135
+ })
1136
+ )
1137
+ })
1138
+ .catch(reason => {
1139
+ // TODO fontCapability.reject?
1140
+ warn(`loadFont - translateFont failed: "${ reason }".`)
1141
+
1142
+ fontCapability.resolve(
1143
+ new TranslatedFont({
1144
+ loadedName: font.loadedName,
1145
+ font: new ErrorFont(
1146
+ reason instanceof Error ? reason.message : reason
1147
+ ),
1148
+ dict: font,
1149
+ evaluatorOptions: this.options
1150
+ })
1151
+ )
1152
+ })
1153
+ // 返回的是字体处理的,使用await之后获得的是TranslatedFont的对象
1154
+ return fontCapability.promise
1155
+ }
1156
+
1157
+ buildPath( operatorList, fn, args, parsingText = false ) {
1158
+ const lastIndex = operatorList.length - 1
1159
+ if ( !args ) {
1160
+ args = []
1161
+ }
1162
+ if (
1163
+ lastIndex < 0 ||
1164
+ operatorList.fnArray[lastIndex] !== OPS.constructPath
1165
+ ) {
1166
+ // Handle corrupt PDF documents that contains path operators inside of
1167
+ // text objects, which may shift subsequent text, by enclosing the path
1168
+ // operator in save/restore operators (fixes issue10542_reduced.pdf).
1169
+ //
1170
+ // Note that this will effectively disable the optimization in the
1171
+ // `else` branch below, but given that this type of corruption is
1172
+ // *extremely* rare that shouldn't really matter much in practice.
1173
+ if ( parsingText ) {
1174
+ warn(`Encountered path operator "${ fn }" inside of a text object.`)
1175
+ operatorList.addOp(OPS.save, null)
1176
+ }
1177
+
1178
+ let minMax
1179
+ switch (fn) {
1180
+ case OPS.rectangle:
1181
+ const x = args[0] + args[2]
1182
+ const y = args[1] + args[3]
1183
+ minMax = [
1184
+ Math.min(args[0], x),
1185
+ Math.min(args[1], y),
1186
+ Math.max(args[0], x),
1187
+ Math.max(args[1], y)
1188
+ ]
1189
+ break
1190
+ case OPS.moveTo:
1191
+ case OPS.lineTo:
1192
+ minMax = [args[0], args[1], args[0], args[1]]
1193
+ break
1194
+ default:
1195
+ minMax = [Infinity, Infinity, -Infinity, -Infinity]
1196
+ break
1197
+ }
1198
+ operatorList.addOp(OPS.constructPath, [[fn], args, minMax])
1199
+
1200
+ if ( parsingText ) {
1201
+ operatorList.addOp(OPS.restore, null)
1202
+ }
1203
+ } else {
1204
+ const opArgs = operatorList.argsArray[lastIndex]
1205
+ opArgs[0].push(fn)
1206
+ opArgs[1].push(...args)
1207
+ const minMax = opArgs[2]
1208
+
1209
+ // Compute min/max in the worker instead of the main thread.
1210
+ // If the current matrix (when drawing) is a scaling one
1211
+ // then min/max can be easily computed in using those values.
1212
+ // Only rectangle, lineTo and moveTo are handled here since
1213
+ // Bezier stuff requires to have the starting point.
1214
+ switch (fn) {
1215
+ case OPS.rectangle:
1216
+ const x = args[0] + args[2]
1217
+ const y = args[1] + args[3]
1218
+ minMax[0] = Math.min(minMax[0], args[0], x)
1219
+ minMax[1] = Math.min(minMax[1], args[1], y)
1220
+ minMax[2] = Math.max(minMax[2], args[0], x)
1221
+ minMax[3] = Math.max(minMax[3], args[1], y)
1222
+ break
1223
+ case OPS.moveTo:
1224
+ case OPS.lineTo:
1225
+ minMax[0] = Math.min(minMax[0], args[0])
1226
+ minMax[1] = Math.min(minMax[1], args[1])
1227
+ minMax[2] = Math.max(minMax[2], args[0])
1228
+ minMax[3] = Math.max(minMax[3], args[1])
1229
+ break
1230
+ }
1231
+ }
1232
+ }
1233
+
1234
+ parseColorSpace( { cs, resources, localColorSpaceCache } ) {
1235
+ return ColorSpace.parseAsync({
1236
+ cs,
1237
+ xref: this.xref,
1238
+ resources,
1239
+ pdfFunctionFactory: this._pdfFunctionFactory,
1240
+ localColorSpaceCache
1241
+ }).catch(reason => {
1242
+ if ( reason instanceof AbortException ) {
1243
+ return null
1244
+ }
1245
+ if ( this.options.ignoreErrors ) {
1246
+ warn(`parseColorSpace - ignoring ColorSpace: "${ reason }".`)
1247
+ return null
1248
+ }
1249
+ throw reason
1250
+ })
1251
+ }
1252
+
1253
+ parseShading( {
1254
+ shading,
1255
+ resources,
1256
+ localColorSpaceCache,
1257
+ localShadingPatternCache
1258
+ } ) {
1259
+ // Shadings and patterns may be referenced by the same name but the resource
1260
+ // dictionary could be different so we can't use the name for the cache key.
1261
+ let id = localShadingPatternCache.get(shading)
1262
+ if ( !id ) {
1263
+ var shadingFill = Pattern.parseShading(
1264
+ shading,
1265
+ this.xref,
1266
+ resources,
1267
+ this._pdfFunctionFactory,
1268
+ localColorSpaceCache
1269
+ )
1270
+ const patternIR = shadingFill.getIR()
1271
+ id = `pattern_${ this.idFactory.createObjId() }`
1272
+ if ( this.parsingType3Font ) {
1273
+ id = `${ this.idFactory.getDocId() }_type3_${ id }`
1274
+ }
1275
+ localShadingPatternCache.set(shading, id)
1276
+
1277
+ if ( this.parsingType3Font ) {
1278
+ this.handler.send("commonobj", [id, "Pattern", patternIR])
1279
+ } else {
1280
+ this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR])
1281
+ }
1282
+ }
1283
+ return id
1284
+ }
1285
+
1286
+ handleColorN(
1287
+ operatorList,
1288
+ fn,
1289
+ args,
1290
+ cs,
1291
+ patterns,
1292
+ resources,
1293
+ task,
1294
+ localColorSpaceCache,
1295
+ localTilingPatternCache,
1296
+ localShadingPatternCache
1297
+ ) {
1298
+ // compile tiling patterns
1299
+ const patternName = args.pop()
1300
+ // SCN/scn applies patterns along with normal colors
1301
+ if ( patternName instanceof Name ) {
1302
+ const rawPattern = patterns.getRaw(patternName.name)
1303
+
1304
+ const localTilingPattern =
1305
+ rawPattern instanceof Ref &&
1306
+ localTilingPatternCache.getByRef(rawPattern)
1307
+ if ( localTilingPattern ) {
1308
+ try {
1309
+ const color = cs.base ? cs.base.getRgb(args, 0) : null
1310
+ const tilingPatternIR = getTilingPatternIR(
1311
+ localTilingPattern.operatorListIR,
1312
+ localTilingPattern.dict,
1313
+ color
1314
+ )
1315
+ operatorList.addOp(fn, tilingPatternIR)
1316
+ return undefined
1317
+ } catch {
1318
+ // Handle any errors during normal TilingPattern parsing.
1319
+ }
1320
+ }
1321
+
1322
+ const pattern = this.xref.fetchIfRef(rawPattern)
1323
+ if ( pattern ) {
1324
+ const dict = pattern instanceof BaseStream ? pattern.dict : pattern
1325
+ const typeNum = dict.get("PatternType")
1326
+
1327
+ if ( typeNum === PatternType.TILING ) {
1328
+ const color = cs.base ? cs.base.getRgb(args, 0) : null
1329
+ return this.handleTilingType(
1330
+ fn,
1331
+ color,
1332
+ resources,
1333
+ pattern,
1334
+ dict,
1335
+ operatorList,
1336
+ task,
1337
+ localTilingPatternCache
1338
+ )
1339
+ } else if ( typeNum === PatternType.SHADING ) {
1340
+ const shading = dict.get("Shading")
1341
+ const matrix = dict.getArray("Matrix")
1342
+ const objId = this.parseShading({
1343
+ shading,
1344
+ resources,
1345
+ localColorSpaceCache,
1346
+ localShadingPatternCache
1347
+ })
1348
+ operatorList.addOp(fn, ["Shading", objId, matrix])
1349
+ return undefined
1350
+ }
1351
+ throw new FormatError(`Unknown PatternType: ${ typeNum }`)
1352
+ }
1353
+ }
1354
+ throw new FormatError(`Unknown PatternName: ${ patternName }`)
1355
+ }
1356
+
1357
+ _parseVisibilityExpression( array, nestingCounter, currentResult ) {
1358
+ const MAX_NESTING = 10
1359
+ if ( ++nestingCounter > MAX_NESTING ) {
1360
+ warn("Visibility expression is too deeply nested")
1361
+ return
1362
+ }
1363
+ const length = array.length
1364
+ const operator = this.xref.fetchIfRef(array[0])
1365
+ if ( length < 2 || !(operator instanceof Name) ) {
1366
+ warn("Invalid visibility expression")
1367
+ return
1368
+ }
1369
+ switch (operator.name) {
1370
+ case "And":
1371
+ case "Or":
1372
+ case "Not":
1373
+ currentResult.push(operator.name)
1374
+ break
1375
+ default:
1376
+ warn(`Invalid operator ${ operator.name } in visibility expression`)
1377
+ return
1378
+ }
1379
+ for (let i = 1; i < length; i++) {
1380
+ const raw = array[i]
1381
+ const object = this.xref.fetchIfRef(raw)
1382
+ if ( Array.isArray(object) ) {
1383
+ const nestedResult = []
1384
+ currentResult.push(nestedResult)
1385
+ // Recursively parse a subarray.
1386
+ this._parseVisibilityExpression(object, nestingCounter, nestedResult)
1387
+ } else if ( raw instanceof Ref ) {
1388
+ // Reference to an OCG dictionary.
1389
+ currentResult.push(raw.toString())
1390
+ }
1391
+ }
1392
+ }
1393
+
1394
+ async parseMarkedContentProps( contentProperties, resources ) {
1395
+ let optionalContent
1396
+ if ( contentProperties instanceof Name ) {
1397
+ const properties = resources.get("Properties")
1398
+ optionalContent = properties.get(contentProperties.name)
1399
+ } else if ( contentProperties instanceof Dict ) {
1400
+ optionalContent = contentProperties
1401
+ } else {
1402
+ throw new FormatError("Optional content properties malformed.")
1403
+ }
1404
+
1405
+ const optionalContentType = optionalContent.get("Type")?.name
1406
+ if ( optionalContentType === "OCG" ) {
1407
+ return {
1408
+ type: optionalContentType,
1409
+ id: optionalContent.objId
1410
+ }
1411
+ } else if ( optionalContentType === "OCMD" ) {
1412
+ const expression = optionalContent.get("VE")
1413
+ if ( Array.isArray(expression) ) {
1414
+ const result = []
1415
+ this._parseVisibilityExpression(expression, 0, result)
1416
+ if ( result.length > 0 ) {
1417
+ return {
1418
+ type: "OCMD",
1419
+ expression: result
1420
+ }
1421
+ }
1422
+ }
1423
+
1424
+ const optionalContentGroups = optionalContent.get("OCGs")
1425
+ if (
1426
+ Array.isArray(optionalContentGroups) ||
1427
+ optionalContentGroups instanceof Dict
1428
+ ) {
1429
+ const groupIds = []
1430
+ if ( Array.isArray(optionalContentGroups) ) {
1431
+ for (const ocg of optionalContentGroups) {
1432
+ groupIds.push(ocg.toString())
1433
+ }
1434
+ } else {
1435
+ // Dictionary, just use the obj id.
1436
+ groupIds.push(optionalContentGroups.objId)
1437
+ }
1438
+
1439
+ return {
1440
+ type: optionalContentType,
1441
+ ids: groupIds,
1442
+ policy:
1443
+ optionalContent.get("P") instanceof Name
1444
+ ? optionalContent.get("P").name
1445
+ : null,
1446
+ expression: null
1447
+ }
1448
+ } else if ( optionalContentGroups instanceof Ref ) {
1449
+ return {
1450
+ type: optionalContentType,
1451
+ id: optionalContentGroups.toString()
1452
+ }
1453
+ }
1454
+ }
1455
+ return null
1456
+ }
1457
+
1458
+ getOperatorList( { stream, task, resources, operatorList, initialState = null, fallbackFontDict = null } ) {
1459
+ // Ensure that `resources`/`initialState` is correctly initialized,
1460
+ // even if the provided parameter is e.g. `null`.
1461
+ resources ||= Dict.empty
1462
+ initialState ||= new EvalState()
1463
+
1464
+ if ( !operatorList ) {
1465
+ throw new Error("getOperatorList: missing \"operatorList\" parameter")
1466
+ }
1467
+
1468
+ const self = this
1469
+ const xref = this.xref
1470
+ let parsingText = false
1471
+ const localImageCache = new LocalImageCache()
1472
+ const localColorSpaceCache = new LocalColorSpaceCache()
1473
+ const localGStateCache = new LocalGStateCache()
1474
+ const localTilingPatternCache = new LocalTilingPatternCache()
1475
+ const localShadingPatternCache = new Map()
1476
+
1477
+ const xobjs = resources.get("XObject") || Dict.empty
1478
+ const patterns = resources.get("Pattern") || Dict.empty
1479
+ const stateManager = new StateManager(initialState)
1480
+ const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager)
1481
+ const timeSlotManager = new TimeSlotManager()
1482
+
1483
+ function closePendingRestoreOPS( argument ) {
1484
+ for (let i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
1485
+ operatorList.addOp(OPS.restore, [])
1486
+ }
1487
+ }
1488
+
1489
+ return new Promise(function promiseBody( resolve, reject ) {
1490
+ const next = function( promise ) {
1491
+ Promise.all([promise, operatorList.ready]).then(function() {
1492
+ try {
1493
+ promiseBody(resolve, reject)
1494
+ } catch (ex) {
1495
+ reject(ex)
1496
+ }
1497
+ }, reject)
1498
+ }
1499
+ task.ensureNotTerminated()
1500
+ timeSlotManager.reset()
1501
+
1502
+ const operation = {}
1503
+ let stop, i, ii, cs, name, isValidName
1504
+ while ( !(stop = timeSlotManager.check())) {
1505
+ // The arguments parsed by read() are used beyond this loop, so we
1506
+ // cannot reuse the same array on each iteration. Therefore we pass
1507
+ // in |null| as the initial value (see the comment on
1508
+ // EvaluatorPreprocessor_read() for why).
1509
+ operation.args = null
1510
+ if ( !preprocessor.read(operation) ) {
1511
+ break
1512
+ }
1513
+ let args = operation.args
1514
+ let fn = operation.fn
1515
+
1516
+ switch (fn | 0) {
1517
+ case OPS.paintXObject:
1518
+ // eagerly compile XForm objects
1519
+ isValidName = args[0] instanceof Name
1520
+ name = args[0].name
1521
+
1522
+ if ( isValidName ) {
1523
+ const localImage = localImageCache.getByName(name)
1524
+ if ( localImage ) {
1525
+ operatorList.addImageOps(
1526
+ localImage.fn,
1527
+ localImage.args,
1528
+ localImage.optionalContent
1529
+ )
1530
+
1531
+ incrementCachedImageMaskCount(localImage)
1532
+ args = null
1533
+ continue
1534
+ }
1535
+ }
1536
+
1537
+ next(
1538
+ new Promise(function( resolveXObject, rejectXObject ) {
1539
+ if ( !isValidName ) {
1540
+ throw new FormatError("XObject must be referred to by name.")
1541
+ }
1542
+
1543
+ let xobj = xobjs.getRaw(name)
1544
+ if ( xobj instanceof Ref ) {
1545
+ const localImage =
1546
+ localImageCache.getByRef(xobj) ||
1547
+ self._regionalImageCache.getByRef(xobj)
1548
+ if ( localImage ) {
1549
+ operatorList.addImageOps(
1550
+ localImage.fn,
1551
+ localImage.args,
1552
+ localImage.optionalContent
1553
+ )
1554
+
1555
+ incrementCachedImageMaskCount(localImage)
1556
+ resolveXObject()
1557
+ return
1558
+ }
1559
+
1560
+ const globalImage = self.globalImageCache.getData(
1561
+ xobj,
1562
+ self.pageIndex
1563
+ )
1564
+ if ( globalImage ) {
1565
+ operatorList.addDependency(globalImage.objId)
1566
+ operatorList.addImageOps(
1567
+ globalImage.fn,
1568
+ globalImage.args,
1569
+ globalImage.optionalContent
1570
+ )
1571
+
1572
+ resolveXObject()
1573
+ return
1574
+ }
1575
+
1576
+ xobj = xref.fetch(xobj)
1577
+ }
1578
+
1579
+ if ( !(xobj instanceof BaseStream) ) {
1580
+ throw new FormatError("XObject should be a stream")
1581
+ }
1582
+
1583
+ const type = xobj.dict.get("Subtype")
1584
+ if ( !(type instanceof Name) ) {
1585
+ throw new FormatError("XObject should have a Name subtype")
1586
+ }
1587
+
1588
+ if ( type.name === "Form" ) {
1589
+ stateManager.save()
1590
+ self
1591
+ .buildFormXObject(
1592
+ resources,
1593
+ xobj,
1594
+ null,
1595
+ operatorList,
1596
+ task,
1597
+ stateManager.state.clone(),
1598
+ localColorSpaceCache
1599
+ )
1600
+ .then(function() {
1601
+ stateManager.restore()
1602
+ resolveXObject()
1603
+ }, rejectXObject)
1604
+ return
1605
+ } else if ( type.name === "Image" ) {
1606
+ self
1607
+ .buildPaintImageXObject({
1608
+ resources,
1609
+ image: xobj,
1610
+ operatorList,
1611
+ cacheKey: name,
1612
+ localImageCache,
1613
+ localColorSpaceCache
1614
+ })
1615
+ .then(resolveXObject, rejectXObject)
1616
+ return
1617
+ } else if ( type.name === "PS" ) {
1618
+ // PostScript XObjects are unused when viewing documents.
1619
+ // See section 4.7.1 of Adobe's PDF reference.
1620
+ // info("Ignored XObject subtype PS")
1621
+ } else {
1622
+ throw new FormatError(
1623
+ `Unhandled XObject subtype ${ type.name }`
1624
+ )
1625
+ }
1626
+ resolveXObject()
1627
+ }).catch(function( reason ) {
1628
+ if ( reason instanceof AbortException ) {
1629
+ return
1630
+ }
1631
+ if ( self.options.ignoreErrors ) {
1632
+ warn(`getOperatorList - ignoring XObject: "${ reason }".`)
1633
+ return
1634
+ }
1635
+ throw reason
1636
+ })
1637
+ )
1638
+ return
1639
+ case OPS.setFont:
1640
+ var fontSize = args[1]
1641
+ // eagerly collect all fonts
1642
+ next(
1643
+ self
1644
+ .handleSetFont(
1645
+ resources,
1646
+ args,
1647
+ null,
1648
+ operatorList,
1649
+ task,
1650
+ stateManager.state,
1651
+ fallbackFontDict
1652
+ )
1653
+ .then(function( loadedName ) {
1654
+ operatorList.addDependency(loadedName)
1655
+ operatorList.addOp(OPS.setFont, [loadedName, fontSize])
1656
+ })
1657
+ )
1658
+ return
1659
+ case OPS.beginText:
1660
+ parsingText = true
1661
+ break
1662
+ case OPS.endText:
1663
+ parsingText = false
1664
+ break
1665
+ case OPS.endInlineImage:
1666
+ var cacheKey = args[0].cacheKey
1667
+ if ( cacheKey ) {
1668
+ const localImage = localImageCache.getByName(cacheKey)
1669
+ if ( localImage ) {
1670
+ operatorList.addImageOps(
1671
+ localImage.fn,
1672
+ localImage.args,
1673
+ localImage.optionalContent
1674
+ )
1675
+
1676
+ incrementCachedImageMaskCount(localImage)
1677
+ args = null
1678
+ continue
1679
+ }
1680
+ }
1681
+ next(
1682
+ self.buildPaintImageXObject({
1683
+ resources,
1684
+ image: args[0],
1685
+ isInline: true,
1686
+ operatorList,
1687
+ cacheKey,
1688
+ localImageCache,
1689
+ localColorSpaceCache
1690
+ })
1691
+ )
1692
+ return
1693
+ case OPS.showText:
1694
+ if ( !stateManager.state.font ) {
1695
+ self.ensureStateFont(stateManager.state)
1696
+ continue
1697
+ }
1698
+ args[0] = self.handleText(args[0], stateManager.state)
1699
+ break
1700
+ case OPS.showSpacedText:
1701
+ if ( !stateManager.state.font ) {
1702
+ self.ensureStateFont(stateManager.state)
1703
+ continue
1704
+ }
1705
+ var combinedGlyphs = []
1706
+ var state = stateManager.state
1707
+ for (const arrItem of args[0]) {
1708
+ if ( typeof arrItem === "string" ) {
1709
+ combinedGlyphs.push(...self.handleText(arrItem, state))
1710
+ } else if ( typeof arrItem === "number" ) {
1711
+ combinedGlyphs.push(arrItem)
1712
+ }
1713
+ }
1714
+ // 这里是先将字符比如T转换成对应字体的符号fontChar,然后调用showText来绘制图形
1715
+ // 这里的Glyph对象包含了字符的图形显示 glyph
1716
+ args[0] = combinedGlyphs
1717
+ fn = OPS.showText
1718
+ break
1719
+ case OPS.nextLineShowText:
1720
+ if ( !stateManager.state.font ) {
1721
+ self.ensureStateFont(stateManager.state)
1722
+ continue
1723
+ }
1724
+ operatorList.addOp(OPS.nextLine)
1725
+ args[0] = self.handleText(args[0], stateManager.state)
1726
+ fn = OPS.showText
1727
+ break
1728
+ case OPS.nextLineSetSpacingShowText:
1729
+ if ( !stateManager.state.font ) {
1730
+ self.ensureStateFont(stateManager.state)
1731
+ continue
1732
+ }
1733
+ operatorList.addOp(OPS.nextLine)
1734
+ operatorList.addOp(OPS.setWordSpacing, [args.shift()])
1735
+ operatorList.addOp(OPS.setCharSpacing, [args.shift()])
1736
+ args[0] = self.handleText(args[0], stateManager.state)
1737
+ fn = OPS.showText
1738
+ break
1739
+ case OPS.setTextRenderingMode:
1740
+ stateManager.state.textRenderingMode = args[0]
1741
+ break
1742
+
1743
+ case OPS.setFillColorSpace: {
1744
+ const cachedColorSpace = ColorSpace.getCached(
1745
+ args[0],
1746
+ xref,
1747
+ localColorSpaceCache
1748
+ )
1749
+ if ( cachedColorSpace ) {
1750
+ stateManager.state.fillColorSpace = cachedColorSpace
1751
+ continue
1752
+ }
1753
+
1754
+ next(
1755
+ self
1756
+ .parseColorSpace({
1757
+ cs: args[0],
1758
+ resources,
1759
+ localColorSpaceCache
1760
+ })
1761
+ .then(function( colorSpace ) {
1762
+ if ( colorSpace ) {
1763
+ stateManager.state.fillColorSpace = colorSpace
1764
+ }
1765
+ })
1766
+ )
1767
+ return
1768
+ }
1769
+ case OPS.setStrokeColorSpace: {
1770
+ const cachedColorSpace = ColorSpace.getCached(
1771
+ args[0],
1772
+ xref,
1773
+ localColorSpaceCache
1774
+ )
1775
+ if ( cachedColorSpace ) {
1776
+ stateManager.state.strokeColorSpace = cachedColorSpace
1777
+ continue
1778
+ }
1779
+
1780
+ next(
1781
+ self
1782
+ .parseColorSpace({
1783
+ cs: args[0],
1784
+ resources,
1785
+ localColorSpaceCache
1786
+ })
1787
+ .then(function( colorSpace ) {
1788
+ if ( colorSpace ) {
1789
+ stateManager.state.strokeColorSpace = colorSpace
1790
+ }
1791
+ })
1792
+ )
1793
+ return
1794
+ }
1795
+ case OPS.setFillColor:
1796
+ cs = stateManager.state.fillColorSpace
1797
+ args = cs.getRgb(args, 0)
1798
+ fn = OPS.setFillRGBColor
1799
+ break
1800
+ case OPS.setStrokeColor:
1801
+ cs = stateManager.state.strokeColorSpace
1802
+ args = cs.getRgb(args, 0)
1803
+ fn = OPS.setStrokeRGBColor
1804
+ break
1805
+ case OPS.setFillGray:
1806
+ stateManager.state.fillColorSpace = ColorSpace.singletons.gray
1807
+ args = ColorSpace.singletons.gray.getRgb(args, 0)
1808
+ fn = OPS.setFillRGBColor
1809
+ break
1810
+ case OPS.setStrokeGray:
1811
+ stateManager.state.strokeColorSpace = ColorSpace.singletons.gray
1812
+ args = ColorSpace.singletons.gray.getRgb(args, 0)
1813
+ fn = OPS.setStrokeRGBColor
1814
+ break
1815
+ case OPS.setFillCMYKColor:
1816
+ stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk
1817
+ args = ColorSpace.singletons.cmyk.getRgb(args, 0)
1818
+ fn = OPS.setFillRGBColor
1819
+ break
1820
+ case OPS.setStrokeCMYKColor:
1821
+ stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk
1822
+ args = ColorSpace.singletons.cmyk.getRgb(args, 0)
1823
+ fn = OPS.setStrokeRGBColor
1824
+ break
1825
+ case OPS.setFillRGBColor:
1826
+ stateManager.state.fillColorSpace = ColorSpace.singletons.rgb
1827
+ args = ColorSpace.singletons.rgb.getRgb(args, 0)
1828
+ break
1829
+ case OPS.setStrokeRGBColor:
1830
+ stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb
1831
+ args = ColorSpace.singletons.rgb.getRgb(args, 0)
1832
+ break
1833
+ case OPS.setFillColorN:
1834
+ cs = stateManager.state.fillColorSpace
1835
+ if ( cs.name === "Pattern" ) {
1836
+ next(
1837
+ self.handleColorN(
1838
+ operatorList,
1839
+ OPS.setFillColorN,
1840
+ args,
1841
+ cs,
1842
+ patterns,
1843
+ resources,
1844
+ task,
1845
+ localColorSpaceCache,
1846
+ localTilingPatternCache,
1847
+ localShadingPatternCache
1848
+ )
1849
+ )
1850
+ return
1851
+ }
1852
+ args = cs.getRgb(args, 0)
1853
+ fn = OPS.setFillRGBColor
1854
+ break
1855
+ case OPS.setStrokeColorN:
1856
+ cs = stateManager.state.strokeColorSpace
1857
+ if ( cs.name === "Pattern" ) {
1858
+ next(
1859
+ self.handleColorN(
1860
+ operatorList,
1861
+ OPS.setStrokeColorN,
1862
+ args,
1863
+ cs,
1864
+ patterns,
1865
+ resources,
1866
+ task,
1867
+ localColorSpaceCache,
1868
+ localTilingPatternCache,
1869
+ localShadingPatternCache
1870
+ )
1871
+ )
1872
+ return
1873
+ }
1874
+ args = cs.getRgb(args, 0)
1875
+ fn = OPS.setStrokeRGBColor
1876
+ break
1877
+
1878
+ case OPS.shadingFill:
1879
+ var shadingRes = resources.get("Shading")
1880
+ if ( !shadingRes ) {
1881
+ throw new FormatError("No shading resource found")
1882
+ }
1883
+
1884
+ var shading = shadingRes.get(args[0].name)
1885
+ if ( !shading ) {
1886
+ throw new FormatError("No shading object found")
1887
+ }
1888
+ const patternId = self.parseShading({
1889
+ shading,
1890
+ resources,
1891
+ localColorSpaceCache,
1892
+ localShadingPatternCache
1893
+ })
1894
+ args = [patternId]
1895
+ fn = OPS.shadingFill
1896
+ break
1897
+ case OPS.setGState:
1898
+ isValidName = args[0] instanceof Name
1899
+ name = args[0].name
1900
+
1901
+ if ( isValidName ) {
1902
+ const localGStateObj = localGStateCache.getByName(name)
1903
+ if ( localGStateObj ) {
1904
+ if ( localGStateObj.length > 0 ) {
1905
+ operatorList.addOp(OPS.setGState, [localGStateObj])
1906
+ }
1907
+ args = null
1908
+ continue
1909
+ }
1910
+ }
1911
+
1912
+ next(
1913
+ new Promise(function( resolveGState, rejectGState ) {
1914
+ if ( !isValidName ) {
1915
+ throw new FormatError("GState must be referred to by name.")
1916
+ }
1917
+
1918
+ const extGState = resources.get("ExtGState")
1919
+ if ( !(extGState instanceof Dict) ) {
1920
+ throw new FormatError("ExtGState should be a dictionary.")
1921
+ }
1922
+
1923
+ const gState = extGState.get(name)
1924
+ // TODO: Attempt to lookup cached GStates by reference as well,
1925
+ // if and only if there are PDF documents where doing so
1926
+ // would significantly improve performance.
1927
+ if ( !(gState instanceof Dict) ) {
1928
+ throw new FormatError("GState should be a dictionary.")
1929
+ }
1930
+
1931
+ self
1932
+ .setGState({
1933
+ resources,
1934
+ gState,
1935
+ operatorList,
1936
+ cacheKey: name,
1937
+ task,
1938
+ stateManager,
1939
+ localGStateCache,
1940
+ localColorSpaceCache
1941
+ })
1942
+ .then(resolveGState, rejectGState)
1943
+ }).catch(function( reason ) {
1944
+ if ( reason instanceof AbortException ) {
1945
+ return
1946
+ }
1947
+ if ( self.options.ignoreErrors ) {
1948
+ warn(`getOperatorList - ignoring ExtGState: "${ reason }".`)
1949
+ return
1950
+ }
1951
+ throw reason
1952
+ })
1953
+ )
1954
+ return
1955
+ case OPS.moveTo:
1956
+ case OPS.lineTo:
1957
+ case OPS.curveTo:
1958
+ case OPS.curveTo2:
1959
+ case OPS.curveTo3:
1960
+ case OPS.closePath:
1961
+ case OPS.rectangle:
1962
+ self.buildPath(operatorList, fn, args, parsingText)
1963
+ continue
1964
+ case OPS.markPoint:
1965
+ case OPS.markPointProps:
1966
+ case OPS.beginCompat:
1967
+ case OPS.endCompat:
1968
+ // Ignore operators where the corresponding handlers are known to
1969
+ // be no-op in CanvasGraphics (display/canvas.js). This prevents
1970
+ // serialization errors and is also a bit more efficient.
1971
+ // We could also try to serialize all objects in a general way,
1972
+ // e.g. as done in https://github.com/mozilla/pdf.js/pull/6266,
1973
+ // but doing so is meaningless without knowing the semantics.
1974
+ continue
1975
+ case OPS.beginMarkedContentProps:
1976
+ if ( !(args[0] instanceof Name) ) {
1977
+ warn(`Expected name for beginMarkedContentProps arg0=${ args[0] }`)
1978
+ continue
1979
+ }
1980
+ if ( args[0].name === "OC" ) {
1981
+ next(
1982
+ self
1983
+ .parseMarkedContentProps(args[1], resources)
1984
+ .then(data => {
1985
+ operatorList.addOp(OPS.beginMarkedContentProps, [
1986
+ "OC",
1987
+ data
1988
+ ])
1989
+ })
1990
+ .catch(reason => {
1991
+ if ( reason instanceof AbortException ) {
1992
+ return
1993
+ }
1994
+ if ( self.options.ignoreErrors ) {
1995
+ warn(
1996
+ `getOperatorList - ignoring beginMarkedContentProps: "${ reason }".`
1997
+ )
1998
+ return
1999
+ }
2000
+ throw reason
2001
+ })
2002
+ )
2003
+ return
2004
+ }
2005
+ // Other marked content types aren't supported yet.
2006
+ args = [
2007
+ args[0].name,
2008
+ args[1] instanceof Dict ? args[1].get("MCID") : null
2009
+ ]
2010
+
2011
+ break
2012
+ case OPS.beginMarkedContent:
2013
+ case OPS.endMarkedContent:
2014
+ default:
2015
+ // Note: Ignore the operator if it has `Dict` arguments, since
2016
+ // those are non-serializable, otherwise postMessage will throw
2017
+ // "An object could not be cloned.".
2018
+ if ( args !== null ) {
2019
+ for (i = 0, ii = args.length; i < ii; i++) {
2020
+ if ( args[i] instanceof Dict ) {
2021
+ break
2022
+ }
2023
+ }
2024
+ if ( i < ii ) {
2025
+ warn("getOperatorList - ignoring operator: " + fn)
2026
+ continue
2027
+ }
2028
+ }
2029
+ }
2030
+ operatorList.addOp(fn, args) // 这里args是要渲染的glyphs的数组,包括了字母,然后中间有数字
2031
+ }
2032
+ if ( stop ) {
2033
+ next(deferred)
2034
+ return
2035
+ }
2036
+ // Some PDFs don't close all restores inside object/form.
2037
+ // Closing those for them.
2038
+ closePendingRestoreOPS()
2039
+ resolve()
2040
+ }).catch(reason => {
2041
+ if ( reason instanceof AbortException ) {
2042
+ return
2043
+ }
2044
+ if ( this.options.ignoreErrors ) {
2045
+ warn(
2046
+ `getOperatorList - ignoring errors during "${ task.name }" ` +
2047
+ `task: "${ reason }".`
2048
+ )
2049
+
2050
+ closePendingRestoreOPS()
2051
+ return
2052
+ }
2053
+ throw reason
2054
+ })
2055
+ }
2056
+
2057
+ async extractDataStructures( dict, properties ) {
2058
+ const xref = this.xref
2059
+ let cidToGidBytes
2060
+ // 9.10.2
2061
+ const toUnicodePromise = this.readToUnicode(properties.toUnicode)
2062
+
2063
+ if ( properties.composite ) {
2064
+ // CIDSystemInfo helps to match CID to glyphs
2065
+ const cidSystemInfo = dict.get("CIDSystemInfo")
2066
+ if ( cidSystemInfo instanceof Dict ) {
2067
+ properties.cidSystemInfo = {
2068
+ registry: stringToPDFString(cidSystemInfo.get("Registry")),
2069
+ ordering: stringToPDFString(cidSystemInfo.get("Ordering")),
2070
+ supplement: cidSystemInfo.get("Supplement")
2071
+ }
2072
+ }
2073
+
2074
+ try {
2075
+ const cidToGidMap = dict.get("CIDToGIDMap")
2076
+ if ( cidToGidMap instanceof BaseStream ) {
2077
+ cidToGidBytes = cidToGidMap.getBytes()
2078
+ }
2079
+ } catch (ex) {
2080
+ if ( !this.options.ignoreErrors ) {
2081
+ throw ex
2082
+ }
2083
+ warn(`extractDataStructures - ignoring CIDToGIDMap data: "${ ex }".`)
2084
+ }
2085
+ }
2086
+
2087
+ // Based on 9.6.6 of the spec the encoding can come from multiple places
2088
+ // and depends on the font type. The base encoding and differences are
2089
+ // read here, but the encoding that is actually used is chosen during
2090
+ // glyph mapping in the font.
2091
+ // TODO: Loading the built in encoding in the font would allow the
2092
+ // differences to be merged in here not require us to hold on to it.
2093
+ const differences = []
2094
+ let baseEncodingName = null
2095
+ let encoding
2096
+ // 这里是判断是否有Encoding这个属性,如果有则提取其中的differences和Encoding,如果没有这继续下面
2097
+ // 使用标准的encoding,比如StandardEncoding等,然后differences为空,ofd里面没有直接读取Encoding的
2098
+ // 所以直接不适用这里的代码,直接下面标准编码,并且有的文件里面包含了differences直接读取
2099
+ if ( dict.has("Encoding") ) {
2100
+ encoding = dict.get("Encoding")
2101
+ if ( encoding instanceof Dict ) {
2102
+ baseEncodingName = encoding.get("BaseEncoding")
2103
+ baseEncodingName =
2104
+ baseEncodingName instanceof Name ? baseEncodingName.name : null
2105
+ // Load the differences between the base and original
2106
+ if ( encoding.has("Differences") ) {
2107
+ const diffEncoding = encoding.get("Differences")
2108
+ let index = 0
2109
+ for (const entry of diffEncoding) {
2110
+ const data = xref.fetchIfRef(entry)
2111
+ if ( typeof data === "number" ) {
2112
+ index = data
2113
+ } else if ( data instanceof Name ) {
2114
+ differences[index++] = data.name
2115
+ } else {
2116
+ throw new FormatError(
2117
+ `Invalid entry in 'Differences' array: ${ data }`
2118
+ )
2119
+ }
2120
+ }
2121
+ }
2122
+ } else if ( encoding instanceof Name ) {
2123
+ baseEncodingName = encoding.name
2124
+ } else {
2125
+ const msg = "Encoding is not a Name nor a Dict"
2126
+
2127
+ if ( !this.options.ignoreErrors ) {
2128
+ throw new FormatError(msg)
2129
+ }
2130
+ warn(msg)
2131
+ }
2132
+ // According to table 114 if the encoding is a named encoding it must be
2133
+ // one of these predefined encodings.
2134
+ if (
2135
+ baseEncodingName !== "MacRomanEncoding" &&
2136
+ baseEncodingName !== "MacExpertEncoding" &&
2137
+ baseEncodingName !== "WinAnsiEncoding"
2138
+ ) {
2139
+ baseEncodingName = null
2140
+ }
2141
+ }
2142
+
2143
+ const nonEmbeddedFont = !properties.file || properties.isInternalFont,
2144
+ isSymbolsFontName = getSymbolsFonts()[properties.name]
2145
+ // Ignore an incorrectly specified named encoding for non-embedded
2146
+ // symbol fonts (fixes issue16464.pdf).
2147
+ if ( baseEncodingName && nonEmbeddedFont && isSymbolsFontName ) {
2148
+ baseEncodingName = null
2149
+ }
2150
+
2151
+ if ( baseEncodingName ) {
2152
+ properties.defaultEncoding = getEncoding(baseEncodingName)
2153
+ } else {
2154
+ const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic)
2155
+ const isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic)
2156
+ // According to "Table 114" in section "9.6.6.1 General" (under
2157
+ // "9.6.6 Character Encoding") of the PDF specification, a Nonsymbolic
2158
+ // font should use the `StandardEncoding` if no encoding is specified.
2159
+ encoding = StandardEncoding
2160
+ if ( properties.type === "TrueType" && !isNonsymbolicFont ) {
2161
+ encoding = WinAnsiEncoding
2162
+ }
2163
+ // The Symbolic attribute can be misused for regular fonts
2164
+ // Heuristic: we have to check if the font is a standard one also
2165
+ if ( isSymbolicFont || isSymbolsFontName ) {
2166
+ encoding = MacRomanEncoding
2167
+ if ( nonEmbeddedFont ) {
2168
+ if ( /Symbol/i.test(properties.name) ) {
2169
+ encoding = SymbolSetEncoding
2170
+ } else if ( /Dingbats/i.test(properties.name) ) {
2171
+ encoding = ZapfDingbatsEncoding
2172
+ } else if ( /Wingdings/i.test(properties.name) ) {
2173
+ encoding = WinAnsiEncoding
2174
+ }
2175
+ }
2176
+ }
2177
+ properties.defaultEncoding = encoding
2178
+ }
2179
+
2180
+ properties.differences = differences
2181
+ properties.baseEncodingName = baseEncodingName
2182
+ properties.hasEncoding = !!baseEncodingName || differences.length > 0
2183
+ properties.dict = dict
2184
+
2185
+ properties.toUnicode = await toUnicodePromise
2186
+
2187
+ const builtToUnicode = await this.buildToUnicode(properties)
2188
+ properties.toUnicode = builtToUnicode
2189
+
2190
+ if ( cidToGidBytes ) {
2191
+ properties.cidToGidMap = this.readCidToGidMap(
2192
+ cidToGidBytes,
2193
+ builtToUnicode
2194
+ )
2195
+ }
2196
+ return properties
2197
+ }
2198
+
2199
+ /**
2200
+ * @returns {Array}
2201
+ * @private
2202
+ */
2203
+ _simpleFontToUnicode( properties, forceGlyphs = false ) {
2204
+ assert( !properties.composite, "Must be a simple font.")
2205
+
2206
+ const toUnicode = []
2207
+ const encoding = properties.defaultEncoding.slice()
2208
+ const baseEncodingName = properties.baseEncodingName
2209
+ // Merge in the differences array.
2210
+ const differences = properties.differences
2211
+ for (const charcode in differences) {
2212
+ const glyphName = differences[charcode]
2213
+ if ( glyphName === ".notdef" ) {
2214
+ // Skip .notdef to prevent rendering errors, e.g. boxes appearing
2215
+ // where there should be spaces (fixes issue5256.pdf).
2216
+ continue
2217
+ }
2218
+ encoding[charcode] = glyphName
2219
+ }
2220
+ const glyphsUnicodeMap = getGlyphsUnicode()
2221
+ for (const charcode in encoding) {
2222
+ // a) Map the character code to a character name.
2223
+ let glyphName = encoding[charcode]
2224
+ if ( glyphName === "" ) {
2225
+ continue
2226
+ }
2227
+ // b) Look up the character name in the Adobe Glyph List (see the
2228
+ // Bibliography) to obtain the corresponding Unicode value.
2229
+ let unicode = glyphsUnicodeMap[glyphName]
2230
+ if ( unicode !== undefined ) {
2231
+ toUnicode[charcode] = String.fromCharCode(unicode)
2232
+ continue
2233
+ }
2234
+ // (undocumented) c) Few heuristics to recognize unknown glyphs
2235
+ // NOTE: Adobe Reader does not do this step, but OSX Preview does
2236
+ let code = 0
2237
+ switch (glyphName[0]) {
2238
+ case "G": // Gxx glyph
2239
+ if ( glyphName.length === 3 ) {
2240
+ code = parseInt(glyphName.substring(1), 16)
2241
+ }
2242
+ break
2243
+ case "g": // g00xx glyph
2244
+ if ( glyphName.length === 5 ) {
2245
+ code = parseInt(glyphName.substring(1), 16)
2246
+ }
2247
+ break
2248
+ case "C": // Cdd{d} glyph
2249
+ case "c": // cdd{d} glyph
2250
+ if ( glyphName.length >= 3 && glyphName.length <= 4 ) {
2251
+ const codeStr = glyphName.substring(1)
2252
+
2253
+ if ( forceGlyphs ) {
2254
+ code = parseInt(codeStr, 16)
2255
+ break
2256
+ }
2257
+ // Normally the Cdd{d}/cdd{d} glyphName format will contain
2258
+ // regular, i.e. base 10, charCodes (see issue4550.pdf)...
2259
+ code = +codeStr
2260
+
2261
+ // ... however some PDF generators violate that assumption by
2262
+ // containing glyph, i.e. base 16, codes instead.
2263
+ // In that case we need to re-parse the *entire* encoding to
2264
+ // prevent broken text-selection (fixes issue9655_reduced.pdf).
2265
+ if ( Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16)) ) {
2266
+ return this._simpleFontToUnicode(
2267
+ properties,
2268
+ /* forceGlyphs */ true
2269
+ )
2270
+ }
2271
+ }
2272
+ break
2273
+ case "u": // 'uniXXXX'/'uXXXX{XX}' glyphs
2274
+ unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap)
2275
+ if ( unicode !== -1 ) {
2276
+ code = unicode
2277
+ }
2278
+ break
2279
+ default:
2280
+ // Support (some) non-standard ligatures.
2281
+ switch (glyphName) {
2282
+ case "f_h":
2283
+ case "f_t":
2284
+ case "T_h":
2285
+ toUnicode[charcode] = glyphName.replaceAll("_", "")
2286
+ continue
2287
+ }
2288
+ break
2289
+ }
2290
+ if ( code > 0 && code <= 0x10ffff && Number.isInteger(code) ) {
2291
+ // If `baseEncodingName` is one the predefined encodings, and `code`
2292
+ // equals `charcode`, using the glyph defined in the baseEncoding
2293
+ // seems to yield a better `toUnicode` mapping (fixes issue 5070).
2294
+ if ( baseEncodingName && code === +charcode ) {
2295
+ const baseEncoding = getEncoding(baseEncodingName)
2296
+ if ( baseEncoding && (glyphName = baseEncoding[charcode]) ) {
2297
+ toUnicode[charcode] = String.fromCharCode(
2298
+ glyphsUnicodeMap[glyphName]
2299
+ )
2300
+ continue
2301
+ }
2302
+ }
2303
+ toUnicode[charcode] = String.fromCodePoint(code)
2304
+ }
2305
+ }
2306
+ return toUnicode
2307
+ }
2308
+
2309
+ /**
2310
+ * Builds a char code to unicode map based on section 9.10 of the spec.
2311
+ * @param {Object} properties Font properties object.
2312
+ * @returns {Promise} A Promise that is resolved with a
2313
+ * {ToUnicodeMap|IdentityToUnicodeMap} object.
2314
+ */
2315
+ async buildToUnicode( properties ) {
2316
+ properties.hasIncludedToUnicodeMap = properties.toUnicode?.length > 0
2317
+
2318
+ // Section 9.10.2 Mapping Character Codes to Unicode Values
2319
+ if ( properties.hasIncludedToUnicodeMap ) {
2320
+ // Some fonts contain incomplete ToUnicode data, causing issues with
2321
+ // text-extraction. For simple fonts, containing encoding information,
2322
+ // use a fallback ToUnicode map to improve this (fixes issue8229.pdf).
2323
+ if ( !properties.composite && properties.hasEncoding ) {
2324
+ properties.fallbackToUnicode = this._simpleFontToUnicode(properties)
2325
+ }
2326
+ return properties.toUnicode
2327
+ }
2328
+
2329
+ // According to the spec if the font is a simple font we should only map
2330
+ // to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
2331
+ // the differences array only contains adobe standard or symbol set names,
2332
+ // in pratice it seems better to always try to create a toUnicode map
2333
+ // based of the default encoding.
2334
+ if ( !properties.composite /* is simple font */ ) {
2335
+ return new ToUnicodeMap(this._simpleFontToUnicode(properties))
2336
+ }
2337
+
2338
+ // If the font is a composite font that uses one of the predefined CMaps
2339
+ // listed in Table 118 (except Identity–H and Identity–V) or whose
2340
+ // descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
2341
+ // Adobe-Korea1 character collection:
2342
+ if (
2343
+ properties.composite &&
2344
+ ((properties.cMap.builtInCMap &&
2345
+ !(properties.cMap instanceof IdentityCMap)) ||
2346
+ (properties.cidSystemInfo.registry === "Adobe" &&
2347
+ (properties.cidSystemInfo.ordering === "GB1" ||
2348
+ properties.cidSystemInfo.ordering === "CNS1" ||
2349
+ properties.cidSystemInfo.ordering === "Japan1" ||
2350
+ properties.cidSystemInfo.ordering === "Korea1")))
2351
+ ) {
2352
+ // Then:
2353
+ // a) Map the character code to a character identifier (CID) according
2354
+ // to the font’s CMap.
2355
+ // b) Obtain the registry and ordering of the character collection used
2356
+ // by the font’s CMap (for example, Adobe and Japan1) from its
2357
+ // CIDSystemInfo dictionary.
2358
+ const { registry, ordering } = properties.cidSystemInfo
2359
+ // c) Construct a second CMap name by concatenating the registry and
2360
+ // ordering obtained in step (b) in the format registry–ordering–UCS2
2361
+ // (for example, Adobe–Japan1–UCS2).
2362
+ const ucs2CMapName = Name.get(`${ registry }-${ ordering }-UCS2`)
2363
+ // d) Obtain the CMap with the name constructed in step (c) (available
2364
+ // from the ASN Web site; see the Bibliography).
2365
+ const ucs2CMap = await CMapFactory.create({
2366
+ encoding: ucs2CMapName,
2367
+ fetchBuiltInCMap: this._fetchBuiltInCMapBound,
2368
+ useCMap: null
2369
+ })
2370
+ const toUnicode = [],
2371
+ buf = []
2372
+ properties.cMap.forEach(function( charcode, cid ) {
2373
+ if ( cid > 0xffff ) {
2374
+ throw new FormatError("Max size of CID is 65,535")
2375
+ }
2376
+ // e) Map the CID obtained in step (a) according to the CMap
2377
+ // obtained in step (d), producing a Unicode value.
2378
+ const ucs2 = ucs2CMap.lookup(cid)
2379
+ if ( ucs2 ) {
2380
+ buf.length = 0
2381
+ // Support multi-byte entries (fixes issue16176.pdf).
2382
+ for (let i = 0, ii = ucs2.length; i < ii; i += 2) {
2383
+ buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1))
2384
+ }
2385
+ toUnicode[charcode] = String.fromCharCode(...buf)
2386
+ }
2387
+ })
2388
+ return new ToUnicodeMap(toUnicode)
2389
+ }
2390
+
2391
+ // The viewer's choice, just use an identity map.
2392
+ return new IdentityToUnicodeMap(properties.firstChar, properties.lastChar)
2393
+ }
2394
+
2395
+ async readToUnicode( cmapObj ) {
2396
+ if ( !cmapObj ) {
2397
+ return null
2398
+ }
2399
+ if ( cmapObj instanceof Name ) {
2400
+ const cmap = await CMapFactory.create({
2401
+ encoding: cmapObj,
2402
+ fetchBuiltInCMap: this._fetchBuiltInCMapBound,
2403
+ useCMap: null
2404
+ })
2405
+
2406
+ if ( cmap instanceof IdentityCMap ) {
2407
+ return new IdentityToUnicodeMap(0, 0xffff)
2408
+ }
2409
+ return new ToUnicodeMap(cmap.getMap())
2410
+ }
2411
+ if ( cmapObj instanceof BaseStream ) {
2412
+ try {
2413
+ const cmap = await CMapFactory.create({
2414
+ encoding: cmapObj,
2415
+ fetchBuiltInCMap: this._fetchBuiltInCMapBound,
2416
+ useCMap: null
2417
+ })
2418
+
2419
+ if ( cmap instanceof IdentityCMap ) {
2420
+ return new IdentityToUnicodeMap(0, 0xffff)
2421
+ }
2422
+ const map = new Array(cmap.length)
2423
+ // Convert UTF-16BE
2424
+ // NOTE: cmap can be a sparse array, so use forEach instead of
2425
+ // `for(;;)` to iterate over all keys.
2426
+ cmap.forEach(function( charCode, token ) {
2427
+ // Some cmaps contain *only* CID characters (fixes issue9367.pdf).
2428
+ if ( typeof token === "number" ) {
2429
+ map[charCode] = String.fromCodePoint(token)
2430
+ return
2431
+ }
2432
+ const str = []
2433
+ for (let k = 0; k < token.length; k += 2) {
2434
+ const w1 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1)
2435
+ if ( (w1 & 0xf800) !== 0xd800 ) {
2436
+ // w1 < 0xD800 || w1 > 0xDFFF
2437
+ str.push(w1)
2438
+ continue
2439
+ }
2440
+ k += 2
2441
+ const w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1)
2442
+ str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000)
2443
+ }
2444
+ map[charCode] = String.fromCodePoint(...str)
2445
+ })
2446
+ return new ToUnicodeMap(map)
2447
+ } catch (reason) {
2448
+ if ( reason instanceof AbortException ) {
2449
+ return null
2450
+ }
2451
+ if ( this.options.ignoreErrors ) {
2452
+ warn(`readToUnicode - ignoring ToUnicode data: "${ reason }".`)
2453
+ return null
2454
+ }
2455
+ throw reason
2456
+ }
2457
+ }
2458
+ return null
2459
+ }
2460
+
2461
+ readCidToGidMap( glyphsData, toUnicode ) {
2462
+ // Extract the encoding from the CIDToGIDMap
2463
+
2464
+ // Set encoding 0 to later verify the font has an encoding
2465
+ const result = []
2466
+ for (let j = 0, jj = glyphsData.length; j < jj; j++) {
2467
+ const glyphID = (glyphsData[j++] << 8) | glyphsData[j]
2468
+ const code = j >> 1
2469
+ if ( glyphID === 0 && !toUnicode.has(code) ) {
2470
+ continue
2471
+ }
2472
+ result[code] = glyphID
2473
+ }
2474
+ return result
2475
+ }
2476
+
2477
+ extractWidths( dict, descriptor, properties ) {
2478
+ const xref = this.xref
2479
+ let glyphsWidths = []
2480
+ let defaultWidth = 0
2481
+ const glyphsVMetrics = []
2482
+ let defaultVMetrics
2483
+ let i, ii, j, jj, start, code, widths
2484
+ if ( properties.composite ) {
2485
+ defaultWidth = dict.has("DW") ? dict.get("DW") : 1000
2486
+
2487
+ widths = dict.get("W")
2488
+ if ( widths ) {
2489
+ for (i = 0, ii = widths.length; i < ii; i++) {
2490
+ start = xref.fetchIfRef(widths[i++])
2491
+ code = xref.fetchIfRef(widths[i])
2492
+ if ( Array.isArray(code) ) {
2493
+ for (j = 0, jj = code.length; j < jj; j++) {
2494
+ glyphsWidths[start++] = xref.fetchIfRef(code[j])
2495
+ }
2496
+ } else {
2497
+ const width = xref.fetchIfRef(widths[++i])
2498
+ for (j = start; j <= code; j++) {
2499
+ glyphsWidths[j] = width
2500
+ }
2501
+ }
2502
+ }
2503
+ }
2504
+
2505
+ if ( properties.vertical ) {
2506
+ let vmetrics = dict.getArray("DW2") || [880, -1000]
2507
+ defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]]
2508
+ vmetrics = dict.get("W2")
2509
+ if ( vmetrics ) {
2510
+ for (i = 0, ii = vmetrics.length; i < ii; i++) {
2511
+ start = xref.fetchIfRef(vmetrics[i++])
2512
+ code = xref.fetchIfRef(vmetrics[i])
2513
+ if ( Array.isArray(code) ) {
2514
+ for (j = 0, jj = code.length; j < jj; j++) {
2515
+ glyphsVMetrics[start++] = [
2516
+ xref.fetchIfRef(code[j++]),
2517
+ xref.fetchIfRef(code[j++]),
2518
+ xref.fetchIfRef(code[j])
2519
+ ]
2520
+ }
2521
+ } else {
2522
+ const vmetric = [
2523
+ xref.fetchIfRef(vmetrics[++i]),
2524
+ xref.fetchIfRef(vmetrics[++i]),
2525
+ xref.fetchIfRef(vmetrics[++i])
2526
+ ]
2527
+ for (j = start; j <= code; j++) {
2528
+ glyphsVMetrics[j] = vmetric
2529
+ }
2530
+ }
2531
+ }
2532
+ }
2533
+ }
2534
+ } else {
2535
+ const firstChar = properties.firstChar
2536
+ widths = dict.get("Widths")
2537
+ if ( widths ) {
2538
+ j = firstChar
2539
+ for (i = 0, ii = widths.length; i < ii; i++) {
2540
+ glyphsWidths[j++] = xref.fetchIfRef(widths[i])
2541
+ }
2542
+ defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0
2543
+ } else {
2544
+ // 没有widths的情况,适用于ofd的情况,根据字体获取宽度
2545
+ // Trying get the BaseFont metrics (see comment above).
2546
+ const baseFontName = dict.get("BaseFont")
2547
+ if ( baseFontName instanceof Name ) {
2548
+ const metrics = this.getBaseFontMetrics(baseFontName.name)
2549
+
2550
+ glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties)
2551
+ defaultWidth = metrics.defaultWidth
2552
+ }
2553
+ }
2554
+ }
2555
+
2556
+ // Heuristic: detection of monospace font by checking all non-zero widths
2557
+ let isMonospace = true
2558
+ let firstWidth = defaultWidth
2559
+ for (const glyph in glyphsWidths) {
2560
+ const glyphWidth = glyphsWidths[glyph]
2561
+ if ( !glyphWidth ) {
2562
+ continue
2563
+ }
2564
+ if ( !firstWidth ) {
2565
+ firstWidth = glyphWidth
2566
+ continue
2567
+ }
2568
+ if ( firstWidth !== glyphWidth ) {
2569
+ isMonospace = false
2570
+ break
2571
+ }
2572
+ }
2573
+ if ( isMonospace ) {
2574
+ properties.flags |= FontFlags.FixedPitch
2575
+ } else {
2576
+ // Clear the flag.
2577
+ properties.flags &= ~FontFlags.FixedPitch
2578
+ }
2579
+
2580
+ properties.defaultWidth = defaultWidth
2581
+ properties.widths = glyphsWidths
2582
+ properties.defaultVMetrics = defaultVMetrics
2583
+ properties.vmetrics = glyphsVMetrics
2584
+ }
2585
+
2586
+ isSerifFont( baseFontName ) {
2587
+ // Simulating descriptor flags attribute
2588
+ const fontNameWoStyle = baseFontName.split("-", 1)[0]
2589
+ return (
2590
+ fontNameWoStyle in getSerifFonts() || /serif/gi.test(fontNameWoStyle)
2591
+ )
2592
+ }
2593
+
2594
+ getBaseFontMetrics( name ) {
2595
+ let defaultWidth = 0
2596
+ let widths = Object.create(null)
2597
+ let monospace = false
2598
+ const stdFontMap = getStdFontMap()
2599
+ let lookupName = stdFontMap[name] || name
2600
+ const Metrics = getMetrics()
2601
+
2602
+ if ( !(lookupName in Metrics) ) {
2603
+ // Use default fonts for looking up font metrics if the passed
2604
+ // font is not a base font
2605
+ lookupName = this.isSerifFont(name) ? "Times-Roman" : "Helvetica"
2606
+ }
2607
+ const glyphWidths = Metrics[lookupName]
2608
+
2609
+ if ( typeof glyphWidths === "number" ) {
2610
+ defaultWidth = glyphWidths
2611
+ monospace = true
2612
+ } else {
2613
+ widths = glyphWidths() // expand lazy widths array
2614
+ }
2615
+
2616
+ return {
2617
+ defaultWidth,
2618
+ monospace,
2619
+ widths
2620
+ }
2621
+ }
2622
+
2623
+ buildCharCodeToWidth( widthsByGlyphName, properties ) {
2624
+ const widths = Object.create(null)
2625
+ const differences = properties.differences
2626
+ const encoding = properties.defaultEncoding
2627
+ for (let charCode = 0; charCode < 256; charCode++) {
2628
+ if ( charCode in differences && widthsByGlyphName[differences[charCode]] ) {
2629
+ widths[charCode] = widthsByGlyphName[differences[charCode]]
2630
+ continue
2631
+ }
2632
+ if ( charCode in encoding && widthsByGlyphName[encoding[charCode]] ) {
2633
+ widths[charCode] = widthsByGlyphName[encoding[charCode]]
2634
+ continue
2635
+ }
2636
+ }
2637
+ return widths
2638
+ }
2639
+
2640
+ preEvaluateFont( dict ) {
2641
+ const baseDict = dict
2642
+ let type = dict.get("Subtype")
2643
+ if ( !(type instanceof Name) ) {
2644
+ throw new FormatError("invalid font Subtype")
2645
+ }
2646
+
2647
+ let composite = false
2648
+ let hash
2649
+ // type0的字体,包含了子字体,他的内容再descendantFonts里面
2650
+ if ( type.name === "Type0" ) {
2651
+ // If font is a composite
2652
+ // - get the descendant font
2653
+ // - set the type according to the descendant font
2654
+ // - get the FontDescriptor from the descendant font
2655
+ const df = dict.get("DescendantFonts")
2656
+ if ( !df ) {
2657
+ throw new FormatError("Descendant fonts are not specified")
2658
+ }
2659
+ dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df // 这里从交叉表中能拿到本地字体的数据,就是在pdf中的字体数据
2660
+
2661
+ if ( !(dict instanceof Dict) ) {
2662
+ throw new FormatError("Descendant font is not a dictionary.")
2663
+ }
2664
+ type = dict.get("Subtype")
2665
+ if ( !(type instanceof Name) ) {
2666
+ throw new FormatError("invalid font Subtype")
2667
+ }
2668
+ composite = true
2669
+ }
2670
+
2671
+ const firstChar = dict.get("FirstChar") || 0,
2672
+ lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff) // 默认最后一个值是65535
2673
+ const descriptor = dict.get("FontDescriptor")
2674
+ const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode")
2675
+
2676
+ if ( descriptor ) {
2677
+ hash = new MurmurHash3_64()
2678
+
2679
+ const encoding = baseDict.getRaw("Encoding")
2680
+ if ( encoding instanceof Name ) {
2681
+ hash.update(encoding.name)
2682
+ } else if ( encoding instanceof Ref ) {
2683
+ hash.update(encoding.toString())
2684
+ } else if ( encoding instanceof Dict ) {
2685
+ for (const entry of encoding.getRawValues()) {
2686
+ if ( entry instanceof Name ) {
2687
+ hash.update(entry.name)
2688
+ } else if ( entry instanceof Ref ) {
2689
+ hash.update(entry.toString())
2690
+ } else if ( Array.isArray(entry) ) {
2691
+ // 'Differences' array (fixes bug1157493.pdf).
2692
+ const diffLength = entry.length,
2693
+ diffBuf = new Array(diffLength)
2694
+
2695
+ for (let j = 0; j < diffLength; j++) {
2696
+ const diffEntry = entry[j]
2697
+ if ( diffEntry instanceof Name ) {
2698
+ diffBuf[j] = diffEntry.name
2699
+ } else if (
2700
+ typeof diffEntry === "number" ||
2701
+ diffEntry instanceof Ref
2702
+ ) {
2703
+ diffBuf[j] = diffEntry.toString()
2704
+ }
2705
+ }
2706
+ hash.update(diffBuf.join())
2707
+ }
2708
+ }
2709
+ }
2710
+
2711
+ hash.update(`${ firstChar }-${ lastChar }`) // Fixes issue10665_reduced.pdf
2712
+
2713
+ // 这里是提前对字体数据做处理,将读取的unit8Array做hash处理
2714
+ if ( descriptor.objId === "29R" ) debugger
2715
+ if ( toUnicode instanceof BaseStream ) {
2716
+ const stream = toUnicode.str || toUnicode
2717
+ // 提取字体的数据,从start到end的位置数据,从buffer中读取
2718
+ const uint8array = stream.buffer
2719
+ ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength)
2720
+ : new Uint8Array(
2721
+ stream.bytes.buffer,
2722
+ stream.start,
2723
+ stream.end - stream.start
2724
+ )
2725
+ hash.update(uint8array)
2726
+ } else if ( toUnicode instanceof Name ) {
2727
+ hash.update(toUnicode.name)
2728
+ }
2729
+
2730
+ const widths = dict.get("Widths") || baseDict.get("Widths")
2731
+ if ( Array.isArray(widths) ) {
2732
+ const widthsBuf = []
2733
+ for (const entry of widths) {
2734
+ if ( typeof entry === "number" || entry instanceof Ref ) {
2735
+ widthsBuf.push(entry.toString())
2736
+ }
2737
+ }
2738
+ hash.update(widthsBuf.join())
2739
+ }
2740
+
2741
+ if ( composite ) {
2742
+ hash.update("compositeFont")
2743
+
2744
+ const compositeWidths = dict.get("W") || baseDict.get("W")
2745
+ if ( Array.isArray(compositeWidths) ) {
2746
+ const widthsBuf = []
2747
+ for (const entry of compositeWidths) {
2748
+ if ( typeof entry === "number" || entry instanceof Ref ) {
2749
+ widthsBuf.push(entry.toString())
2750
+ } else if ( Array.isArray(entry) ) {
2751
+ const subWidthsBuf = []
2752
+ for (const element of entry) {
2753
+ if ( typeof element === "number" || element instanceof Ref ) {
2754
+ subWidthsBuf.push(element.toString())
2755
+ }
2756
+ }
2757
+ widthsBuf.push(`[${ subWidthsBuf.join() }]`)
2758
+ }
2759
+ }
2760
+ hash.update(widthsBuf.join())
2761
+ }
2762
+
2763
+ const cidToGidMap =
2764
+ dict.getRaw("CIDToGIDMap") || baseDict.getRaw("CIDToGIDMap")
2765
+ if ( cidToGidMap instanceof Name ) {
2766
+ hash.update(cidToGidMap.name)
2767
+ } else if ( cidToGidMap instanceof Ref ) {
2768
+ hash.update(cidToGidMap.toString())
2769
+ } else if ( cidToGidMap instanceof BaseStream ) {
2770
+ hash.update(cidToGidMap.peekBytes())
2771
+ }
2772
+ }
2773
+ }
2774
+
2775
+ return {
2776
+ descriptor,
2777
+ dict,
2778
+ baseDict,
2779
+ composite,
2780
+ type: type.name,
2781
+ firstChar,
2782
+ lastChar,
2783
+ toUnicode,
2784
+ hash: hash ? hash.hexdigest() : ""
2785
+ }
2786
+ }
2787
+
2788
+ async translateFont( { descriptor, dict, baseDict, composite, type, firstChar, lastChar, toUnicode, cssFontInfo } ) {
2789
+ const isType3Font = type === "Type3"
2790
+ // 如果pdf中不包含descriptor,那么就创建一个心的,这里适合ofd文档,就是创建心的descriptor
2791
+ // 也就是新建properties对象
2792
+ if ( !descriptor ) {
2793
+ if ( isType3Font ) {
2794
+ // FontDescriptor is only required for Type3 fonts when the document
2795
+ // is a tagged pdf. Create a barbebones one to get by.
2796
+ descriptor = new Dict(null)
2797
+ descriptor.set("FontName", Name.get(type))
2798
+ descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0])
2799
+ } else {
2800
+ // Before PDF 1.5 if the font was one of the base 14 fonts, having a
2801
+ // FontDescriptor was not required.
2802
+ // This case is here for compatibility.
2803
+ let baseFontName = dict.get("BaseFont")
2804
+ if ( !(baseFontName instanceof Name) ) {
2805
+ throw new FormatError("Base font is not specified")
2806
+ }
2807
+
2808
+ // Using base font name as a font name.
2809
+ baseFontName = baseFontName.name.replaceAll(/[,_]/g, "-")
2810
+ const metrics = this.getBaseFontMetrics(baseFontName)
2811
+
2812
+ // Simulating descriptor flags attribute
2813
+ const fontNameWoStyle = baseFontName.split("-", 1)[0]
2814
+ const flags =
2815
+ (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) |
2816
+ (metrics.monospace ? FontFlags.FixedPitch : 0) |
2817
+ (getSymbolsFonts()[fontNameWoStyle]
2818
+ ? FontFlags.Symbolic
2819
+ : FontFlags.Nonsymbolic)
2820
+
2821
+ // 没有descriptor情况下生成的properties内容,这里是ofd可以使用的,所以还是要加上properties
2822
+ const properties = {
2823
+ type,
2824
+ name: baseFontName,
2825
+ loadedName: baseDict.loadedName,
2826
+ systemFontInfo: null,
2827
+ widths: metrics.widths,
2828
+ defaultWidth: metrics.defaultWidth,
2829
+ isSimulatedFlags: true,
2830
+ flags,
2831
+ firstChar,
2832
+ lastChar,
2833
+ toUnicode,
2834
+ xHeight: 0,
2835
+ capHeight: 0,
2836
+ italicAngle: 0,
2837
+ isType3Font
2838
+ }
2839
+ const widths = dict.get("Widths")
2840
+
2841
+ const standardFontName = getStandardFontName(baseFontName)
2842
+ let file = null
2843
+ if ( standardFontName ) {
2844
+ file = await this.fetchStandardFontData(standardFontName)
2845
+ properties.isInternalFont = !!file
2846
+ }
2847
+ if ( !properties.isInternalFont && this.options.useSystemFonts ) {
2848
+ properties.systemFontInfo = getFontSubstitution(
2849
+ this.systemFontCache,
2850
+ this.idFactory,
2851
+ this.options.standardFontDataUrl,
2852
+ baseFontName,
2853
+ standardFontName
2854
+ )
2855
+ }
2856
+
2857
+ const newProperties = await this.extractDataStructures(
2858
+ dict,
2859
+ properties
2860
+ )
2861
+ if ( widths ) {
2862
+ const glyphWidths = []
2863
+ let j = firstChar
2864
+ for (const width of widths) {
2865
+ glyphWidths[j++] = this.xref.fetchIfRef(width)
2866
+ }
2867
+ newProperties.widths = glyphWidths
2868
+ } else {
2869
+ newProperties.widths = this.buildCharCodeToWidth(
2870
+ metrics.widths,
2871
+ newProperties
2872
+ )
2873
+ }
2874
+ return new Font(baseFontName, file, newProperties)
2875
+ }
2876
+ }
2877
+
2878
+ // According to the spec if 'FontDescriptor' is declared, 'FirstChar',
2879
+ // 'LastChar' and 'Widths' should exist too, but some PDF encoders seem
2880
+ // to ignore this rule when a variant of a standard font is used.
2881
+ // TODO Fill the width array depending on which of the base font this is
2882
+ // a variant.
2883
+
2884
+ let fontName = descriptor.get("FontName")
2885
+ let baseFont = dict.get("BaseFont")
2886
+ // Some bad PDFs have a string as the font name.
2887
+ if ( typeof fontName === "string" ) {
2888
+ fontName = Name.get(fontName)
2889
+ }
2890
+ if ( typeof baseFont === "string" ) {
2891
+ baseFont = Name.get(baseFont)
2892
+ }
2893
+
2894
+ const fontNameStr = fontName?.name
2895
+ const baseFontStr = baseFont?.name
2896
+ if ( !isType3Font && fontNameStr !== baseFontStr ) {
2897
+ // info(
2898
+ // `The FontDescriptor's FontName is "${ fontNameStr }" but ` +
2899
+ // `should be the same as the Font's BaseFont "${ baseFontStr }".`
2900
+ // )
2901
+ // - Workaround for cases where e.g. fontNameStr = 'Arial' and
2902
+ // baseFontStr = 'Arial,Bold' (needed when no font file is embedded).
2903
+ //
2904
+ // - Workaround for cases where e.g. fontNameStr = 'wg09np' and
2905
+ // baseFontStr = 'Wingdings-Regular' (fixes issue7454.pdf).
2906
+ if (
2907
+ fontNameStr &&
2908
+ baseFontStr &&
2909
+ (baseFontStr.startsWith(fontNameStr) ||
2910
+ ( !isKnownFontName(fontNameStr) && isKnownFontName(baseFontStr)))
2911
+ ) {
2912
+ fontName = null
2913
+ }
2914
+ }
2915
+ fontName ||= baseFont
2916
+
2917
+ if ( !(fontName instanceof Name) ) {
2918
+ throw new FormatError("invalid font name")
2919
+ }
2920
+
2921
+ let fontFile, subtype, length1, length2, length3
2922
+ try {
2923
+ // 这里拿到的是FontFile的引用位置,还不是实际数据
2924
+ fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3") // 从FontFile/FontFile2/FontFile3中取数据
2925
+ } catch (ex) {
2926
+ if ( !this.options.ignoreErrors ) {
2927
+ throw ex
2928
+ }
2929
+ warn(`translateFont - fetching "${ fontName.name }" font file: "${ ex }".`)
2930
+ fontFile = new NullStream()
2931
+ }
2932
+ let isInternalFont = false
2933
+ let glyphScaleFactors = null
2934
+ let systemFontInfo = null
2935
+ if ( fontFile ) {
2936
+ if ( fontFile.dict ) {
2937
+ const subtypeEntry = fontFile.dict.get("Subtype")
2938
+ if ( subtypeEntry instanceof Name ) {
2939
+ subtype = subtypeEntry.name
2940
+ }
2941
+ length1 = fontFile.dict.get("Length1")
2942
+ length2 = fontFile.dict.get("Length2")
2943
+ length3 = fontFile.dict.get("Length3")
2944
+ }
2945
+ } else if ( cssFontInfo ) {
2946
+ // We've a missing XFA font.
2947
+ const standardFontName = getXfaFontName(fontName.name)
2948
+ if ( standardFontName ) {
2949
+ cssFontInfo.fontFamily = `${ cssFontInfo.fontFamily }-PdfJS-XFA`
2950
+ cssFontInfo.metrics = standardFontName.metrics || null
2951
+ glyphScaleFactors = standardFontName.factors || null
2952
+ fontFile = await this.fetchStandardFontData(standardFontName.name)
2953
+ isInternalFont = !!fontFile
2954
+
2955
+ // We're using a substitution font but for example widths (if any)
2956
+ // are related to the glyph positions in the font.
2957
+ // So we overwrite everything here to be sure that widths are
2958
+ // correct.
2959
+ baseDict = dict = getXfaFontDict(fontName.name)
2960
+ composite = true
2961
+ }
2962
+ } else if ( !isType3Font ) {
2963
+ const standardFontName = getStandardFontName(fontName.name)
2964
+ if ( standardFontName ) {
2965
+ fontFile = await this.fetchStandardFontData(standardFontName)
2966
+ isInternalFont = !!fontFile
2967
+ }
2968
+ if ( !isInternalFont && this.options.useSystemFonts ) {
2969
+ systemFontInfo = getFontSubstitution(
2970
+ this.systemFontCache,
2971
+ this.idFactory,
2972
+ this.options.standardFontDataUrl,
2973
+ fontName.name,
2974
+ standardFontName
2975
+ )
2976
+ }
2977
+ }
2978
+
2979
+ const properties = {
2980
+ type,
2981
+ name: fontName.name,
2982
+ subtype,
2983
+ file: fontFile,
2984
+ length1,
2985
+ length2,
2986
+ length3,
2987
+ isInternalFont,
2988
+ loadedName: baseDict.loadedName,
2989
+ composite,
2990
+ fixedPitch: false,
2991
+ fontMatrix: dict.getArray("FontMatrix") || FONT_IDENTITY_MATRIX,
2992
+ firstChar,
2993
+ lastChar,
2994
+ toUnicode,
2995
+ bbox: descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
2996
+ ascent: descriptor.get("Ascent"),
2997
+ descent: descriptor.get("Descent"),
2998
+ xHeight: descriptor.get("XHeight") || 0,
2999
+ capHeight: descriptor.get("CapHeight") || 0,
3000
+ flags: descriptor.get("Flags"),
3001
+ italicAngle: descriptor.get("ItalicAngle") || 0,
3002
+ isType3Font,
3003
+ cssFontInfo,
3004
+ scaleFactors: glyphScaleFactors,
3005
+ systemFontInfo
3006
+ }
3007
+
3008
+ if ( composite ) {
3009
+ const cidEncoding = baseDict.get("Encoding")
3010
+ if ( cidEncoding instanceof Name ) {
3011
+ properties.cidEncoding = cidEncoding.name
3012
+ }
3013
+ const cMap = await CMapFactory.create({
3014
+ encoding: cidEncoding,
3015
+ fetchBuiltInCMap: this._fetchBuiltInCMapBound,
3016
+ useCMap: null
3017
+ })
3018
+ properties.cMap = cMap
3019
+ properties.vertical = properties.cMap.vertical
3020
+ }
3021
+ if ( fontName.name === "TACTGM+NimbusRomNo9L-Medi" ) {
3022
+ // debugger
3023
+ }
3024
+ // 这里是提取Encoding和differences
3025
+ const newProperties = await this.extractDataStructures(dict, properties)
3026
+ // 这里是提取widths,字体的字符的宽度
3027
+ this.extractWidths(dict, descriptor, newProperties)
3028
+ // 这里是加载字体文件的数据,data里面包含字体数据
3029
+ if ( fontName.name === "TACTGM+NimbusRomNo9L-Medi" ) {
3030
+ // debugger
3031
+ }
3032
+ return new Font(fontName.name, fontFile, newProperties) // 这里是生成字体的描述文件,还没有开始加载,再Font的构造函数中会加载到字体的data数据
3033
+ }
3034
+
3035
+ static buildFontPaths( font, glyphs, handler, evaluatorOptions ) {
3036
+ function buildPath( fontChar ) {
3037
+ const glyphName = `${ font.loadedName }_path_${ fontChar }`
3038
+ try {
3039
+ if ( font.renderer.hasBuiltPath(fontChar) ) {
3040
+ return
3041
+ }
3042
+ handler.send("commonobj", [
3043
+ glyphName,
3044
+ "FontPath",
3045
+ font.renderer.getPathJs(fontChar)
3046
+ ])
3047
+ } catch (reason) {
3048
+ if ( evaluatorOptions.ignoreErrors ) {
3049
+ warn(`buildFontPaths - ignoring ${ glyphName } glyph: "${ reason }".`)
3050
+ return
3051
+ }
3052
+ throw reason
3053
+ }
3054
+ }
3055
+
3056
+ for (const glyph of glyphs) {
3057
+ buildPath(glyph.fontChar)
3058
+
3059
+ // If the glyph has an accent we need to build a path for its
3060
+ // fontChar too, otherwise CanvasGraphics_paintChar will fail.
3061
+ const accent = glyph.accent
3062
+ if ( accent?.fontChar ) {
3063
+ buildPath(accent.fontChar)
3064
+ }
3065
+ }
3066
+ }
3067
+
3068
+ static get fallbackFontDict() {
3069
+ const dict = new Dict()
3070
+ dict.set("BaseFont", Name.get("Helvetica"))
3071
+ dict.set("Type", Name.get("FallbackType"))
3072
+ dict.set("Subtype", Name.get("FallbackType"))
3073
+ dict.set("Encoding", Name.get("WinAnsiEncoding"))
3074
+
3075
+ return shadow(this, "fallbackFontDict", dict)
3076
+ }
3077
+ }
3078
+
3079
+ class TranslatedFont {
3080
+ constructor( { loadedName, font, dict, evaluatorOptions } ) {
3081
+ this.loadedName = loadedName
3082
+ this.font = font
3083
+ this.dict = dict
3084
+ this._evaluatorOptions = evaluatorOptions || DefaultPartialEvaluatorOptions
3085
+ this.type3Loaded = null
3086
+ this.type3Dependencies = font.isType3Font ? new Set() : null
3087
+ this.sent = false
3088
+ }
3089
+
3090
+ // 字体加载完成之后发送消息进行下一步处理
3091
+ send( handler ) {
3092
+ if ( this.sent ) {
3093
+ return
3094
+ }
3095
+ this.sent = true
3096
+
3097
+ handler.send("commonobj", [
3098
+ this.loadedName,
3099
+ "Font",
3100
+ this.font.exportData(this._evaluatorOptions.fontExtraProperties)
3101
+ ])
3102
+ }
3103
+
3104
+ fallback( handler ) {
3105
+ if ( !this.font.data ) {
3106
+ return
3107
+ }
3108
+ // When font loading failed, fall back to the built-in font renderer.
3109
+ this.font.disableFontFace = true
3110
+ // An arbitrary number of text rendering operators could have been
3111
+ // encountered between the point in time when the 'Font' message was sent
3112
+ // to the main-thread, and the point in time when the 'FontFallback'
3113
+ // message was received on the worker-thread.
3114
+ // To ensure that all 'FontPath's are available on the main-thread, when
3115
+ // font loading failed, attempt to resend *all* previously parsed glyphs.
3116
+ PartialEvaluator.buildFontPaths(
3117
+ this.font,
3118
+ /* glyphs = */ this.font.glyphCacheValues,
3119
+ handler,
3120
+ this._evaluatorOptions
3121
+ )
3122
+ }
3123
+ }
3124
+
3125
+ export {TranslatedFont};