pdf-codec 1.5.0 → 1.7.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 (214) hide show
  1. package/README.md +100 -9
  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-bounds.cjs +432 -0
  35. package/dist/cff-bounds.d.cts +9 -0
  36. package/dist/cff-bounds.d.ts +9 -0
  37. package/dist/cff-bounds.js +431 -0
  38. package/dist/cff-probe.cjs +35 -0
  39. package/dist/cff-probe.d.cts +10 -0
  40. package/dist/cff-probe.d.ts +10 -0
  41. package/dist/cff-probe.js +34 -0
  42. package/dist/cff.cjs +158 -0
  43. package/dist/cff.d.cts +17 -0
  44. package/dist/cff.d.ts +17 -0
  45. package/dist/cff.js +150 -0
  46. package/dist/cmap-table.cjs +108 -0
  47. package/dist/cmap-table.d.cts +6 -0
  48. package/dist/cmap-table.d.ts +6 -0
  49. package/dist/cmap-table.js +107 -0
  50. package/dist/content-write.cjs +34 -14
  51. package/dist/content-write.d.cts +9 -2
  52. package/dist/content-write.d.ts +9 -2
  53. package/dist/content-write.js +34 -14
  54. package/dist/embedded-font-CLedn-mT.d.cts +42 -0
  55. package/dist/embedded-font-CbqkKgBl.d.ts +42 -0
  56. package/dist/embedded-font-write.cjs +92 -0
  57. package/dist/embedded-font-write.d.cts +22 -0
  58. package/dist/embedded-font-write.d.ts +22 -0
  59. package/dist/embedded-font-write.js +90 -0
  60. package/dist/embedded-font.cjs +142 -0
  61. package/dist/embedded-font.d.cts +2 -0
  62. package/dist/embedded-font.d.ts +2 -0
  63. package/dist/embedded-font.js +138 -0
  64. package/dist/filters.cjs +45 -2
  65. package/dist/filters.d.cts +4 -3
  66. package/dist/filters.d.ts +4 -3
  67. package/dist/filters.js +45 -2
  68. package/dist/font-registry-Cn7P9lAh.d.ts +38 -0
  69. package/dist/font-registry-yby02snZ.d.cts +38 -0
  70. package/dist/font-registry.cjs +152 -0
  71. package/dist/font-registry.d.cts +2 -0
  72. package/dist/font-registry.d.ts +2 -0
  73. package/dist/font-registry.js +150 -0
  74. package/dist/font-substitutes.cjs +13 -0
  75. package/dist/font-substitutes.d.cts +5 -0
  76. package/dist/font-substitutes.d.ts +5 -0
  77. package/dist/font-substitutes.js +12 -0
  78. package/dist/font-tables.cjs +127 -0
  79. package/dist/font-tables.d.cts +43 -0
  80. package/dist/font-tables.d.ts +43 -0
  81. package/dist/font-tables.js +122 -0
  82. package/dist/fonts.cjs +1 -0
  83. package/dist/fonts.d.cts +2 -1
  84. package/dist/fonts.d.ts +2 -1
  85. package/dist/fonts.js +1 -1
  86. package/dist/formula.d.cts +1 -1
  87. package/dist/formula.d.ts +1 -1
  88. package/dist/glyf.cjs +183 -0
  89. package/dist/glyf.d.cts +33 -0
  90. package/dist/glyf.d.ts +33 -0
  91. package/dist/glyf.js +181 -0
  92. package/dist/glyph-bounds-BV_Z40KS.d.cts +10 -0
  93. package/dist/glyph-bounds-BV_Z40KS.d.ts +10 -0
  94. package/dist/glyph-bounds.cjs +12 -0
  95. package/dist/glyph-bounds.d.cts +2 -0
  96. package/dist/glyph-bounds.d.ts +2 -0
  97. package/dist/glyph-bounds.js +11 -0
  98. package/dist/{math-hmtx.cjs → hmtx-table.cjs} +3 -3
  99. package/dist/{math-hmtx.d.ts → hmtx-table.d.cts} +2 -2
  100. package/dist/{math-hmtx.d.cts → hmtx-table.d.ts} +2 -2
  101. package/dist/{math-hmtx.js → hmtx-table.js} +3 -3
  102. package/dist/image/jbig2-arith.cjs +432 -0
  103. package/dist/image/jbig2-arith.d.cts +23 -0
  104. package/dist/image/jbig2-arith.d.ts +23 -0
  105. package/dist/image/jbig2-arith.js +426 -0
  106. package/dist/image/jbig2-bitmap.cjs +80 -0
  107. package/dist/image/jbig2-bitmap.d.cts +20 -0
  108. package/dist/image/jbig2-bitmap.d.ts +20 -0
  109. package/dist/image/jbig2-bitmap.js +72 -0
  110. package/dist/image/jbig2-errors.cjs +17 -0
  111. package/dist/image/jbig2-errors.d.cts +2 -0
  112. package/dist/image/jbig2-errors.d.ts +2 -0
  113. package/dist/image/jbig2-errors.js +15 -0
  114. package/dist/image/jbig2-generic.cjs +242 -0
  115. package/dist/image/jbig2-generic.d.cts +27 -0
  116. package/dist/image/jbig2-generic.d.ts +27 -0
  117. package/dist/image/jbig2-generic.js +237 -0
  118. package/dist/image/jbig2-text.cjs +175 -0
  119. package/dist/image/jbig2-text.d.cts +58 -0
  120. package/dist/image/jbig2-text.d.ts +58 -0
  121. package/dist/image/jbig2-text.js +170 -0
  122. package/dist/image/jbig2.cjs +333 -0
  123. package/dist/image/jbig2.d.cts +15 -0
  124. package/dist/image/jbig2.d.ts +15 -0
  125. package/dist/image/jbig2.js +332 -0
  126. package/dist/image/jp2-boxes.cjs +148 -0
  127. package/dist/image/jp2-boxes.d.cts +26 -0
  128. package/dist/image/jp2-boxes.d.ts +26 -0
  129. package/dist/image/jp2-boxes.js +146 -0
  130. package/dist/image/jpeg2000-codestream.cjs +309 -0
  131. package/dist/image/jpeg2000-codestream.d.cts +78 -0
  132. package/dist/image/jpeg2000-codestream.d.ts +78 -0
  133. package/dist/image/jpeg2000-codestream.js +308 -0
  134. package/dist/image/jpeg2000-dwt.cjs +148 -0
  135. package/dist/image/jpeg2000-dwt.d.cts +34 -0
  136. package/dist/image/jpeg2000-dwt.d.ts +34 -0
  137. package/dist/image/jpeg2000-dwt.js +145 -0
  138. package/dist/image/jpeg2000-errors.cjs +17 -0
  139. package/dist/image/jpeg2000-errors.d.cts +9 -0
  140. package/dist/image/jpeg2000-errors.d.ts +9 -0
  141. package/dist/image/jpeg2000-errors.js +15 -0
  142. package/dist/image/jpeg2000-t1.cjs +254 -0
  143. package/dist/image/jpeg2000-t1.d.cts +18 -0
  144. package/dist/image/jpeg2000-t1.d.ts +18 -0
  145. package/dist/image/jpeg2000-t1.js +253 -0
  146. package/dist/image/jpeg2000-t2.cjs +316 -0
  147. package/dist/image/jpeg2000-t2.d.cts +79 -0
  148. package/dist/image/jpeg2000-t2.d.ts +79 -0
  149. package/dist/image/jpeg2000-t2.js +311 -0
  150. package/dist/image/jpeg2000-tagtree.cjs +105 -0
  151. package/dist/image/jpeg2000-tagtree.d.cts +29 -0
  152. package/dist/image/jpeg2000-tagtree.d.ts +29 -0
  153. package/dist/image/jpeg2000-tagtree.js +103 -0
  154. package/dist/image/jpeg2000.cjs +322 -0
  155. package/dist/image/jpeg2000.d.cts +54 -0
  156. package/dist/image/jpeg2000.d.ts +54 -0
  157. package/dist/image/jpeg2000.js +320 -0
  158. package/dist/images-read.cjs +78 -1
  159. package/dist/images-read.js +78 -1
  160. package/dist/index.cjs +22 -0
  161. package/dist/index.d.cts +14 -3
  162. package/dist/index.d.ts +14 -3
  163. package/dist/index.js +9 -2
  164. package/dist/jbig2-errors-Bj6MPxrx.d.cts +9 -0
  165. package/dist/jbig2-errors-Bj6MPxrx.d.ts +9 -0
  166. package/dist/math-font-write.cjs +2 -31
  167. package/dist/math-font-write.js +1 -30
  168. package/dist/math-font.cjs +50 -23
  169. package/dist/math-font.d.cts +8 -1
  170. package/dist/math-font.d.ts +8 -1
  171. package/dist/math-font.js +48 -21
  172. package/dist/math-stretch-Bwk_bxh1.d.ts +24 -0
  173. package/dist/math-stretch-DXWjs8gL.d.cts +24 -0
  174. package/dist/math-stretch.cjs +96 -0
  175. package/dist/math-stretch.d.cts +2 -0
  176. package/dist/math-stretch.d.ts +2 -0
  177. package/dist/math-stretch.js +94 -0
  178. package/dist/math-table-DhPrNoPa.d.ts +70 -0
  179. package/dist/math-table-gFNB8DmQ.d.cts +70 -0
  180. package/dist/math-table.cjs +69 -1
  181. package/dist/math-table.d.cts +2 -45
  182. package/dist/math-table.d.ts +2 -45
  183. package/dist/math-table.js +69 -1
  184. package/dist/{math-types-Ba8qAf1p.d.cts → math-types-YSQUTviw.d.cts} +2 -0
  185. package/dist/{math-types-Ba8qAf1p.d.ts → math-types-YSQUTviw.d.ts} +2 -0
  186. package/dist/math-types.d.cts +1 -1
  187. package/dist/math-types.d.ts +1 -1
  188. package/dist/measure.cjs +65 -14
  189. package/dist/measure.d.cts +8 -1
  190. package/dist/measure.d.ts +8 -1
  191. package/dist/measure.js +64 -15
  192. package/dist/sfnt-V08bb5ut.d.cts +21 -0
  193. package/dist/sfnt-V08bb5ut.d.ts +21 -0
  194. package/dist/sfnt-subset.cjs +250 -0
  195. package/dist/sfnt-subset.d.cts +11 -0
  196. package/dist/sfnt-subset.d.ts +11 -0
  197. package/dist/sfnt-subset.js +249 -0
  198. package/dist/sfnt.cjs +50 -4
  199. package/dist/sfnt.d.cts +2 -17
  200. package/dist/sfnt.d.ts +2 -17
  201. package/dist/sfnt.js +47 -5
  202. package/dist/tounicode.cjs +34 -0
  203. package/dist/tounicode.d.cts +5 -0
  204. package/dist/tounicode.d.ts +5 -0
  205. package/dist/tounicode.js +33 -0
  206. package/dist/write.cjs +80 -10
  207. package/dist/write.d.cts +6 -0
  208. package/dist/write.d.ts +6 -0
  209. package/dist/write.js +81 -11
  210. package/package.json +1 -1
  211. package/dist/math-cmap.cjs +0 -81
  212. package/dist/math-cmap.d.cts +0 -6
  213. package/dist/math-cmap.d.ts +0 -6
  214. package/dist/math-cmap.js +0 -80
