reamkit 1.29.0 → 1.31.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 (106) hide show
  1. package/README.md +60 -24
  2. package/dist/esm/core/converter/project.js +3 -1
  3. package/dist/esm/core/crypto/offcrypto.js +1 -1
  4. package/dist/esm/core/document-model/index.d.ts +1 -1
  5. package/dist/esm/core/document-model/types.d.ts +65 -0
  6. package/dist/esm/core/drawingml/shape-render.js +13 -1
  7. package/dist/esm/core/font/index.d.ts +2 -0
  8. package/dist/esm/core/font/ttf-build.d.ts +113 -0
  9. package/dist/esm/core/font/ttf-build.js +1224 -0
  10. package/dist/esm/core/font/ttf-subset.d.ts +19 -0
  11. package/dist/esm/core/font/ttf-subset.js +14 -1
  12. package/dist/esm/core/fonts/index.d.ts +1 -1
  13. package/dist/esm/core/fonts/provider.d.ts +17 -0
  14. package/dist/esm/core/fonts/provider.js +27 -2
  15. package/dist/esm/core/fonts/remote-fonts.d.ts +8 -0
  16. package/dist/esm/core/fonts/remote-fonts.js +108 -18
  17. package/dist/esm/core/ir/flow.d.ts +88 -1
  18. package/dist/esm/core/numbering/index.d.ts +1 -1
  19. package/dist/esm/core/numbering/state.d.ts +11 -1
  20. package/dist/esm/core/numbering/state.js +10 -1
  21. package/dist/esm/core/style-cascade/resolver.js +35 -4
  22. package/dist/esm/core/style-cascade/types.d.ts +19 -1
  23. package/dist/esm/core/style-cascade/types.js +3 -0
  24. package/dist/esm/index.d.ts +2 -2
  25. package/dist/esm/layout/page-doc.d.ts +10 -3
  26. package/dist/esm/layout/styled-layout.d.ts +48 -7
  27. package/dist/esm/layout/styled-layout.js +881 -119
  28. package/dist/esm/layout/turned-section.d.ts +38 -0
  29. package/dist/esm/layout/turned-section.js +193 -0
  30. package/dist/esm/pdf/styled-page-emitter.js +78 -2
  31. package/dist/esm/pdf-reader/annot-draw.js +93 -1
  32. package/dist/esm/pdf-reader/annots.d.ts +18 -0
  33. package/dist/esm/pdf-reader/annots.js +86 -9
  34. package/dist/esm/pdf-reader/cff-outline.d.ts +27 -0
  35. package/dist/esm/pdf-reader/cff-outline.js +169 -21
  36. package/dist/esm/pdf-reader/cmap.js +5 -2
  37. package/dist/esm/pdf-reader/content.d.ts +70 -4
  38. package/dist/esm/pdf-reader/content.js +172 -12
  39. package/dist/esm/pdf-reader/display.d.ts +36 -0
  40. package/dist/esm/pdf-reader/display.js +82 -1
  41. package/dist/esm/pdf-reader/document.js +5 -1
  42. package/dist/esm/pdf-reader/embedded-fonts.d.ts +25 -0
  43. package/dist/esm/pdf-reader/embedded-fonts.js +78 -9
  44. package/dist/esm/pdf-reader/encodings.d.ts +8 -0
  45. package/dist/esm/pdf-reader/encodings.js +25 -3
  46. package/dist/esm/pdf-reader/face-outlines.d.ts +78 -0
  47. package/dist/esm/pdf-reader/face-outlines.js +362 -0
  48. package/dist/esm/pdf-reader/figures.d.ts +52 -0
  49. package/dist/esm/pdf-reader/figures.js +433 -0
  50. package/dist/esm/pdf-reader/flow-build.d.ts +224 -7
  51. package/dist/esm/pdf-reader/flow-build.js +545 -39
  52. package/dist/esm/pdf-reader/font.d.ts +27 -1
  53. package/dist/esm/pdf-reader/font.js +632 -63
  54. package/dist/esm/pdf-reader/glyf-outline.d.ts +33 -0
  55. package/dist/esm/pdf-reader/glyf-outline.js +148 -3
  56. package/dist/esm/pdf-reader/glyph-names.js +154 -1
  57. package/dist/esm/pdf-reader/glyph-shapes.d.ts +18 -0
  58. package/dist/esm/pdf-reader/glyph-shapes.js +57 -0
  59. package/dist/esm/pdf-reader/image-decode.js +70 -4
  60. package/dist/esm/pdf-reader/images.d.ts +5 -0
  61. package/dist/esm/pdf-reader/images.js +4 -2
  62. package/dist/esm/pdf-reader/jbig2.d.ts +40 -1
  63. package/dist/esm/pdf-reader/jbig2.js +78 -16
  64. package/dist/esm/pdf-reader/jpeg.d.ts +6 -3
  65. package/dist/esm/pdf-reader/jpeg.js +21 -1
  66. package/dist/esm/pdf-reader/layout.d.ts +119 -2
  67. package/dist/esm/pdf-reader/layout.js +2219 -184
  68. package/dist/esm/pdf-reader/lexer.d.ts +10 -0
  69. package/dist/esm/pdf-reader/lexer.js +17 -0
  70. package/dist/esm/pdf-reader/page-numbers.d.ts +53 -0
  71. package/dist/esm/pdf-reader/page-numbers.js +167 -0
  72. package/dist/esm/pdf-reader/pattern-tint.d.ts +11 -1
  73. package/dist/esm/pdf-reader/pattern-tint.js +21 -3
  74. package/dist/esm/pdf-reader/regions.d.ts +25 -0
  75. package/dist/esm/pdf-reader/regions.js +167 -0
  76. package/dist/esm/pdf-reader/shading.d.ts +58 -2
  77. package/dist/esm/pdf-reader/shading.js +181 -11
  78. package/dist/esm/pdf-reader/struct-tree.js +112 -8
  79. package/dist/esm/pdf-reader/tagged.js +207 -28
  80. package/dist/esm/pdf-reader/text-rules.js +1 -1
  81. package/dist/esm/pdf-reader/text.d.ts +6 -3
  82. package/dist/esm/pdf-reader/text.js +106 -22
  83. package/dist/esm/pdf-reader/type1-outline.d.ts +11 -0
  84. package/dist/esm/pdf-reader/type1-outline.js +63 -8
  85. package/dist/esm/pdf-reader/vector.d.ts +8 -2
  86. package/dist/esm/pdf-reader/vector.js +105 -6
  87. package/dist/esm/word/doc/doc-reader.js +6 -2
  88. package/dist/esm/word/doc/doc-text.d.ts +6 -0
  89. package/dist/esm/word/doc/doc-text.js +19 -1
  90. package/dist/esm/word/document-parser.d.ts +2 -2
  91. package/dist/esm/word/document-parser.js +11 -1
  92. package/dist/esm/word/docx-reader.js +5 -3
  93. package/dist/esm/word/docx-writer.js +341 -54
  94. package/dist/esm/word/drawing-parser.d.ts +5 -3
  95. package/dist/esm/word/drawing-parser.js +56 -10
  96. package/dist/esm/word/font-embed.d.ts +30 -0
  97. package/dist/esm/word/font-embed.js +173 -0
  98. package/dist/esm/word/font-table.d.ts +10 -0
  99. package/dist/esm/word/font-table.js +13 -1
  100. package/dist/esm/word/index.js +1 -1
  101. package/dist/esm/word/numbering-parser.d.ts +3 -1
  102. package/dist/esm/word/numbering-parser.js +2 -1
  103. package/dist/esm/word/paragraph-properties.d.ts +7 -6
  104. package/dist/esm/word/paragraph-properties.js +16 -2
  105. package/dist/esm/word/run-properties.js +26 -0
  106. package/package.json +12 -5
