pdf-codec 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +36 -3
  2. package/dist/assets/caladea-bold.cjs +5 -0
  3. package/dist/assets/caladea-bold.d.cts +4 -0
  4. package/dist/assets/caladea-bold.d.ts +4 -0
  5. package/dist/assets/caladea-bold.js +4 -0
  6. package/dist/assets/caladea-bolditalic.cjs +5 -0
  7. package/dist/assets/caladea-bolditalic.d.cts +4 -0
  8. package/dist/assets/caladea-bolditalic.d.ts +4 -0
  9. package/dist/assets/caladea-bolditalic.js +4 -0
  10. package/dist/assets/caladea-italic.cjs +5 -0
  11. package/dist/assets/caladea-italic.d.cts +4 -0
  12. package/dist/assets/caladea-italic.d.ts +4 -0
  13. package/dist/assets/caladea-italic.js +4 -0
  14. package/dist/assets/caladea-regular.cjs +5 -0
  15. package/dist/assets/caladea-regular.d.cts +4 -0
  16. package/dist/assets/caladea-regular.d.ts +4 -0
  17. package/dist/assets/caladea-regular.js +4 -0
  18. package/dist/assets/carlito-bold.cjs +5 -0
  19. package/dist/assets/carlito-bold.d.cts +4 -0
  20. package/dist/assets/carlito-bold.d.ts +4 -0
  21. package/dist/assets/carlito-bold.js +4 -0
  22. package/dist/assets/carlito-bolditalic.cjs +5 -0
  23. package/dist/assets/carlito-bolditalic.d.cts +4 -0
  24. package/dist/assets/carlito-bolditalic.d.ts +4 -0
  25. package/dist/assets/carlito-bolditalic.js +4 -0
  26. package/dist/assets/carlito-italic.cjs +5 -0
  27. package/dist/assets/carlito-italic.d.cts +4 -0
  28. package/dist/assets/carlito-italic.d.ts +4 -0
  29. package/dist/assets/carlito-italic.js +4 -0
  30. package/dist/assets/carlito-regular.cjs +5 -0
  31. package/dist/assets/carlito-regular.d.cts +4 -0
  32. package/dist/assets/carlito-regular.d.ts +4 -0
  33. package/dist/assets/carlito-regular.js +4 -0
  34. package/dist/cff-probe.cjs +133 -0
  35. package/dist/cff-probe.d.cts +10 -0
  36. package/dist/cff-probe.d.ts +10 -0
  37. package/dist/cff-probe.js +132 -0
  38. package/dist/cmap-table.cjs +108 -0
  39. package/dist/cmap-table.d.cts +6 -0
  40. package/dist/cmap-table.d.ts +6 -0
  41. package/dist/cmap-table.js +107 -0
  42. package/dist/content-write.cjs +34 -14
  43. package/dist/content-write.d.cts +9 -2
  44. package/dist/content-write.d.ts +9 -2
  45. package/dist/content-write.js +34 -14
  46. package/dist/embedded-font-CLedn-mT.d.cts +42 -0
  47. package/dist/embedded-font-CbqkKgBl.d.ts +42 -0
  48. package/dist/embedded-font-write.cjs +92 -0
  49. package/dist/embedded-font-write.d.cts +22 -0
  50. package/dist/embedded-font-write.d.ts +22 -0
  51. package/dist/embedded-font-write.js +90 -0
  52. package/dist/embedded-font.cjs +142 -0
  53. package/dist/embedded-font.d.cts +2 -0
  54. package/dist/embedded-font.d.ts +2 -0
  55. package/dist/embedded-font.js +138 -0
  56. package/dist/font-registry-Cn7P9lAh.d.ts +38 -0
  57. package/dist/font-registry-yby02snZ.d.cts +38 -0
  58. package/dist/font-registry.cjs +152 -0
  59. package/dist/font-registry.d.cts +2 -0
  60. package/dist/font-registry.d.ts +2 -0
  61. package/dist/font-registry.js +150 -0
  62. package/dist/font-substitutes.cjs +13 -0
  63. package/dist/font-substitutes.d.cts +5 -0
  64. package/dist/font-substitutes.d.ts +5 -0
  65. package/dist/font-substitutes.js +12 -0
  66. package/dist/font-tables.cjs +127 -0
  67. package/dist/font-tables.d.cts +43 -0
  68. package/dist/font-tables.d.ts +43 -0
  69. package/dist/font-tables.js +122 -0
  70. package/dist/fonts.cjs +1 -0
  71. package/dist/fonts.d.cts +2 -1
  72. package/dist/fonts.d.ts +2 -1
  73. package/dist/fonts.js +1 -1
  74. package/dist/glyf.cjs +127 -0
  75. package/dist/glyf.d.cts +31 -0
  76. package/dist/glyf.d.ts +31 -0
  77. package/dist/glyf.js +125 -0
  78. package/dist/{math-hmtx.cjs → hmtx-table.cjs} +3 -3
  79. package/dist/{math-hmtx.d.ts → hmtx-table.d.cts} +2 -2
  80. package/dist/{math-hmtx.d.cts → hmtx-table.d.ts} +2 -2
  81. package/dist/{math-hmtx.js → hmtx-table.js} +3 -3
  82. package/dist/index.cjs +5 -0
  83. package/dist/index.d.cts +4 -2
  84. package/dist/index.d.ts +4 -2
  85. package/dist/index.js +3 -2
  86. package/dist/math-font-write.cjs +2 -31
  87. package/dist/math-font-write.js +1 -30
  88. package/dist/math-font.cjs +7 -5
  89. package/dist/math-font.js +5 -3
  90. package/dist/math-table.d.cts +1 -1
  91. package/dist/math-table.d.ts +1 -1
  92. package/dist/measure.cjs +65 -14
  93. package/dist/measure.d.cts +8 -1
  94. package/dist/measure.d.ts +8 -1
  95. package/dist/measure.js +64 -15
  96. package/dist/sfnt-V08bb5ut.d.cts +21 -0
  97. package/dist/sfnt-V08bb5ut.d.ts +21 -0
  98. package/dist/sfnt-subset.cjs +250 -0
  99. package/dist/sfnt-subset.d.cts +11 -0
  100. package/dist/sfnt-subset.d.ts +11 -0
  101. package/dist/sfnt-subset.js +249 -0
  102. package/dist/sfnt.cjs +50 -4
  103. package/dist/sfnt.d.cts +2 -17
  104. package/dist/sfnt.d.ts +2 -17
  105. package/dist/sfnt.js +47 -5
  106. package/dist/tounicode.cjs +34 -0
  107. package/dist/tounicode.d.cts +5 -0
  108. package/dist/tounicode.d.ts +5 -0
  109. package/dist/tounicode.js +33 -0
  110. package/dist/write.cjs +80 -10
  111. package/dist/write.d.cts +6 -0
  112. package/dist/write.d.ts +6 -0
  113. package/dist/write.js +81 -11
  114. package/package.json +1 -1
  115. package/dist/math-cmap.cjs +0 -81
  116. package/dist/math-cmap.d.cts +0 -6
  117. package/dist/math-cmap.d.ts +0 -6
  118. package/dist/math-cmap.js +0 -80