@@ -0,0 +1,94 @@
1
+ //#region src/math-stretch.ts
2
+ function sumBy(items, value) {
3
+ return items.reduce((total, item) => total + value(item), 0);
4
+ }
5
+ function requiredRepeatCount(fixed, extenders, targetSize, minConnectorOverlap) {
6
+ const minimumRepeat = fixed.length === 0 ? 1 : 0;
7
+ if (extenders.length === 0) return minimumRepeat;
8
+ const growthPerRepeat = sumBy(extenders, (part) => part.fullAdvance) - extenders.length * minConnectorOverlap;
9
+ if (growthPerRepeat <= 0) return minimumRepeat;
10
+ const shortfall = targetSize - sumBy(fixed, (part) => part.fullAdvance) + (fixed.length - 1) * minConnectorOverlap;
11
+ return Math.max(minimumRepeat, Math.ceil(shortfall / growthPerRepeat));
12
+ }
13
+ function expandParts(parts, repeatCount) {
14
+ const expanded = [];
15
+ for (const part of parts) for (let i = 0; i < (part.isExtender ? repeatCount : 1); i++) expanded.push(part);
16
+ return expanded;
17
+ }
18
+ function maximumOverlap(expanded) {
19
+ let overlap = Number.POSITIVE_INFINITY;
20
+ for (let i = 0; i + 1 < expanded.length; i++) overlap = Math.min(overlap, expanded[i].endConnectorLength, expanded[i + 1].startConnectorLength);
21
+ for (let i = 0; i < expanded.length; i++) {
22
+ const joins = (i === 0 ? 0 : 1) + (i === expanded.length - 1 ? 0 : 1);
23
+ if (joins > 0) overlap = Math.min(overlap, expanded[i].fullAdvance / joins);
24
+ }
25
+ return overlap;
26
+ }
27
+ function assembleFromParts(assembly, options) {
28
+ const fixed = assembly.parts.filter((part) => !part.isExtender);
29
+ const extenders = assembly.parts.filter((part) => part.isExtender);
30
+ const expanded = expandParts(assembly.parts, requiredRepeatCount(fixed, extenders, options.targetSize, options.minConnectorOverlap));
31
+ if (expanded.length === 0) return;
32
+ const joins = expanded.length - 1;
33
+ const maxOverlap = maximumOverlap(expanded);
34
+ const minOverlap = Math.min(options.minConnectorOverlap, maxOverlap);
35
+ const totalAdvance = sumBy(expanded, (part) => part.fullAdvance);
36
+ const exactOverlap = joins === 0 ? minOverlap : (totalAdvance - options.targetSize) / joins;
37
+ const overlap = Math.min(Math.max(exactOverlap, minOverlap), maxOverlap);
38
+ const placements = [];
39
+ let offset = 0;
40
+ for (const part of expanded) {
41
+ placements.push({
42
+ glyphId: part.glyphId,
43
+ offset,
44
+ advance: part.fullAdvance
45
+ });
46
+ offset += part.fullAdvance - overlap;
47
+ }
48
+ return {
49
+ kind: "assembly",
50
+ axis: options.axis,
51
+ size: totalAdvance - joins * overlap,
52
+ italicsCorrection: assembly.italicsCorrection,
53
+ placements
54
+ };
55
+ }
56
+ function fromVariant(variant, isBaseGlyph, axis) {
57
+ return {
58
+ kind: isBaseGlyph ? "base" : "variant",
59
+ axis,
60
+ size: variant.advanceMeasurement,
61
+ italicsCorrection: 0,
62
+ placements: [{
63
+ glyphId: variant.glyphId,
64
+ offset: 0,
65
+ advance: variant.advanceMeasurement
66
+ }]
67
+ };
68
+ }
69
+ function assembleStretchyGlyph(construction, options) {
70
+ const variants = construction.variants;
71
+ const reaching = variants.findIndex((variant) => variant.advanceMeasurement >= options.targetSize);
72
+ if (reaching !== -1) return fromVariant(variants[reaching], reaching === 0, options.axis);
73
+ if (construction.assembly !== void 0) {
74
+ const assembled = assembleFromParts(construction.assembly, options);
75
+ if (assembled !== void 0) return assembled;
76
+ }
77
+ const largest = variants[variants.length - 1];
78
+ return largest === void 0 ? void 0 : fromVariant(largest, variants.length === 1, options.axis);
79
+ }
80
+ function scaleMathStretchConstruction(construction, factor) {
81
+ return {
82
+ kind: construction.kind,
83
+ axis: construction.axis,
84
+ size: construction.size * factor,
85
+ italicsCorrection: construction.italicsCorrection * factor,
86
+ placements: construction.placements.map((placement) => ({
87
+ glyphId: placement.glyphId,
88
+ offset: placement.offset * factor,
89
+ advance: placement.advance * factor
90
+ }))
91
+ };
92
+ }
93
+ //#endregion
94
+ export { assembleStretchyGlyph, scaleMathStretchConstruction };
@@ -0,0 +1,70 @@
1
+ import { t as SfntFont } from "./sfnt-V08bb5ut.js";
2
+ //#region src/math-table.d.ts
3
+ interface MathConstants {
4
+ readonly scriptPercentScaleDown: number;
5
+ readonly scriptScriptPercentScaleDown: number;
6
+ readonly axisHeight: number;
7
+ readonly subscriptShiftDown: number;
8
+ readonly subscriptBaselineDropMin: number;
9
+ readonly superscriptShiftUp: number;
10
+ readonly superscriptShiftUpCramped: number;
11
+ readonly superscriptBaselineDropMax: number;
12
+ readonly subSuperscriptGapMin: number;
13
+ readonly spaceAfterScript: number;
14
+ readonly upperLimitGapMin: number;
15
+ readonly upperLimitBaselineRiseMin: number;
16
+ readonly lowerLimitGapMin: number;
17
+ readonly lowerLimitBaselineDropMin: number;
18
+ readonly stackTopShiftUp: number;
19
+ readonly stackBottomShiftDown: number;
20
+ readonly stackGapMin: number;
21
+ readonly fractionNumeratorShiftUp: number;
22
+ readonly fractionNumeratorDisplayStyleShiftUp: number;
23
+ readonly fractionDenominatorShiftDown: number;
24
+ readonly fractionDenominatorDisplayStyleShiftDown: number;
25
+ readonly fractionNumeratorGapMin: number;
26
+ readonly fractionRuleThickness: number;
27
+ readonly fractionDenominatorGapMin: number;
28
+ readonly radicalVerticalGap: number;
29
+ readonly radicalRuleThickness: number;
30
+ readonly radicalExtraAscender: number;
31
+ readonly radicalKernBeforeDegree: number;
32
+ readonly radicalKernAfterDegree: number;
33
+ readonly radicalDegreeBottomRaisePercent: number;
34
+ }
35
+ interface MathGlyphInfo {
36
+ readonly italicsCorrection: ReadonlyMap<number, number>;
37
+ readonly topAccentAttachment: ReadonlyMap<number, number>;
38
+ }
39
+ interface MathGlyphVariant {
40
+ readonly glyphId: number;
41
+ readonly advanceMeasurement: number;
42
+ }
43
+ interface MathGlyphPart {
44
+ readonly glyphId: number;
45
+ readonly startConnectorLength: number;
46
+ readonly endConnectorLength: number;
47
+ readonly fullAdvance: number;
48
+ readonly isExtender: boolean;
49
+ }
50
+ interface MathGlyphAssembly {
51
+ readonly italicsCorrection: number;
52
+ readonly parts: readonly MathGlyphPart[];
53
+ }
54
+ interface MathGlyphConstruction {
55
+ readonly variants: readonly MathGlyphVariant[];
56
+ readonly assembly?: MathGlyphAssembly;
57
+ }
58
+ interface MathVariants {
59
+ readonly minConnectorOverlap: number;
60
+ readonly vertical: ReadonlyMap<number, MathGlyphConstruction>;
61
+ readonly horizontal: ReadonlyMap<number, MathGlyphConstruction>;
62
+ }
63
+ interface MathTable {
64
+ readonly constants: MathConstants;
65
+ readonly glyphInfo: MathGlyphInfo;
66
+ readonly variants: MathVariants;
67
+ }
68
+ declare function parseMathTable(font: SfntFont): MathTable;
69
+ //#endregion
70
+ export { MathGlyphPart as a, MathVariants as c, MathGlyphInfo as i, parseMathTable as l, MathGlyphAssembly as n, MathGlyphVariant as o, MathGlyphConstruction as r, MathTable as s, MathConstants as t };
@@ -0,0 +1,70 @@
1
+ import { t as SfntFont } from "./sfnt-V08bb5ut.cjs";
2
+ //#region src/math-table.d.ts
3
+ interface MathConstants {
4
+ readonly scriptPercentScaleDown: number;
5
+ readonly scriptScriptPercentScaleDown: number;
6
+ readonly axisHeight: number;
7
+ readonly subscriptShiftDown: number;
8
+ readonly subscriptBaselineDropMin: number;
9
+ readonly superscriptShiftUp: number;
10
+ readonly superscriptShiftUpCramped: number;
11
+ readonly superscriptBaselineDropMax: number;
12
+ readonly subSuperscriptGapMin: number;
13
+ readonly spaceAfterScript: number;
14
+ readonly upperLimitGapMin: number;
15
+ readonly upperLimitBaselineRiseMin: number;
16
+ readonly lowerLimitGapMin: number;
17
+ readonly lowerLimitBaselineDropMin: number;
18
+ readonly stackTopShiftUp: number;
19
+ readonly stackBottomShiftDown: number;
20
+ readonly stackGapMin: number;
21
+ readonly fractionNumeratorShiftUp: number;
22
+ readonly fractionNumeratorDisplayStyleShiftUp: number;
23
+ readonly fractionDenominatorShiftDown: number;
24
+ readonly fractionDenominatorDisplayStyleShiftDown: number;
25
+ readonly fractionNumeratorGapMin: number;
26
+ readonly fractionRuleThickness: number;
27
+ readonly fractionDenominatorGapMin: number;
28
+ readonly radicalVerticalGap: number;
29
+ readonly radicalRuleThickness: number;
30
+ readonly radicalExtraAscender: number;
31
+ readonly radicalKernBeforeDegree: number;
32
+ readonly radicalKernAfterDegree: number;
33
+ readonly radicalDegreeBottomRaisePercent: number;
34
+ }
35
+ interface MathGlyphInfo {
36
+ readonly italicsCorrection: ReadonlyMap<number, number>;
37
+ readonly topAccentAttachment: ReadonlyMap<number, number>;
38
+ }
39
+ interface MathGlyphVariant {
40
+ readonly glyphId: number;
41
+ readonly advanceMeasurement: number;
42
+ }
43
+ interface MathGlyphPart {
44
+ readonly glyphId: number;
45
+ readonly startConnectorLength: number;
46
+ readonly endConnectorLength: number;
47
+ readonly fullAdvance: number;
48
+ readonly isExtender: boolean;
49
+ }
50
+ interface MathGlyphAssembly {
51
+ readonly italicsCorrection: number;
52
+ readonly parts: readonly MathGlyphPart[];
53
+ }
54
+ interface MathGlyphConstruction {
55
+ readonly variants: readonly MathGlyphVariant[];
56
+ readonly assembly?: MathGlyphAssembly;
57
+ }
58
+ interface MathVariants {
59
+ readonly minConnectorOverlap: number;
60
+ readonly vertical: ReadonlyMap<number, MathGlyphConstruction>;
61
+ readonly horizontal: ReadonlyMap<number, MathGlyphConstruction>;
62
+ }
63
+ interface MathTable {
64
+ readonly constants: MathConstants;
65
+ readonly glyphInfo: MathGlyphInfo;
66
+ readonly variants: MathVariants;
67
+ }
68
+ declare function parseMathTable(font: SfntFont): MathTable;
69
+ //#endregion
70
+ export { MathGlyphPart as a, MathVariants as c, MathGlyphInfo as i, parseMathTable as l, MathGlyphAssembly as n, MathGlyphVariant as o, MathGlyphConstruction as r, MathTable as s, MathConstants as t };
@@ -105,12 +105,80 @@ function parseMathGlyphInfo(bytes, mathTableOffset) {
105
105
  topAccentAttachment: topAccentOffset === 0 ? /* @__PURE__ */ new Map() : parseGlyphValueTable(bytes, glyphInfoOffset + topAccentOffset)
106
106
  };