@@ -1,3 +1,4 @@
1
+ import { standardEncodingTable } from "./encodings.js";
1
2
  //#region src/pdf-reader/cff-outline.ts
2
3
  /**
3
4
  * Prepare an embedded CFF program for outline reading.
@@ -69,6 +70,90 @@ function cffCidToGid(program) {
69
70
  return;
70
71
  }
71
72
  }
73
+ /**
74
+ * How far the pen moves after a name-keyed CFF program's `space`, in
75
+ * thousandths of an em — the width a writer gives the space a page never
76
+ * showed, which is the one it was typeset with.
77
+ *
78
+ * @param program The raw CFF bytes.
79
+ * @returns The advance, or `undefined` where the program has no `space` or its
80
+ * width cannot be read off the charstring.
81
+ */
82
+ function cffSpaceAdvance(program) {
83
+ try {
84
+ const font = parseCff(program);
85
+ const gid = font?.nameToGid?.get("space");
86
+ if (!font || gid === void 0) return void 0;
87
+ const width = glyphWidth(font, gid);
88
+ return width === void 0 ? void 0 : width * font.scale * 1e3;
89
+ } catch {
90
+ return;
91
+ }
92
+ }
93
+ /**
94
+ * TN 5177 §4.1 — a glyph's width: `nominalWidthX` plus the operand a
95
+ * charstring puts before its first stack-clearing operator, or
96
+ * `defaultWidthX` where it puts none. Whether one is there is a matter of
97
+ * COUNT — one more than the operator takes.
98
+ */
99
+ function glyphWidth(font, gid) {
100
+ const code = font.charStrings[gid];
101
+ if (!code) return void 0;
102
+ const { defaultWidth, nominalWidth } = font.widthsOf(gid);
103
+ const stack = [];
104
+ for (let i = 0; i < code.length;) {
105
+ const b = code[i++];
106
+ if (b === 28) {
107
+ stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
108
+ i += 2;
109
+ } else if (b >= 32 && b <= 246) stack.push(b - 139);
110
+ else if (b >= 247 && b <= 250) stack.push((b - 247) * 256 + code[i++] + 108);
111
+ else if (b >= 251 && b <= 254) stack.push(-(b - 251) * 256 - code[i++] - 108);
112
+ else if (b === 255) {
113
+ stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
114
+ i += 4;
115
+ } else {
116
+ const takes = b === 21 ? 2 : b === 22 || b === 4 ? 1 : b === 14 ? stack.length >= 4 ? 4 : 0 : -1;
117
+ if (b === 1 || b === 3 || b === 18 || b === 23 || b === 19 || b === 20) return stack.length % 2 === 1 ? nominalWidth + stack[0] : defaultWidth;
118
+ if (takes < 0) return void 0;
119
+ return stack.length > takes ? nominalWidth + stack[0] : defaultWidth;
120
+ }
121
+ }
122
+ }
123
+ /**
124
+ * The embedding a CFF program's licence allows: CFF has no OS/2 table, and
125
+ * Adobe writes the OS/2 `fsType` into the Top DICT's `PostScript` string
126
+ * instead (TN 5176 §9, key 12 21) as `/FSType 8 def`.
127
+ *
128
+ * @param program The raw CFF bytes.
129
+ * @returns The value, or `undefined` where the program states none.
130
+ */
131
+ function cffFsType(program) {
132
+ try {
133
+ const names = readIndex(program, program[2] ?? 4);
134
+ const tops = names ? readIndex(program, names.end) : void 0;
135
+ const strings = tops ? readIndex(program, tops.end) : void 0;
136
+ const top = tops?.items[0];
137
+ if (!top || !strings) return void 0;
138
+ const sid = parseDict(top).get(1221)?.[0];
139
+ if (sid === void 0 || sid < STANDARD_STRINGS.length) return void 0;
140
+ const own = strings.items[sid - STANDARD_STRINGS.length];
141
+ return own ? postScriptFsType(new TextDecoder("latin1").decode(own)) : void 0;
142
+ } catch {
143
+ return;
144
+ }
145
+ }
146
+ /**
147
+ * The `/FSType n def` a PostScript font program writes where an OpenType one
148
+ * has its OS/2 field (Adobe TN 5176 §9; a Type 1 font's `FontInfo` alike).
149
+ *
150
+ * @param text The PostScript to search.
151
+ * @returns The value, or `undefined` where the text states none.
152
+ */
153
+ function postScriptFsType(text) {
154
+ const m = /\/FSType\s+(\d+)\s+def/u.exec(text);
155
+ return m ? Number(m[1]) : void 0;
156
+ }
72
157
  /** The `CFF ` table of an OpenType wrapper, where the program is one. */