@@ -1,81 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sfnt = require("./sfnt.cjs");
3
- //#region src/math-cmap.ts
4
- function parseFormat4(bytes, subtableOffset) {
5
- const segCountX2 = require_sfnt.u16(bytes, subtableOffset + 6);
6
- const segCount = segCountX2 / 2;
7
- const endCodesOffset = subtableOffset + 14;
8
- const startCodesOffset = endCodesOffset + segCountX2 + 2;
9
- const idDeltasOffset = startCodesOffset + segCountX2;
10
- const idRangeOffsetsOffset = idDeltasOffset + segCountX2;
11
- const groups = [];
12
- for (let i = 0; i < segCount; i++) {
13
- const idRangeOffsetPos = idRangeOffsetsOffset + i * 2;
14
- groups.push({
15
- endCode: require_sfnt.u16(bytes, endCodesOffset + i * 2),
16
- startCode: require_sfnt.u16(bytes, startCodesOffset + i * 2),
17
- idDelta: (() => {
18
- const raw = require_sfnt.u16(bytes, idDeltasOffset + i * 2);
19
- return raw >= 32768 ? raw - 65536 : raw;
20
- })(),
21
- idRangeOffsetPos,
22
- idRangeOffset: require_sfnt.u16(bytes, idRangeOffsetPos)
23
- });
24
- }
25
- return (codePoint) => {
26
- if (codePoint > 65535) return;
27
- for (const group of groups) {
28
- if (codePoint < group.startCode || codePoint > group.endCode) continue;
29
- if (group.idRangeOffset === 0) return codePoint + group.idDelta & 65535;
30
- const glyphIndexAddress = group.idRangeOffsetPos + group.idRangeOffset + (codePoint - group.startCode) * 2;
31
- const glyphId = require_sfnt.u16(bytes, glyphIndexAddress);
32
- return glyphId === 0 ? void 0 : glyphId + group.idDelta & 65535;
33
- }
34
- };
35
- }
36
- function parseFormat12(bytes, subtableOffset) {
37
- const numGroups = require_sfnt.u32(bytes, subtableOffset + 12);
38
- const groups = [];
39
- for (let i = 0; i < numGroups; i++) {
40
- const recordOffset = subtableOffset + 16 + i * 12;
41
- groups.push({
42
- startCharCode: require_sfnt.u32(bytes, recordOffset),
43
- endCharCode: require_sfnt.u32(bytes, recordOffset + 4),
44
- startGlyphId: require_sfnt.u32(bytes, recordOffset + 8)
45
- });
46
- }
47
- return (codePoint) => {
48
- for (const group of groups) if (codePoint >= group.startCharCode && codePoint <= group.endCharCode) return group.startGlyphId + (codePoint - group.startCharCode);
49
- };
50
- }
51
- function buildCmapLookup(font) {
52
- const cmapBytes = require_sfnt.sfntTableBytes(font, "cmap");
53
- if (cmapBytes === void 0) throw new Error("math font has no cmap table");
54
- const numTables = require_sfnt.u16(cmapBytes, 2);
55
- const subtables = [];
56
- for (let i = 0; i < numTables; i++) {
57
- const recordOffset = 4 + i * 8;
58
- const platformId = require_sfnt.u16(cmapBytes, recordOffset);
59
- const encodingId = require_sfnt.u16(cmapBytes, recordOffset + 2);
60
- const offset = require_sfnt.u32(cmapBytes, recordOffset + 4);
61
- subtables.push({
62
- platformId,
63
- encodingId,
64
- offset,
65
- format: require_sfnt.u16(cmapBytes, offset)
66
- });
67
- }
68
- const byPreference = (a) => {
69
- if (a.format === 12 && a.platformId === 3 && a.encodingId === 10) return 0;
70
- if (a.format === 12 && a.platformId === 0) return 1;
71
- if (a.format === 12) return 2;
72
- if (a.format === 4 && a.platformId === 3 && a.encodingId === 1) return 3;
73
- if (a.format === 4) return 4;
74
- return 5;
75
- };
76
- const best = subtables.filter((s) => s.format === 4 || s.format === 12).sort((a, b) => byPreference(a) - byPreference(b))[0];
77
- if (best === void 0) throw new Error("math font cmap has no format 4 or format 12 subtable");
78
- return best.format === 12 ? parseFormat12(cmapBytes, best.offset) : parseFormat4(cmapBytes, best.offset);
79
- }
80
- //#endregion
81
- exports.buildCmapLookup = buildCmapLookup;
@@ -1,6 +0,0 @@
1
- import { SfntFont } from "./sfnt.cjs";
2
- //#region src/math-cmap.d.ts
3
- type CmapLookup = (codePoint: number) => number | undefined;
4
- declare function buildCmapLookup(font: SfntFont): CmapLookup;
5
- //#endregion
6
- export { CmapLookup, buildCmapLookup };
@@ -1,6 +0,0 @@
1
- import { SfntFont } from "./sfnt.js";
2
- //#region src/math-cmap.d.ts
3
- type CmapLookup = (codePoint: number) => number | undefined;
4
- declare function buildCmapLookup(font: SfntFont): CmapLookup;
5
- //#endregion
6
- export { CmapLookup, buildCmapLookup };
package/dist/math-cmap.js DELETED
@@ -1,80 +0,0 @@
1
- import { sfntTableBytes, u16, u32 } from "./sfnt.js";
2
- //#region src/math-cmap.ts
3
- function parseFormat4(bytes, subtableOffset) {
4
- const segCountX2 = u16(bytes, subtableOffset + 6);
5
- const segCount = segCountX2 / 2;
6
- const endCodesOffset = subtableOffset + 14;
7
- const startCodesOffset = endCodesOffset + segCountX2 + 2;
8
- const idDeltasOffset = startCodesOffset + segCountX2;
9
- const idRangeOffsetsOffset = idDeltasOffset + segCountX2;
10
- const groups = [];
11
- for (let i = 0; i < segCount; i++) {
12
- const idRangeOffsetPos = idRangeOffsetsOffset + i * 2;
13
- groups.push({
14
- endCode: u16(bytes, endCodesOffset + i * 2),
15
- startCode: u16(bytes, startCodesOffset + i * 2),
16
- idDelta: (() => {
17
- const raw = u16(bytes, idDeltasOffset + i * 2);
18
- return raw >= 32768 ? raw - 65536 : raw;
19
- })(),
20
- idRangeOffsetPos,
21
- idRangeOffset: u16(bytes, idRangeOffsetPos)
22
- });
23
- }
24
- return (codePoint) => {
25
- if (codePoint > 65535) return;
26
- for (const group of groups) {
27
- if (codePoint < group.startCode || codePoint > group.endCode) continue;
28
- if (group.idRangeOffset === 0) return codePoint + group.idDelta & 65535;
29
- const glyphIndexAddress = group.idRangeOffsetPos + group.idRangeOffset + (codePoint - group.startCode) * 2;
30
- const glyphId = u16(bytes, glyphIndexAddress);
31
- return glyphId === 0 ? void 0 : glyphId + group.idDelta & 65535;
32
- }
33
- };
34
- }
35
- function parseFormat12(bytes, subtableOffset) {
36
- const numGroups = u32(bytes, subtableOffset + 12);
37
- const groups = [];
38
- for (let i = 0; i < numGroups; i++) {
39
- const recordOffset = subtableOffset + 16 + i * 12;
40
- groups.push({
41
- startCharCode: u32(bytes, recordOffset),
42
- endCharCode: u32(bytes, recordOffset + 4),
43
- startGlyphId: u32(bytes, recordOffset + 8)
44
- });
45
- }
46
- return (codePoint) => {
47
- for (const group of groups) if (codePoint >= group.startCharCode && codePoint <= group.endCharCode) return group.startGlyphId + (codePoint - group.startCharCode);
48
- };
49
- }
50
- function buildCmapLookup(font) {
51
- const cmapBytes = sfntTableBytes(font, "cmap");
52
- if (cmapBytes === void 0) throw new Error("math font has no cmap table");
53
- const numTables = u16(cmapBytes, 2);
54
- const subtables = [];
55
- for (let i = 0; i < numTables; i++) {
56
- const recordOffset = 4 + i * 8;
57
- const platformId = u16(cmapBytes, recordOffset);
58
- const encodingId = u16(cmapBytes, recordOffset + 2);
59
- const offset = u32(cmapBytes, recordOffset + 4);
60
- subtables.push({
61
- platformId,
62
- encodingId,
63
- offset,
64
- format: u16(cmapBytes, offset)
65
- });
66
- }
67
- const byPreference = (a) => {
68
- if (a.format === 12 && a.platformId === 3 && a.encodingId === 10) return 0;
69
- if (a.format === 12 && a.platformId === 0) return 1;
70
- if (a.format === 12) return 2;
71
- if (a.format === 4 && a.platformId === 3 && a.encodingId === 1) return 3;
72
- if (a.format === 4) return 4;
73
- return 5;
74
- };
75
- const best = subtables.filter((s) => s.format === 4 || s.format === 12).sort((a, b) => byPreference(a) - byPreference(b))[0];
76
- if (best === void 0) throw new Error("math font cmap has no format 4 or format 12 subtable");
77
- return best.format === 12 ? parseFormat12(cmapBytes, best.offset) : parseFormat4(cmapBytes, best.offset);
78
- }
79
- //#endregion
80
- export { buildCmapLookup };