107
107
  }
108
+ const MATH_GLYPH_VARIANT_RECORD_SIZE = 4;
109
+ const GLYPH_PART_RECORD_SIZE = 10;
110
+ const GLYPH_PART_FLAG_EXTENDER = 1;
111
+ const MATH_VARIANTS_HEADER_SIZE = 10;
112
+ function parseGlyphAssembly(bytes, assemblyOffset) {
113
+ const partCount = require_sfnt.u16(bytes, assemblyOffset + MATH_VALUE_RECORD_SIZE);
114
+ const parts = [];
115
+ for (let i = 0; i < partCount; i++) {
116
+ const recordOffset = assemblyOffset + MATH_VALUE_RECORD_SIZE + 2 + i * GLYPH_PART_RECORD_SIZE;
117
+ parts.push({
118
+ glyphId: require_sfnt.u16(bytes, recordOffset),
119
+ startConnectorLength: require_sfnt.u16(bytes, recordOffset + 2),
120
+ endConnectorLength: require_sfnt.u16(bytes, recordOffset + 4),
121
+ fullAdvance: require_sfnt.u16(bytes, recordOffset + 6),
122
+ isExtender: (require_sfnt.u16(bytes, recordOffset + 8) & GLYPH_PART_FLAG_EXTENDER) !== 0
123
+ });
124
+ }
125
+ return {
126
+ italicsCorrection: require_sfnt.i16(bytes, assemblyOffset),
127
+ parts
128
+ };
129
+ }
130
+ function parseGlyphConstruction(bytes, constructionOffset) {
131
+ const assemblyOffset = require_sfnt.u16(bytes, constructionOffset);
132
+ const variantCount = require_sfnt.u16(bytes, constructionOffset + 2);
133
+ const variants = [];
134
+ for (let i = 0; i < variantCount; i++) {
135
+ const recordOffset = constructionOffset + 4 + i * MATH_GLYPH_VARIANT_RECORD_SIZE;
136
+ variants.push({
137
+ glyphId: require_sfnt.u16(bytes, recordOffset),
138
+ advanceMeasurement: require_sfnt.u16(bytes, recordOffset + 2)
139
+ });
140
+ }
141
+ return assemblyOffset === 0 ? { variants } : {
142
+ variants,
143
+ assembly: parseGlyphAssembly(bytes, constructionOffset + assemblyOffset)
144
+ };
145
+ }
146
+ function parseConstructionsForAxis(bytes, variantsOffset, coverageOffset, count, constructionArrayOffset) {
147
+ const constructions = /* @__PURE__ */ new Map();
148
+ if (coverageOffset === 0) return constructions;
149
+ for (const [glyphId, coverageIndex] of parseCoverageIndex(bytes, variantsOffset + coverageOffset)) {
150
+ if (coverageIndex >= count) continue;
151
+ constructions.set(glyphId, parseGlyphConstruction(bytes, variantsOffset + require_sfnt.u16(bytes, constructionArrayOffset + coverageIndex * 2)));
152
+ }
153
+ return constructions;
154
+ }
155
+ function parseMathVariants(bytes, mathTableOffset) {
156
+ const variantsTableOffset = require_sfnt.u16(bytes, mathTableOffset + 8);
157
+ if (variantsTableOffset === 0) return {
158
+ minConnectorOverlap: 0,
159
+ vertical: /* @__PURE__ */ new Map(),
160
+ horizontal: /* @__PURE__ */ new Map()
161
+ };
162
+ const variantsOffset = mathTableOffset + variantsTableOffset;
163
+ const verticalCoverageOffset = require_sfnt.u16(bytes, variantsOffset + 2);
164
+ const horizontalCoverageOffset = require_sfnt.u16(bytes, variantsOffset + 4);
165
+ const verticalCount = require_sfnt.u16(bytes, variantsOffset + 6);
166
+ const horizontalCount = require_sfnt.u16(bytes, variantsOffset + 8);
167
+ const verticalArrayOffset = variantsOffset + MATH_VARIANTS_HEADER_SIZE;
168
+ const horizontalArrayOffset = verticalArrayOffset + verticalCount * 2;
169
+ return {
170
+ minConnectorOverlap: require_sfnt.u16(bytes, variantsOffset),
171
+ vertical: parseConstructionsForAxis(bytes, variantsOffset, verticalCoverageOffset, verticalCount, verticalArrayOffset),
172
+ horizontal: parseConstructionsForAxis(bytes, variantsOffset, horizontalCoverageOffset, horizontalCount, horizontalArrayOffset)
173
+ };
174
+ }
108
175
  function parseMathTable(font) {
109
176
  const mathBytes = require_sfnt.sfntTableBytes(font, "MATH");
110
177
  if (mathBytes === void 0) throw new Error("math font has no MATH table");
111
178
  return {
112
179
  constants: parseMathConstants(mathBytes, 0),
113
- glyphInfo: parseMathGlyphInfo(mathBytes, 0)
180
+ glyphInfo: parseMathGlyphInfo(mathBytes, 0),
181
+ variants: parseMathVariants(mathBytes, 0)
114
182
  };
115
183
  }