73
158
  function openTypeCff(program) {
74
159
  if (program.length < 12) return void 0;
@@ -102,27 +187,52 @@ function parseCff(program) {
102
187
  if (!charStrings) return void 0;
103
188
  const matrix = top.get(1207);
104
189
  const scale = matrix && matrix.length >= 4 ? matrix[0] ?? .001 : .001;
105
- const privateSubrs = (dict) => {
190
+ const privateOf = (dict) => {
191
+ const none = {
192
+ subrs: [],
193
+ widths: {
194
+ defaultWidth: 0,
195
+ nominalWidth: 0
196
+ }
197
+ };
106
198
  const priv = dict.get(18);
107
- if (!priv || priv.length < 2) return [];
199
+ if (!priv || priv.length < 2) return none;
108
200
  const size = priv[0];
109
201
  const offset = priv[1];
110
- if (offset < 0 || offset + size > program.length) return [];
111
- const subrsAt = parseDict(program.subarray(offset, offset + size)).get(19)?.[0];
112
- if (subrsAt === void 0) return [];
113
- return readIndex(program, offset + subrsAt)?.items ?? [];
202
+ if (offset < 0 || offset + size > program.length) return none;
203
+ const inner = parseDict(program.subarray(offset, offset + size));
204
+ const widths = {
205
+ defaultWidth: inner.get(20)?.[0] ?? 0,
206
+ nominalWidth: inner.get(21)?.[0] ?? 0
207
+ };
208
+ const subrsAt = inner.get(19)?.[0];
209
+ if (subrsAt === void 0) return {
210
+ subrs: [],
211
+ widths
212
+ };
213
+ return {
214
+ subrs: readIndex(program, offset + subrsAt)?.items ?? [],
215
+ widths
216
+ };
114
217
  };
115
218
  const isCid = top.has(1230);
116
219
  let localSubrs;
220
+ let widthsOf;
117
221
  if (isCid) {
118
222
  const fdArrayAt = top.get(1236)?.[0];
119
223
  const fdSelectAt = top.get(1237)?.[0];
120
- const subrsPerFd = (fdArrayAt !== void 0 ? readIndex(program, fdArrayAt)?.items ?? [] : []).map((fd) => privateSubrs(parseDict(fd)));
224
+ const privatePerFd = (fdArrayAt !== void 0 ? readIndex(program, fdArrayAt)?.items ?? [] : []).map((fd) => privateOf(parseDict(fd)));
121
225
  const select = fdSelectAt !== void 0 ? readFdSelect(program, fdSelectAt, charStrings.items.length) : void 0;
122
- localSubrs = (gid) => subrsPerFd[select ? select[gid] ?? 0 : 0] ?? [];
226
+ const privateFor = (gid) => privatePerFd[select ? select[gid] ?? 0 : 0];
227
+ localSubrs = (gid) => privateFor(gid)?.subrs ?? [];
228
+ widthsOf = (gid) => privateFor(gid)?.widths ?? {
229
+ defaultWidth: 0,
230
+ nominalWidth: 0
231
+ };
123
232
  } else {
124
- const only = privateSubrs(top);
125
- localSubrs = () => only;
233
+ const only = privateOf(top);
234
+ localSubrs = () => only.subrs;
235
+ widthsOf = () => only.widths;
126
236
  }
127
237
  const charsetAt = top.get(15)?.[0];
128
238
  const sids = charsetAt !== void 0 && charsetAt > 2 ? readCharset(program, charsetAt, charStrings.items.length) : void 0;
@@ -134,7 +244,8 @@ function parseCff(program) {
134
244
  localSubrs,
135
245
  scale,
136
246
  ...cidToGid ? { cidToGid } : {},
137
- ...nameToGid ? { nameToGid } : {}
247
+ ...nameToGid ? { nameToGid } : {},
248
+ widthsOf
138
249
  };
139
250
  }
140
251
  /**
@@ -689,9 +800,10 @@ function bias(subrs) {
689
800
  /** How deep a charstring may call, and how many operators it may run. */
690
801
  var MAX_CALL_DEPTH = 10;
691
802
  var MAX_STEPS = 65536;
692
- function runGlyph(font, gid) {
803
+ function runGlyph(font, gid, part = false) {
693
804
  const program = font.charStrings[gid];
694
805
  if (!program) return void 0;
806
+ let seac;
695
807
  const local = font.localSubrs(gid);
696
808
  const localBias = bias(local);
697
809
  const globalBias = bias(font.globalSubrs);
@@ -885,7 +997,16 @@ function runGlyph(font, gid) {
885
997
  }
886
998
  case 11: return true;
887
999
  case 14:
888
- takeWidth(stack.length > 4 ? 4 : 0);
1000
+ takeWidth(stack.length >= 4 ? 4 : 0);
1001
+ if (stack.length >= 4) {
1002
+ const [adx = 0, ady = 0, bchar = 0, achar = 0] = stack;
1003
+ seac = {
1004
+ adx,
1005
+ ady,
1006
+ bchar,
1007
+ achar
1008
+ };
1009
+ }
889
1010
  if (open) out.push({ op: "close" });
890
1011
  open = false;
891
1012
  return false;
@@ -919,8 +1040,35 @@ function runGlyph(font, gid) {
919
1040
  }
920
1041
  run(program, 0);
921
1042
  if (out.length > 0 && out[out.length - 1]?.op !== "close") out.push({ op: "close" });
922
- if (out.length === 0) return void 0;
923
- return out.map((seg) => scaleSeg(seg, font.scale));
1043
+ const own = out.map((seg) => scaleSeg(seg, font.scale));
1044
+ if (seac && !part) {
1045
+ const at = seac;
1046
+ const glyphOf = (code) => {
1047
+ const name = standardEncodingTable().get(code);
1048
+ const gid = name !== void 0 ? font.nameToGid?.get(name) : void 0;
1049
+ return gid !== void 0 ? runGlyph(font, gid, true) ?? [] : [];
1050
+ };
1051
+ own.push(...glyphOf(at.bchar), ...glyphOf(at.achar).map((seg) => shiftSeg(seg, at.adx * font.scale, at.ady * font.scale)));
1052
+ }
1053
+ return own.length > 0 ? own : void 0;
1054
+ }
1055
+ /** A segment moved by `(dx, dy)`: where a `seac` puts its accent. */
1056
+ function shiftSeg(seg, dx, dy) {
1057
+ if (seg.op === "close") return seg;
1058
+ if (seg.op === "cubic") return {
1059
+ op: "cubic",
1060
+ x1: seg.x1 + dx,
1061
+ y1: seg.y1 + dy,
1062
+ x2: seg.x2 + dx,
1063
+ y2: seg.y2 + dy,
1064
+ x: seg.x + dx,
1065
+ y: seg.y + dy
1066
+ };
1067
+ return {
1068
+ op: seg.op,
1069
+ x: seg.x + dx,
1070
+ y: seg.y + dy
1071
+ };
924
1072
  }
925
1073
  function runEscape(op, stack, trans) {
926
1074
  switch (op) {
@@ -1030,8 +1178,8 @@ function flexCurves(op, stack, x0, y0) {
1030
1178
  ]);
1031
1179
  push([
1032
1180
  n(4),
1033
- n(6),
1034
- 0
1181
+ n(5),
1182
+ n(6)
1035
1183
  ], [
1036
1184
  0,
1037
1185
  startY - y,
@@ -1051,12 +1199,12 @@ function flexCurves(op, stack, x0, y0) {
1051
1199
  ]);
1052
1200
  push([
1053
1201
  n(5),
1054
- n(7),
1202
+ n(6),
1055
1203
  n(8)
1056
1204
  ], [
1057
1205
  0,
1058
- n(6),
1059
- startY - (y + n(6))
1206
+ n(7),
1207
+ startY - (y + n(7))
1060
1208
  ]);
1061
1209
  y = startY;
1062
1210
  } else if (op === 37) {
@@ -1119,4 +1267,4 @@ function scaleSeg(seg, k) {
1119
1267
  };
1120
1268
  }
1121
1269
  //#endregion
1122
- export { cffCidToGid, cffNameToGid, cffOutlineSource, openTypeCff };
1270
+ export { cffCidToGid, cffFsType, cffNameToGid, cffOutlineSource, cffSpaceAdvance, openTypeCff, postScriptFsType };
@@ -45,8 +45,11 @@ function parseToUnicodeCMap(bytes) {
45
45
  const hiN = bytesToInt(hi.bytes);
46
46
  const dst = lexer.nextToken();
47
47
  if (dst.kind === "hexstr") {
48
- const base = stated(utf16be(dst.bytes));
49
- if (base !== void 0) for (let i = 0; loN + i <= hiN && i < MAX_RANGE; i++) map.set(loN + i, incString(base, i));
48
+ const base = utf16be(dst.bytes);
49
+ for (let i = 0; loN + i <= hiN && i < MAX_RANGE; i++) {
50
+ const text = stated(incString(base, i));
51
+ if (text !== void 0) map.set(loN + i, text);
52
+ }
50
53
  } else if (dst.kind === "arrayOpen") {
51
54
  let i = 0;
52
55
  for (;;) {
@@ -1,6 +1,5 @@
1
- import { ColorSpaceInfo, GsPaint } from './shading.js';
1
+ import { ColorSpaceInfo, GsPaint, PageGradient } from './shading.js';
2
2
  import { TextMarkup } from './annot-draw.js';
3
- import { ShapeGradient } from '../core/vector.js';
4
3
  import { PdfDict, PdfStream } from '../pdf/objects.js';
5
4
  /**
6
5
  * A page font as the interpreter needs it (built from the font dictionaries in
@@ -22,6 +21,15 @@ export interface ContentFont {
22
21
  decode: (codes: ReadonlyArray<number>) => string;
23
22
  /** Glyph advance for one code, in 1000-unit text space. */
24
23
  width: (code: number) => number;
24
+ /**
25
+ * §9.6.2.1 — the advance of the face's SPACE as the file states it, in
26
+ * 1000-unit text space: the code its encoding names `space`. Absent where
27
+ * the font states none — not the fallback {@link width} gives a code with no
28
+ * width of its own.
29
+ */
30
+ readonly spaceWidth?: number;
31
+ /** §9.8.2 — every glyph of the face is as wide as the next: a typewriter's. */
32
+ readonly fixedPitch?: boolean;
25
33
  /**
26
34
  * §9.4.4 / §9.7.4.3 — the face sets its text DOWN the page, not across, and
27
35
  * the pen advances by the vertical displacement `w1` rather than by `w0`.
@@ -48,6 +56,43 @@ export interface ContentFont {
48
56
  * this is the last resort before a blank page.
49
57
  */
50
58
  readonly outline?: GlyphOutline;
59
+ /**
60
+ * §9.9 — the face's embedded program, for a writer that embeds the face:
61
+ * the outline EVERY code draws, the program's licence, the descriptor's
62
+ * metrics. Only a face whose program this reads has one.
63
+ */
64
+ readonly program?: FaceProgram;
65
+ }
66
+ /**
67
+ * §9.9 — what a writer that embeds a face needs from its program: the outline
68
+ * each code draws, what the licence allows, and the metrics the descriptor
69
+ * states (§9.8.1).
70
+ */
71
+ export interface FaceProgram {
72
+ /**
73
+ * The contours a code draws, in a one-unit em — empty for a glyph the program
74
+ * holds that draws nothing, `undefined` where it holds none for the code.
75
+ */
76
+ readonly glyph: (code: number) => ReadonlyArray<PathSeg> | undefined;
77
+ /**
78
+ * OS/2 `fsType` — or the `/FSType` a CFF or Type 1 program writes in its
79
+ * place — where the program states one.
80
+ */
81
+ readonly fsType?: number;
82
+ /**
83
+ * How far the program's own space advances, in thousandths of an em — the
84
+ * width a writer gives a space the page never showed as a glyph.
85
+ */
86
+ readonly spaceAdvance?: number;
87
+ /** The program's PostScript name: the `/BaseFont` less its subset tag. */
88
+ readonly postScriptName: string;
89
+ /** §9.8.1 `/CapHeight` and `/XHeight`, in thousandths of an em, where stated. */
90
+ readonly capHeight?: number;
91
+ readonly xHeight?: number;
92
+ /** §9.8.1 `/ItalicAngle`, in degrees counterclockwise from the vertical. */
93
+ readonly italicAngle: number;
94
+ /** §9.8.2 `/Flags` bit 1 — every glyph has the same width. */
95
+ readonly fixedPitch: boolean;
51
96
  }
52
97
  /** §9.6.6 — the outlines of a face read by glyph index, and their glyph space. */
53
98
  export interface GlyphOutline {
@@ -107,6 +152,8 @@ export interface TextRun {
107
152
  * Absent where the face states no width for it.
108
153
  */
109
154
  readonly spaceWidthPt?: number;
155
+ /** §9.8.2 — the face sets every glyph as wide as the next (see `ContentFont`). */
156
+ readonly fixedPitch?: boolean;
110
157
  /** §9.8.1 — the face the glyphs were shown in is a bold one. */
111
158
  readonly bold?: boolean;
112
159
  /**
@@ -136,6 +183,12 @@ export interface TextRun {
136
183
  * leaves it to the picture.
137
184
  */
138
185
  readonly invisible?: boolean;
186
+ /**
187
+ * §12.5.5 — drawn by an annotation's appearance rather than by the page: a
188
+ * field's value, a button's caption, a tick. It stands in the annotation's
189
+ * box, which is placed where the page has it, not in the page's reading.
190
+ */
191
+ readonly annotation?: boolean;
139
192
  /**
140
193
  * §9.3.6 — the colour the glyphs are STROKED in, when the rendering mode
141
194
  * asks for a stroke, and how wide the pen is.
@@ -245,7 +298,7 @@ export interface VectorPlacement {
245
298
  /** Fill colour (6-hex), present iff the path is filled (`f` / `F` / `f*` / `B` / `b`). */
246
299
  readonly fillHex?: string;
247
300
  /** Shading pattern, present iff filled with one (EP16c). */
248
- readonly gradient?: ShapeGradient;
301
+ readonly gradient?: PageGradient;
249
302
  /** §11.6.4.4 `/ca` — how opaque the fill is, when the page asked for less. */
250
303
  readonly alpha?: number;
251
304
  /**
@@ -271,10 +324,18 @@ export interface VectorPlacement {
271
324
  * known by walking into it; the `fillHex` beside this is not the fill.
272
325
  */
273
326
  readonly patternName?: string;
327
+ /** §8.7.3.3 — the colour `scn` gave an uncoloured pattern, where it gave one. */
328
+ readonly patternPaint?: string;
274
329
  /** Stroke colour (6-hex), present iff the path is stroked (`S` / `s` / `B` / `b`) — EP11. */
275
330
  readonly strokeHex?: string;
276
331
  /** Stroke width in page-space points — EP11. */
277
332
  readonly lineWidth?: number;
333
+ /** §8.4.3.6 — the stroke's dash lengths in page-space points, where it is dashed. */
334
+ readonly dash?: ReadonlyArray<number>;
335
+ /** §8.4.3.3 — the stroke's cap, where it is not the butt cap every line starts with. */
336
+ readonly cap?: 'round' | 'square';
337
+ /** §11.6.4.4 `/CA` — how opaque the stroke is, when the page asked for less than all. */
338
+ readonly strokeAlpha?: number;
278
339
  readonly mcid?: number;
279
340
  }
280
341
  /** Everything {@link interpretContent} extracts from one page's content stream. */
@@ -296,6 +357,11 @@ export interface InterpretResult {
296
357
  * there is something to draw.
297
358
  */
298
359
  readonly outlines: Array<VectorPlacement>;
360
+ /**
361
+ * §9.4.3 — the codes each font with a readable program showed where the
362
+ * page paints them: the glyphs a writer embedding the face has to carry.
363
+ */
364
+ readonly shown: ReadonlyMap<ContentFont, ReadonlySet<number>>;
299
365
  }
300
366
  /**
301
367
  * §9.6.5 — one showing of a Type 3 glyph: which procedure, and the matrix that
@@ -357,7 +423,7 @@ export type Matrix = readonly [number, number, number, number, number, number];
357
423
  export declare const IDENTITY: Matrix;
358
424
  /** Compose two {@link Matrix matrices}: `a` applied first, then `b`. */
359
425
  export declare function multiply(a: Matrix, b: Matrix): Matrix;
360
- export declare function interpretContent(bytes: Uint8Array, fonts: ReadonlyMap<string, ContentFont>, initialCtm?: Matrix, shadings?: ReadonlyMap<string, ShapeGradient>, alphas?: ReadonlyMap<string, GsPaint>, spaces?: ReadonlyMap<string, ColorSpaceInfo>, hiddenOc?: ReadonlySet<string>): InterpretResult;
426
+ export declare function interpretContent(bytes: Uint8Array, fonts: ReadonlyMap<string, ContentFont>, initialCtm?: Matrix, shadings?: ReadonlyMap<string, PageGradient>, alphas?: ReadonlyMap<string, GsPaint>, spaces?: ReadonlyMap<string, ColorSpaceInfo>, hiddenOc?: ReadonlySet<string>): InterpretResult;
361
427
  /**
362
428
  * Whether a string is wholly right-to-left: at least one letter of an RTL
363
429
  * script and nothing of any other, spaces and joiners aside.