116
184
  //#endregion
@@ -1,45 +1,2 @@
1
- import { SfntFont } from "./sfnt.cjs";
2
- //#region src/math-table.d.ts
3
- interface MathConstants {
4
- readonly scriptPercentScaleDown: number;
5
- readonly scriptScriptPercentScaleDown: number;
6
- readonly axisHeight: number;
7
- readonly subscriptShiftDown: number;
8
- readonly subscriptBaselineDropMin: number;
9
- readonly superscriptShiftUp: number;
10
- readonly superscriptShiftUpCramped: number;
11
- readonly superscriptBaselineDropMax: number;
12
- readonly subSuperscriptGapMin: number;
13
- readonly spaceAfterScript: number;
14
- readonly upperLimitGapMin: number;
15
- readonly upperLimitBaselineRiseMin: number;
16
- readonly lowerLimitGapMin: number;
17
- readonly lowerLimitBaselineDropMin: number;
18
- readonly stackTopShiftUp: number;
19
- readonly stackBottomShiftDown: number;
20
- readonly stackGapMin: number;
21
- readonly fractionNumeratorShiftUp: number;
22
- readonly fractionNumeratorDisplayStyleShiftUp: number;
23
- readonly fractionDenominatorShiftDown: number;
24
- readonly fractionDenominatorDisplayStyleShiftDown: number;
25
- readonly fractionNumeratorGapMin: number;
26
- readonly fractionRuleThickness: number;
27
- readonly fractionDenominatorGapMin: number;
28
- readonly radicalVerticalGap: number;
29
- readonly radicalRuleThickness: number;
30
- readonly radicalExtraAscender: number;
31
- readonly radicalKernBeforeDegree: number;
32
- readonly radicalKernAfterDegree: number;
33
- readonly radicalDegreeBottomRaisePercent: number;
34
- }
35
- interface MathGlyphInfo {
36
- readonly italicsCorrection: ReadonlyMap<number, number>;
37
- readonly topAccentAttachment: ReadonlyMap<number, number>;
38
- }
39
- interface MathTable {
40
- readonly constants: MathConstants;
41
- readonly glyphInfo: MathGlyphInfo;
42
- }
43
- declare function parseMathTable(font: SfntFont): MathTable;
44
- //#endregion
45
- export { MathConstants, MathGlyphInfo, MathTable, parseMathTable };
1
+ import { a as MathGlyphPart, c as MathVariants, i as MathGlyphInfo, l as parseMathTable, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction, s as MathTable, t as MathConstants } from "./math-table-gFNB8DmQ.cjs";
2
+ export { MathConstants, MathGlyphAssembly, MathGlyphConstruction, MathGlyphInfo, MathGlyphPart, MathGlyphVariant, MathTable, MathVariants, parseMathTable };
@@ -1,45 +1,2 @@
1
- import { SfntFont } from "./sfnt.js";
2
- //#region src/math-table.d.ts
3
- interface MathConstants {
4
- readonly scriptPercentScaleDown: number;
5
- readonly scriptScriptPercentScaleDown: number;
6
- readonly axisHeight: number;
7
- readonly subscriptShiftDown: number;
8
- readonly subscriptBaselineDropMin: number;
9
- readonly superscriptShiftUp: number;
10
- readonly superscriptShiftUpCramped: number;
11
- readonly superscriptBaselineDropMax: number;
12
- readonly subSuperscriptGapMin: number;
13
- readonly spaceAfterScript: number;
14
- readonly upperLimitGapMin: number;
15
- readonly upperLimitBaselineRiseMin: number;
16
- readonly lowerLimitGapMin: number;
17
- readonly lowerLimitBaselineDropMin: number;
18
- readonly stackTopShiftUp: number;
19
- readonly stackBottomShiftDown: number;
20
- readonly stackGapMin: number;
21
- readonly fractionNumeratorShiftUp: number;
22
- readonly fractionNumeratorDisplayStyleShiftUp: number;
23
- readonly fractionDenominatorShiftDown: number;
24
- readonly fractionDenominatorDisplayStyleShiftDown: number;
25
- readonly fractionNumeratorGapMin: number;
26
- readonly fractionRuleThickness: number;
27
- readonly fractionDenominatorGapMin: number;
28
- readonly radicalVerticalGap: number;
29
- readonly radicalRuleThickness: number;
30
- readonly radicalExtraAscender: number;
31
- readonly radicalKernBeforeDegree: number;
32
- readonly radicalKernAfterDegree: number;
33
- readonly radicalDegreeBottomRaisePercent: number;
34
- }
35
- interface MathGlyphInfo {
36
- readonly italicsCorrection: ReadonlyMap<number, number>;
37
- readonly topAccentAttachment: ReadonlyMap<number, number>;
38
- }
39
- interface MathTable {
40
- readonly constants: MathConstants;
41
- readonly glyphInfo: MathGlyphInfo;
42
- }
43
- declare function parseMathTable(font: SfntFont): MathTable;
44
- //#endregion
45
- export { MathConstants, MathGlyphInfo, MathTable, parseMathTable };
1
+ import { a as MathGlyphPart, c as MathVariants, i as MathGlyphInfo, l as parseMathTable, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction, s as MathTable, t as MathConstants } from "./math-table-DhPrNoPa.js";
2
+ export { MathConstants, MathGlyphAssembly, MathGlyphConstruction, MathGlyphInfo, MathGlyphPart, MathGlyphVariant, MathTable, MathVariants, parseMathTable };
@@ -104,12 +104,80 @@ function parseMathGlyphInfo(bytes, mathTableOffset) {
104
104
  topAccentAttachment: topAccentOffset === 0 ? /* @__PURE__ */ new Map() : parseGlyphValueTable(bytes, glyphInfoOffset + topAccentOffset)
105
105
  };
106
106
  }
107
+ const MATH_GLYPH_VARIANT_RECORD_SIZE = 4;
108
+ const GLYPH_PART_RECORD_SIZE = 10;
109
+ const GLYPH_PART_FLAG_EXTENDER = 1;
110
+ const MATH_VARIANTS_HEADER_SIZE = 10;
111
+ function parseGlyphAssembly(bytes, assemblyOffset) {
112
+ const partCount = u16(bytes, assemblyOffset + MATH_VALUE_RECORD_SIZE);
113
+ const parts = [];
114
+ for (let i = 0; i < partCount; i++) {
115
+ const recordOffset = assemblyOffset + MATH_VALUE_RECORD_SIZE + 2 + i * GLYPH_PART_RECORD_SIZE;
116
+ parts.push({
117
+ glyphId: u16(bytes, recordOffset),
118
+ startConnectorLength: u16(bytes, recordOffset + 2),
119
+ endConnectorLength: u16(bytes, recordOffset + 4),
120
+ fullAdvance: u16(bytes, recordOffset + 6),
121
+ isExtender: (u16(bytes, recordOffset + 8) & GLYPH_PART_FLAG_EXTENDER) !== 0
122
+ });
123
+ }
124
+ return {
125
+ italicsCorrection: i16(bytes, assemblyOffset),
126
+ parts
127
+ };
128
+ }
129
+ function parseGlyphConstruction(bytes, constructionOffset) {
130
+ const assemblyOffset = u16(bytes, constructionOffset);
131
+ const variantCount = u16(bytes, constructionOffset + 2);
132
+ const variants = [];
133
+ for (let i = 0; i < variantCount; i++) {
134
+ const recordOffset = constructionOffset + 4 + i * MATH_GLYPH_VARIANT_RECORD_SIZE;
135
+ variants.push({
136
+ glyphId: u16(bytes, recordOffset),
137
+ advanceMeasurement: u16(bytes, recordOffset + 2)
138
+ });
139
+ }
140
+ return assemblyOffset === 0 ? { variants } : {
141
+ variants,
142
+ assembly: parseGlyphAssembly(bytes, constructionOffset + assemblyOffset)
143
+ };
144
+ }
145
+ function parseConstructionsForAxis(bytes, variantsOffset, coverageOffset, count, constructionArrayOffset) {
146
+ const constructions = /* @__PURE__ */ new Map();
147
+ if (coverageOffset === 0) return constructions;
148
+ for (const [glyphId, coverageIndex] of parseCoverageIndex(bytes, variantsOffset + coverageOffset)) {
149
+ if (coverageIndex >= count) continue;
150
+ constructions.set(glyphId, parseGlyphConstruction(bytes, variantsOffset + u16(bytes, constructionArrayOffset + coverageIndex * 2)));
151
+ }
152
+ return constructions;
153
+ }
154
+ function parseMathVariants(bytes, mathTableOffset) {
155
+ const variantsTableOffset = u16(bytes, mathTableOffset + 8);
156
+ if (variantsTableOffset === 0) return {
157
+ minConnectorOverlap: 0,
158
+ vertical: /* @__PURE__ */ new Map(),
159
+ horizontal: /* @__PURE__ */ new Map()
160
+ };
161
+ const variantsOffset = mathTableOffset + variantsTableOffset;
162
+ const verticalCoverageOffset = u16(bytes, variantsOffset + 2);
163
+ const horizontalCoverageOffset = u16(bytes, variantsOffset + 4);
164
+ const verticalCount = u16(bytes, variantsOffset + 6);
165
+ const horizontalCount = u16(bytes, variantsOffset + 8);
166
+ const verticalArrayOffset = variantsOffset + MATH_VARIANTS_HEADER_SIZE;
167
+ const horizontalArrayOffset = verticalArrayOffset + verticalCount * 2;
168
+ return {
169
+ minConnectorOverlap: u16(bytes, variantsOffset),
170
+ vertical: parseConstructionsForAxis(bytes, variantsOffset, verticalCoverageOffset, verticalCount, verticalArrayOffset),
171
+ horizontal: parseConstructionsForAxis(bytes, variantsOffset, horizontalCoverageOffset, horizontalCount, horizontalArrayOffset)
172
+ };
173
+ }
107
174
  function parseMathTable(font) {
108
175
  const mathBytes = sfntTableBytes(font, "MATH");
109
176
  if (mathBytes === void 0) throw new Error("math font has no MATH table");
110
177
  return {
111
178
  constants: parseMathConstants(mathBytes, 0),
112
- glyphInfo: parseMathGlyphInfo(mathBytes, 0)
179
+ glyphInfo: parseMathGlyphInfo(mathBytes, 0),
180
+ variants: parseMathVariants(mathBytes, 0)
113
181
  };
114
182
  }
115
183
  //#endregion
@@ -41,6 +41,8 @@ interface MathGlyphMetrics {
41
41
  readonly advanceWidthPt: number;
42
42
  readonly italicCorrectionPt: number;
43
43
  readonly topAccentXPt?: number;
44
+ readonly inkAscentPt?: number;
45
+ readonly inkDescentPt?: number;
44
46
  }
45
47
  interface MathFontMetrics {
46
48
  readonly ascentPerEm: number;
@@ -41,6 +41,8 @@ interface MathGlyphMetrics {
41
41
  readonly advanceWidthPt: number;
42
42
  readonly italicCorrectionPt: number;
43
43
  readonly topAccentXPt?: number;
44
+ readonly inkAscentPt?: number;
45
+ readonly inkDescentPt?: number;
44
46
  }
45
47
  interface MathFontMetrics {
46
48
  readonly ascentPerEm: number;
@@ -1,2 +1,2 @@
1
- import { a as MathGlyphRun, c as MathStroke, i as MathGlyphMetrics, n as MathColor, o as MathLayoutItem, r as MathFontMetrics, s as MathRule, t as MathBox } from "./math-types-Ba8qAf1p.cjs";
1
+ import { a as MathGlyphRun, c as MathStroke, i as MathGlyphMetrics, n as MathColor, o as MathLayoutItem, r as MathFontMetrics, s as MathRule, t as MathBox } from "./math-types-YSQUTviw.cjs";
2
2
  export { MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphRun, MathLayoutItem, MathRule, MathStroke };
@@ -1,2 +1,2 @@
1
- import { a as MathGlyphRun, c as MathStroke, i as MathGlyphMetrics, n as MathColor, o as MathLayoutItem, r as MathFontMetrics, s as MathRule, t as MathBox } from "./math-types-Ba8qAf1p.js";
1
+ import { a as MathGlyphRun, c as MathStroke, i as MathGlyphMetrics, n as MathColor, o as MathLayoutItem, r as MathFontMetrics, s as MathRule, t as MathBox } from "./math-types-YSQUTviw.js";
2
2
  export { MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphRun, MathLayoutItem, MathRule, MathStroke };
package/dist/measure.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_afm_widths = require("./afm-widths-BoeTOK2r.cjs");
3
- const require_fonts = require("./fonts.cjs");
3
+ const require_embedded_font = require("./embedded-font.cjs");
4
+ const require_font_registry = require("./font-registry.cjs");
4
5
  //#region src/measure.ts
6
+ const GLYPH_SPACE_UNITS_PER_EM = 1e3;
5
7
  const DEFAULT_WIDTH_CORRECTIONS = {
6
8
  calibri: .92,
7
9
  aptos: .93,
@@ -13,42 +15,91 @@ const DEFAULT_WIDTH_CORRECTIONS = {
13
15
  function normalizeFamilyKey(family) {
14
16
  return family.toLowerCase().replace(/[^a-z0-9]/g, "");
15
17
  }
16
- function createStandardFontMeasurer(options = {}) {
18
+ const EMBEDDED_HORIZONTAL_SCALE = 1;
19
+ const DEFAULT_VERTICAL_METRIC_POLICY = "hhea";
20
+ function verticalMetricsFor(face, policy) {
21
+ const m = face.metrics;
22
+ const hhea = {
23
+ ascentGlyphSpace: m.ascentGlyphSpace,
24
+ descentGlyphSpace: m.descentGlyphSpace,
25
+ lineGapGlyphSpace: m.lineGapGlyphSpace
26
+ };
27
+ if (policy === "os2Typo") {
28
+ if (m.typoAscentGlyphSpace === void 0 || m.typoDescentGlyphSpace === void 0 || m.typoLineGapGlyphSpace === void 0) return hhea;
29
+ return {
30
+ ascentGlyphSpace: m.typoAscentGlyphSpace,
31
+ descentGlyphSpace: m.typoDescentGlyphSpace,
32
+ lineGapGlyphSpace: m.typoLineGapGlyphSpace
33
+ };
34
+ }
35
+ if (policy === "os2Win") {
36
+ if (m.winAscentGlyphSpace === void 0 || m.winDescentGlyphSpace === void 0) return hhea;
37
+ return {
38
+ ascentGlyphSpace: m.winAscentGlyphSpace,
39
+ descentGlyphSpace: m.winDescentGlyphSpace,
40
+ lineGapGlyphSpace: 0
41
+ };
42
+ }
43
+ return hhea;
44
+ }
45
+ function createFontMeasurer(registry, options = {}) {
17
46
  const corrections = {
18
47
  ...DEFAULT_WIDTH_CORRECTIONS,
19
48
  ...options.widthCorrectionByFamily
20
49
  };
21
- function correctionFor(family) {
50
+ const verticalPolicy = options.verticalMetrics ?? "hhea";
51
+ function standardWidthCorrectionFor(family) {
22
52
  return corrections[normalizeFamilyKey(family)] ?? 1;
23
53
  }
24
- function standardNameFor(font) {
25
- return require_fonts.resolveStandardFont(font.family, font.weight === "bold", font.style === "italic").standardName;
54
+ function resolve(font) {
55
+ return require_font_registry.resolveFaceWithRegistry(registry, font);
26
56
  }
27
57
  return {
28
58
  widthOfTextAtSize(text, font, sizePt) {
29
- const { width1000 } = require_afm_widths.encodeForShow(text, standardNameFor(font));
30
- return width1000 / 1e3 * sizePt * correctionFor(font.family);
59
+ const face = resolve(font);
60
+ if (face.kind === "embedded") return require_embedded_font.encodeForShowEmbedded(text, face.face).width1000 / GLYPH_SPACE_UNITS_PER_EM * sizePt;
61
+ const { width1000 } = require_afm_widths.encodeForShow(text, face.standardName);
62
+ return width1000 / GLYPH_SPACE_UNITS_PER_EM * sizePt * standardWidthCorrectionFor(font.family);
31
63
  },
32
64
  lineHeightAtSize(font, sizePt) {
33
- return require_afm_widths.STANDARD_METRICS[standardNameFor(font)].lineHeightEm * sizePt;
65
+ const face = resolve(font);
66
+ if (face.kind === "embedded") {
67
+ const vertical = verticalMetricsFor(face.face, verticalPolicy);
68
+ return (vertical.ascentGlyphSpace - vertical.descentGlyphSpace + vertical.lineGapGlyphSpace) / GLYPH_SPACE_UNITS_PER_EM * sizePt;
69
+ }
70
+ return require_afm_widths.STANDARD_METRICS[face.standardName].lineHeightEm * sizePt;
34
71
  },
35
72
  ascenderAtSize(font, sizePt) {
36
- return require_afm_widths.STANDARD_METRICS[standardNameFor(font)].ascender / 1e3 * sizePt;
73
+ const face = resolve(font);
74
+ if (face.kind === "embedded") return verticalMetricsFor(face.face, verticalPolicy).ascentGlyphSpace / GLYPH_SPACE_UNITS_PER_EM * sizePt;
75
+ return require_afm_widths.STANDARD_METRICS[face.standardName].ascender / GLYPH_SPACE_UNITS_PER_EM * sizePt;
37
76
  },
38
77
  descenderAtSize(font, sizePt) {
39
- return require_afm_widths.STANDARD_METRICS[standardNameFor(font)].descender / 1e3 * sizePt;
78
+ const face = resolve(font);
79
+ if (face.kind === "embedded") return verticalMetricsFor(face.face, verticalPolicy).descentGlyphSpace / GLYPH_SPACE_UNITS_PER_EM * sizePt;
80
+ return require_afm_widths.STANDARD_METRICS[face.standardName].descender / GLYPH_SPACE_UNITS_PER_EM * sizePt;
40
81
  },
41
82
  underlineAtSize(font, sizePt) {
42
- const metrics = require_afm_widths.STANDARD_METRICS[standardNameFor(font)];
83
+ const face = resolve(font);
84
+ if (face.kind === "embedded") return {
85
+ offsetPt: face.face.metrics.underlinePositionGlyphSpace / GLYPH_SPACE_UNITS_PER_EM * sizePt,
86
+ thicknessPt: face.face.metrics.underlineThicknessGlyphSpace / GLYPH_SPACE_UNITS_PER_EM * sizePt
87
+ };
88
+ const metrics = require_afm_widths.STANDARD_METRICS[face.standardName];
43
89
  return {
44
- offsetPt: metrics.underlinePosition / 1e3 * sizePt,
45
- thicknessPt: metrics.underlineThickness / 1e3 * sizePt
90
+ offsetPt: metrics.underlinePosition / GLYPH_SPACE_UNITS_PER_EM * sizePt,
91
+ thicknessPt: metrics.underlineThickness / GLYPH_SPACE_UNITS_PER_EM * sizePt
46
92
  };
47
93
  },
48
94
  horizontalScaleFor(font) {
49
- return correctionFor(font.family);
95
+ return resolve(font).kind === "embedded" ? EMBEDDED_HORIZONTAL_SCALE : standardWidthCorrectionFor(font.family);
50
96
  }
51
97
  };
52
98
  }
99
+ function createStandardFontMeasurer(options = {}) {
100
+ return createFontMeasurer(void 0, options);
101
+ }
53
102
  //#endregion
103
+ exports.DEFAULT_VERTICAL_METRIC_POLICY = DEFAULT_VERTICAL_METRIC_POLICY;
104
+ exports.createFontMeasurer = createFontMeasurer;
54
105
  exports.createStandardFontMeasurer = createStandardFontMeasurer;
@@ -1,3 +1,4 @@
1
+ import { t as FontRegistry } from "./font-registry-yby02snZ.cjs";
1
2
  import { LayoutFont } from "document-schema.js";
2
3
  //#region src/measure.d.ts
3
4
  interface UnderlineMetrics {
@@ -12,9 +13,15 @@ interface TextMeasurer {
12
13
  underlineAtSize(font: LayoutFont, sizePt: number): UnderlineMetrics;
13
14
  horizontalScaleFor(font: LayoutFont): number;
14
15
  }
16
+ type VerticalMetricPolicy = 'hhea' | 'os2Typo' | 'os2Win';
17
+ declare const DEFAULT_VERTICAL_METRIC_POLICY: VerticalMetricPolicy;
15
18
  interface StandardFontMeasurerOptions {
16
19
  readonly widthCorrectionByFamily?: Readonly<Record<string, number>>;
17
20
  }
21
+ interface FontMeasurerOptions extends StandardFontMeasurerOptions {
22
+ readonly verticalMetrics?: VerticalMetricPolicy;
23
+ }
24
+ declare function createFontMeasurer(registry?: FontRegistry, options?: FontMeasurerOptions): TextMeasurer;
18
25
  declare function createStandardFontMeasurer(options?: StandardFontMeasurerOptions): TextMeasurer;
19
26
  //#endregion
20
- export { StandardFontMeasurerOptions, TextMeasurer, UnderlineMetrics, createStandardFontMeasurer };
27
+ export { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, TextMeasurer, UnderlineMetrics, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer };