reamkit 0.1.0-alpha.0 → 1.0.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.
- package/README.md +106 -30
- package/dist/esm/{bidi → core/bidi}/algorithm.js +1 -1
- package/dist/esm/{bidi → core/bidi}/char-types.js +1 -1
- package/dist/esm/{bidi → core/bidi}/index.js +1 -1
- package/dist/esm/core/bytes.d.ts +1 -0
- package/dist/esm/core/bytes.js +11 -0
- package/dist/esm/core/converter/facade.d.ts +45 -0
- package/dist/esm/core/converter/facade.js +89 -0
- package/dist/esm/core/converter/index.d.ts +4 -0
- package/dist/esm/core/converter/project.d.ts +4 -0
- package/dist/esm/core/converter/project.js +16 -0
- package/dist/esm/core/converter/ream.d.ts +35 -0
- package/dist/esm/core/converter/ream.js +100 -0
- package/dist/esm/{crypto → core/crypto}/asn1.js +1 -1
- package/dist/esm/{crypto → core/crypto}/cms.js +1 -1
- package/dist/esm/core/document-model/index.d.ts +1 -0
- package/dist/esm/{document-model → core/document-model}/types.d.ts +57 -41
- package/dist/esm/{ooxml → core}/drawingml/chart-parser.d.ts +1 -1
- package/dist/esm/{ooxml → core}/drawingml/chart-parser.js +6 -29
- package/dist/esm/{ooxml → core}/drawingml/colors.d.ts +3 -0
- package/dist/esm/{ooxml → core}/drawingml/colors.js +32 -2
- package/dist/esm/{ooxml → core}/drawingml/theme-parser.js +2 -2
- package/dist/esm/{font → core/font}/arabic-joining.js +1 -1
- package/dist/esm/{font → core/font}/binary-reader.js +1 -1
- package/dist/esm/{font → core/font}/font-registry.d.ts +1 -0
- package/dist/esm/{font → core/font}/font-registry.js +17 -16
- package/dist/esm/{font → core/font}/index.d.ts +1 -0
- package/dist/esm/{font → core/font}/opentype-layout.js +1 -1
- package/dist/esm/{font → core/font}/ttf-parser.js +1 -1
- package/dist/esm/{font → core/font}/ttf-subset.js +1 -1
- package/dist/esm/core/fonts/provider.d.ts +60 -0
- package/dist/esm/core/fonts/provider.js +163 -0
- package/dist/esm/{fonts → core/fonts}/remote-fonts.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/index.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/liang.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/patterns-en-us.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/patterns-ru.js +1 -1
- package/dist/esm/core/ir/adapters.d.ts +37 -0
- package/dist/esm/core/ir/features.d.ts +25 -0
- package/dist/esm/core/ir/features.js +24 -0
- package/dist/esm/core/ir/flow.d.ts +24 -0
- package/dist/esm/core/ir/index.d.ts +11 -0
- package/dist/esm/core/ir/loss.d.ts +22 -0
- package/dist/esm/core/ir/loss.js +15 -0
- package/dist/esm/core/ir/resources.d.ts +16 -0
- package/dist/esm/core/ir/resources.js +50 -0
- package/dist/esm/core/ir/units.d.ts +16 -0
- package/dist/esm/core/ir/units.js +41 -0
- package/dist/esm/core/line-breaker/index.d.ts +2 -0
- package/dist/esm/{line-breaker → core/line-breaker}/knuth-plass.js +1 -1
- package/dist/esm/{numbering → core/numbering}/state.js +1 -1
- package/dist/esm/{opc → core/opc}/core-properties.js +1 -1
- package/dist/esm/{opc → core/opc}/package.js +1 -1
- package/dist/esm/{opc → core/opc}/relationship-types.js +1 -1
- package/dist/esm/{opc → core/opc}/relationships.js +1 -1
- package/dist/esm/{ooxml/wordproc → core}/po-helpers.js +1 -1
- package/dist/esm/{style-cascade → core/style-cascade}/index.d.ts +2 -2
- package/dist/esm/core/style-cascade/index.js +2 -0
- package/dist/esm/{style-cascade → core/style-cascade}/resolver.d.ts +1 -0
- package/dist/esm/{style-cascade → core/style-cascade}/resolver.js +14 -9
- package/dist/esm/{style-cascade → core/style-cascade}/types.d.ts +8 -7
- package/dist/esm/{style-cascade → core/style-cascade}/types.js +9 -8
- package/dist/esm/{ooxml/spreadsheet → excel}/cell-reference.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/defined-name-ref.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/index.d.ts +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/number-format.js +1 -1
- package/dist/esm/excel/print-model.d.ts +18 -0
- package/dist/esm/{converter/xlsx-to-pdf.js → excel/print-model.js} +39 -148
- package/dist/esm/{ooxml/spreadsheet → excel}/shared-strings-parser.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/styles-parser.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/workbook-parser.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/worksheet-parser.js +1 -1
- package/dist/esm/excel/xlsx-reader.d.ts +4 -0
- package/dist/esm/excel/xlsx-reader.js +91 -0
- package/dist/esm/{converter → excel}/xlsx-to-pdf.d.ts +13 -2
- package/dist/esm/excel/xlsx-to-pdf.js +69 -0
- package/dist/esm/index.d.ts +23 -8
- package/dist/esm/index.js +18 -11
- package/dist/esm/pdf/chart-geometry.d.ts +1 -1
- package/dist/esm/pdf/cid-font.d.ts +7 -1
- package/dist/esm/pdf/cid-font.js +33 -22
- package/dist/esm/pdf/image-xobject.d.ts +13 -0
- package/dist/esm/pdf/image-xobject.js +55 -54
- package/dist/esm/pdf/index.d.ts +2 -2
- package/dist/esm/pdf/math-layout.d.ts +1 -1
- package/dist/esm/pdf/preset-geometry.d.ts +1 -1
- package/dist/esm/pdf/signature.js +4 -4
- package/dist/esm/pdf/styled-page-emitter.d.ts +5 -0
- package/dist/esm/pdf/styled-page-emitter.js +542 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +189 -14
- package/dist/esm/pdf/styled-page-renderer.js +168 -654
- package/dist/esm/pdf/text-page-renderer.d.ts +1 -1
- package/dist/esm/svg/svg-writer.d.ts +8 -0
- package/dist/esm/svg/svg-writer.js +138 -0
- package/dist/esm/word/document-parser.d.ts +16 -0
- package/dist/esm/{ooxml/wordproc → word}/document-parser.js +55 -47
- package/dist/esm/word/docx-reader.d.ts +4 -0
- package/dist/esm/word/docx-reader.js +190 -0
- package/dist/esm/word/docx-to-pdf.d.ts +34 -0
- package/dist/esm/word/docx-to-pdf.js +112 -0
- package/dist/esm/{ooxml/wordproc → word}/drawing-parser.d.ts +10 -9
- package/dist/esm/{ooxml/wordproc → word}/drawing-parser.js +15 -42
- package/dist/esm/{ooxml/wordproc → word}/font-table.d.ts +2 -2
- package/dist/esm/{ooxml/wordproc → word}/font-table.js +2 -2
- package/dist/esm/{ooxml/wordproc → word}/index.d.ts +3 -2
- package/dist/esm/{ooxml/wordproc → word}/numbering-parser.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/numbering-parser.js +1 -1
- package/dist/esm/{ooxml/math → word}/omml-parser.d.ts +2 -2
- package/dist/esm/{ooxml/math → word}/omml-parser.js +2 -2
- package/dist/esm/{ooxml/wordproc → word}/paragraph-properties.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/paragraph-properties.js +9 -8
- package/dist/esm/{ooxml/wordproc → word}/po-to-flat.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/po-to-flat.js +2 -2
- package/dist/esm/{ooxml/wordproc → word}/run-properties.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/run-properties.js +3 -2
- package/dist/esm/{ooxml/wordproc → word}/settings-parser.js +2 -2
- package/dist/esm/word/styles-parser.d.ts +2 -0
- package/dist/esm/{ooxml/wordproc → word}/styles-parser.js +4 -7
- package/dist/esm/word/table-parser.d.ts +4 -0
- package/dist/esm/{ooxml/wordproc → word}/table-parser.js +80 -26
- package/dist/esm/{ooxml/wordproc → word}/xml-helpers.js +1 -1
- package/package.json +5 -6
- package/dist/esm/converter/docx-to-pdf.d.ts +0 -15
- package/dist/esm/converter/docx-to-pdf.js +0 -227
- package/dist/esm/converter/index.d.ts +0 -4
- package/dist/esm/converter/index.js +0 -2
- package/dist/esm/document-model/index.d.ts +0 -1
- package/dist/esm/line-breaker/index.d.ts +0 -2
- package/dist/esm/ooxml/index.d.ts +0 -1
- package/dist/esm/ooxml/wordproc/document-parser.d.ts +0 -9
- package/dist/esm/ooxml/wordproc/styles-parser.d.ts +0 -3
- package/dist/esm/ooxml/wordproc/table-parser.d.ts +0 -3
- /package/dist/esm/{bidi → core/bidi}/algorithm.d.ts +0 -0
- /package/dist/esm/{bidi → core/bidi}/char-types.d.ts +0 -0
- /package/dist/esm/{bidi → core/bidi}/index.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/asn1.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/cms.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/index.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/index.js +0 -0
- /package/dist/esm/{document-model → core/document-model}/index.js +0 -0
- /package/dist/esm/{ooxml → core}/drawingml/theme-parser.d.ts +0 -0
- /package/dist/esm/{font → core/font}/arabic-joining.d.ts +0 -0
- /package/dist/esm/{font → core/font}/binary-reader.d.ts +0 -0
- /package/dist/esm/{font → core/font}/opentype-layout.d.ts +0 -0
- /package/dist/esm/{font → core/font}/ttf-parser.d.ts +0 -0
- /package/dist/esm/{font → core/font}/ttf-subset.d.ts +0 -0
- /package/dist/esm/{fonts → core/fonts}/index.d.ts +0 -0
- /package/dist/esm/{fonts → core/fonts}/remote-fonts.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/index.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/liang.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/patterns-en-us.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/patterns-ru.d.ts +0 -0
- /package/dist/esm/{line-breaker → core/line-breaker}/knuth-plass.d.ts +0 -0
- /package/dist/esm/{numbering → core/numbering}/index.d.ts +0 -0
- /package/dist/esm/{numbering → core/numbering}/state.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/core-properties.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/index.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/index.js +0 -0
- /package/dist/esm/{opc → core/opc}/package.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/relationship-types.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/relationships.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → core}/po-helpers.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/cell-reference.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/defined-name-ref.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/index.js +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/number-format.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/shared-strings-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/styles-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/workbook-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/worksheet-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/index.js +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/settings-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/text-extractor.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/text-extractor.js +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/xml-helpers.d.ts +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeBag, Pt, ResourceId } from '../ir/index.js';
|
|
1
2
|
export type Alignment = 'left' | 'right' | 'center' | 'both' | 'distribute';
|
|
2
3
|
export type UnderlineStyle = 'none' | 'single' | 'double' | 'thick' | 'dotted' | 'dottedHeavy' | 'dash' | 'dashHeavy' | 'wave';
|
|
3
4
|
export type VerticalAlign = 'baseline' | 'superscript' | 'subscript';
|
|
@@ -13,7 +14,7 @@ export interface RunProperties {
|
|
|
13
14
|
readonly italic?: boolean;
|
|
14
15
|
readonly underline?: UnderlineStyle;
|
|
15
16
|
readonly strike?: boolean;
|
|
16
|
-
readonly
|
|
17
|
+
readonly fontSizePt?: Pt;
|
|
17
18
|
readonly colorHex?: string;
|
|
18
19
|
readonly fontFamily?: FontFamilyMap;
|
|
19
20
|
readonly verticalAlign?: VerticalAlign;
|
|
@@ -23,13 +24,13 @@ export interface RunProperties {
|
|
|
23
24
|
export interface ParagraphProperties {
|
|
24
25
|
readonly styleId?: string;
|
|
25
26
|
readonly alignment?: Alignment;
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
27
|
+
readonly spacingBefore?: Pt;
|
|
28
|
+
readonly spacingAfter?: Pt;
|
|
29
|
+
readonly spacingLine?: Pt;
|
|
29
30
|
readonly spacingLineRule?: 'auto' | 'exact' | 'atLeast';
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
readonly
|
|
31
|
+
readonly indentLeft?: Pt;
|
|
32
|
+
readonly indentRight?: Pt;
|
|
33
|
+
readonly indentFirstLine?: Pt;
|
|
33
34
|
readonly runProperties?: RunProperties;
|
|
34
35
|
readonly numbering?: NumberingReference;
|
|
35
36
|
readonly pageBreakBefore?: boolean;
|
|
@@ -37,9 +38,9 @@ export interface ParagraphProperties {
|
|
|
37
38
|
readonly outlineLevel?: number;
|
|
38
39
|
}
|
|
39
40
|
export interface InlineImage {
|
|
40
|
-
readonly
|
|
41
|
-
readonly
|
|
42
|
-
readonly
|
|
41
|
+
readonly resource?: ResourceId;
|
|
42
|
+
readonly width: Pt;
|
|
43
|
+
readonly height: Pt;
|
|
43
44
|
}
|
|
44
45
|
export type MathNode = MathRow | MathRun | MathFraction | MathScript | MathRadical | MathNary | MathFunc | MathLimit | MathDelimiter | MathMatrix | MathAccent | MathBar | MathGroupChr | MathEqArray;
|
|
45
46
|
export interface MathRow {
|
|
@@ -122,6 +123,7 @@ export interface MathEqArray {
|
|
|
122
123
|
readonly rows: ReadonlyArray<MathNode>;
|
|
123
124
|
}
|
|
124
125
|
export interface Run {
|
|
126
|
+
readonly native?: NativeBag;
|
|
125
127
|
readonly text: string;
|
|
126
128
|
readonly properties: RunProperties;
|
|
127
129
|
readonly inlineImage?: InlineImage;
|
|
@@ -129,6 +131,7 @@ export interface Run {
|
|
|
129
131
|
readonly pageBreak?: boolean;
|
|
130
132
|
}
|
|
131
133
|
export interface Paragraph {
|
|
134
|
+
readonly native?: NativeBag;
|
|
132
135
|
readonly properties: ParagraphProperties;
|
|
133
136
|
readonly runs: ReadonlyArray<Run>;
|
|
134
137
|
}
|
|
@@ -174,7 +177,7 @@ export interface StyleSheet {
|
|
|
174
177
|
export type BorderStyle = 'none' | 'single' | 'double' | 'thick' | 'dotted' | 'dashed';
|
|
175
178
|
export interface Border {
|
|
176
179
|
readonly style: BorderStyle;
|
|
177
|
-
readonly
|
|
180
|
+
readonly width?: Pt;
|
|
178
181
|
readonly colorHex?: string;
|
|
179
182
|
}
|
|
180
183
|
export interface CellBorders {
|
|
@@ -186,31 +189,33 @@ export interface CellBorders {
|
|
|
186
189
|
readonly insideV?: Border;
|
|
187
190
|
}
|
|
188
191
|
export interface CellMargins {
|
|
189
|
-
readonly
|
|
190
|
-
readonly
|
|
191
|
-
readonly
|
|
192
|
-
readonly
|
|
192
|
+
readonly top?: Pt;
|
|
193
|
+
readonly right?: Pt;
|
|
194
|
+
readonly bottom?: Pt;
|
|
195
|
+
readonly left?: Pt;
|
|
193
196
|
}
|
|
194
197
|
export interface CellShading {
|
|
195
198
|
readonly colorHex: string;
|
|
196
199
|
}
|
|
200
|
+
export type CellMerge = 'start' | 'middle' | 'end';
|
|
197
201
|
export interface CellProperties {
|
|
198
|
-
readonly
|
|
199
|
-
readonly
|
|
200
|
-
readonly
|
|
202
|
+
readonly width?: Pt;
|
|
203
|
+
readonly colSpan?: number;
|
|
204
|
+
readonly merge?: CellMerge;
|
|
201
205
|
readonly borders?: CellBorders;
|
|
202
206
|
readonly margins?: CellMargins;
|
|
203
207
|
readonly shading?: CellShading;
|
|
204
208
|
}
|
|
205
209
|
export interface RowProperties {
|
|
206
|
-
readonly
|
|
210
|
+
readonly height?: Pt;
|
|
207
211
|
readonly heightRule?: 'auto' | 'atLeast' | 'exact';
|
|
208
212
|
readonly cantSplit?: boolean;
|
|
209
213
|
readonly isHeader?: boolean;
|
|
210
214
|
readonly pageBreakBefore?: boolean;
|
|
211
215
|
}
|
|
212
216
|
export interface TableProperties {
|
|
213
|
-
readonly
|
|
217
|
+
readonly widthPt?: Pt;
|
|
218
|
+
readonly widthFraction?: number;
|
|
214
219
|
readonly widthType?: 'auto' | 'dxa' | 'pct' | 'nil';
|
|
215
220
|
readonly layout?: 'auto' | 'fixed';
|
|
216
221
|
readonly defaultCellMargins?: CellMargins;
|
|
@@ -226,14 +231,15 @@ export interface TableRow {
|
|
|
226
231
|
readonly cells: ReadonlyArray<TableCell>;
|
|
227
232
|
}
|
|
228
233
|
export interface Table {
|
|
234
|
+
readonly native?: NativeBag;
|
|
229
235
|
readonly properties: TableProperties;
|
|
230
|
-
readonly grid: ReadonlyArray<
|
|
236
|
+
readonly grid: ReadonlyArray<Pt>;
|
|
231
237
|
readonly rows: ReadonlyArray<TableRow>;
|
|
232
238
|
}
|
|
233
239
|
export interface ImageBlock {
|
|
234
|
-
readonly
|
|
235
|
-
readonly
|
|
236
|
-
readonly
|
|
240
|
+
readonly resource?: ResourceId;
|
|
241
|
+
readonly width: Pt;
|
|
242
|
+
readonly height: Pt;
|
|
237
243
|
readonly paragraphProperties: ParagraphProperties;
|
|
238
244
|
readonly altText?: string;
|
|
239
245
|
}
|
|
@@ -286,7 +292,7 @@ export interface ShapeFill {
|
|
|
286
292
|
}
|
|
287
293
|
export type ShapeDash = 'solid' | 'dot' | 'dash' | 'dashDot' | 'lgDash' | 'lgDashDot' | 'sysDash' | 'sysDot';
|
|
288
294
|
export interface ShapeLine {
|
|
289
|
-
readonly
|
|
295
|
+
readonly width?: Pt;
|
|
290
296
|
readonly colorHex?: string;
|
|
291
297
|
readonly dash?: ShapeDash;
|
|
292
298
|
readonly cap?: 'flat' | 'round' | 'square';
|
|
@@ -299,15 +305,15 @@ export interface ShapeTransform {
|
|
|
299
305
|
}
|
|
300
306
|
export interface ShapeTextBody {
|
|
301
307
|
readonly content: ReadonlyArray<BodyElement>;
|
|
302
|
-
readonly
|
|
303
|
-
readonly
|
|
304
|
-
readonly
|
|
305
|
-
readonly
|
|
308
|
+
readonly insetLeft?: Pt;
|
|
309
|
+
readonly insetTop?: Pt;
|
|
310
|
+
readonly insetRight?: Pt;
|
|
311
|
+
readonly insetBottom?: Pt;
|
|
306
312
|
readonly anchor?: 't' | 'ctr' | 'b';
|
|
307
313
|
}
|
|
308
314
|
export interface ShapeBlock {
|
|
309
|
-
readonly
|
|
310
|
-
readonly
|
|
315
|
+
readonly width: Pt;
|
|
316
|
+
readonly height: Pt;
|
|
311
317
|
readonly geometry: ShapeGeometry;
|
|
312
318
|
readonly fill: ShapeFill;
|
|
313
319
|
readonly line?: ShapeLine;
|
|
@@ -344,8 +350,8 @@ export interface Chart {
|
|
|
344
350
|
}
|
|
345
351
|
export interface ChartBlock {
|
|
346
352
|
readonly chartRelId: string;
|
|
347
|
-
readonly
|
|
348
|
-
readonly
|
|
353
|
+
readonly width: Pt;
|
|
354
|
+
readonly height: Pt;
|
|
349
355
|
readonly paragraphProperties: ParagraphProperties;
|
|
350
356
|
readonly altText?: string;
|
|
351
357
|
}
|
|
@@ -366,17 +372,17 @@ export type BodyElement = {
|
|
|
366
372
|
readonly chart: ChartBlock;
|
|
367
373
|
};
|
|
368
374
|
export interface PageSize {
|
|
369
|
-
readonly
|
|
370
|
-
readonly
|
|
375
|
+
readonly width: Pt;
|
|
376
|
+
readonly height: Pt;
|
|
371
377
|
readonly orientation?: 'portrait' | 'landscape';
|
|
372
378
|
}
|
|
373
379
|
export interface PageMargins {
|
|
374
|
-
readonly
|
|
375
|
-
readonly
|
|
376
|
-
readonly
|
|
377
|
-
readonly
|
|
378
|
-
readonly
|
|
379
|
-
readonly
|
|
380
|
+
readonly top: Pt;
|
|
381
|
+
readonly right: Pt;
|
|
382
|
+
readonly bottom: Pt;
|
|
383
|
+
readonly left: Pt;
|
|
384
|
+
readonly header?: Pt;
|
|
385
|
+
readonly footer?: Pt;
|
|
380
386
|
}
|
|
381
387
|
export type HeaderFooterType = 'default' | 'first' | 'even';
|
|
382
388
|
export interface HeaderFooterReference {
|
|
@@ -401,3 +407,13 @@ export interface DocumentModel {
|
|
|
401
407
|
readonly numbering?: Numbering;
|
|
402
408
|
readonly section?: SectionProperties;
|
|
403
409
|
}
|
|
410
|
+
export interface DocumentInfo {
|
|
411
|
+
readonly title?: string;
|
|
412
|
+
readonly author?: string;
|
|
413
|
+
readonly subject?: string;
|
|
414
|
+
readonly keywords?: string;
|
|
415
|
+
readonly creator?: string;
|
|
416
|
+
readonly producer?: string;
|
|
417
|
+
readonly creationDate?: Date;
|
|
418
|
+
readonly modificationDate?: Date;
|
|
419
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { poAttr, poChildren, poFindByPath, poFindDescendant, poIntAttr, poIs, poTag, poText, poVal } from "../
|
|
1
|
+
import { poAttr, poChildren, poFindByPath, poFindDescendant, poIntAttr, poIs, poTag, poText, poVal } from "../po-helpers.js";
|
|
2
|
+
import { resolveColorNode } from "./colors.js";
|
|
2
3
|
import { XMLParser } from "fast-xml-parser";
|
|
3
|
-
//#region src/
|
|
4
|
+
//#region src/core/drawingml/chart-parser.ts
|
|
4
5
|
var decoder = new TextDecoder("utf-8");
|
|
5
6
|
var parser = new XMLParser({
|
|
6
7
|
ignoreAttributes: false,
|
|
@@ -109,35 +110,11 @@ function fillColorOf(spPr, resolveColor) {
|
|
|
109
110
|
const lnFill = ln ? poChildren(ln).find((c) => poIs(c, "a:solidFill")) : void 0;
|
|
110
111
|
return lnFill ? colorFromSolidFill(lnFill, resolveColor) : void 0;
|
|
111
112
|
}
|
|
112
|
-
function colorMods(colorNode) {
|
|
113
|
-
const mods = [];
|
|
114
|
-
for (const c of poChildren(colorNode)) for (const kind of [
|
|
115
|
-
"lumMod",
|
|
116
|
-
"lumOff",
|
|
117
|
-
"shade",
|
|
118
|
-
"tint",
|
|
119
|
-
"alpha"
|
|
120
|
-
]) if (poIs(c, `a:${kind}`)) {
|
|
121
|
-
const v = poIntAttr(c, "val");
|
|
122
|
-
if (v !== void 0) mods.push({
|
|
123
|
-
kind,
|
|
124
|
-
val: v / 1e5
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return mods;
|
|
128
|
-
}
|
|
129
113
|
function colorFromSolidFill(solid, resolveColor) {
|
|
130
114
|
for (const c of poChildren(solid)) {
|
|
131
|
-
|
|
132
|
-
if (!
|
|
133
|
-
|
|
134
|
-
if (!v) continue;
|
|
135
|
-
const mods = colorMods(c);
|
|
136
|
-
const raw = isSrgb ? { srgb: v } : { scheme: v };
|
|
137
|
-
return resolveColor(mods.length > 0 ? {
|
|
138
|
-
...raw,
|
|
139
|
-
mods
|
|
140
|
-
} : raw);
|
|
115
|
+
if (!poIs(c, "a:srgbClr") && !poIs(c, "a:schemeClr")) continue;
|
|
116
|
+
if (!poAttr(c, "val")) continue;
|
|
117
|
+
return resolveColorNode(c, resolveColor);
|
|
141
118
|
}
|
|
142
119
|
}
|
|
143
120
|
function collectAT(node) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PoNode } from '../po-helpers.js';
|
|
1
2
|
export interface ColorMod {
|
|
2
3
|
readonly kind: 'lumMod' | 'lumOff' | 'shade' | 'tint' | 'alpha';
|
|
3
4
|
readonly val: number;
|
|
@@ -15,3 +16,5 @@ export declare const DEFAULT_THEME_PALETTE: ReadonlyMap<string, string>;
|
|
|
15
16
|
export declare function resolveSchemeName(name: string): string;
|
|
16
17
|
export declare function makeColorResolver(palette: ReadonlyMap<string, string>): ColorResolver;
|
|
17
18
|
export declare const defaultColorResolver: ColorResolver;
|
|
19
|
+
export declare function readColorMods(colorNode: PoNode): Array<ColorMod>;
|
|
20
|
+
export declare function resolveColorNode(c: PoNode, resolveColor: ColorResolver): string | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { poAttr, poChildren, poIntAttr, poIs } from "../po-helpers.js";
|
|
2
|
+
//#region src/core/drawingml/colors.ts
|
|
2
3
|
function clamp01(x) {
|
|
3
4
|
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
4
5
|
}
|
|
@@ -121,5 +122,34 @@ function makeColorResolver(palette) {
|
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
var defaultColorResolver = makeColorResolver(DEFAULT_THEME_PALETTE);
|
|
125
|
+
function readColorMods(colorNode) {
|
|
126
|
+
const mods = [];
|
|
127
|
+
for (const c of poChildren(colorNode)) for (const kind of [
|
|
128
|
+
"lumMod",
|
|
129
|
+
"lumOff",
|
|
130
|
+
"shade",
|
|
131
|
+
"tint",
|
|
132
|
+
"alpha"
|
|
133
|
+
]) if (poIs(c, `a:${kind}`)) {
|
|
134
|
+
const v = poIntAttr(c, "val");
|
|
135
|
+
if (v !== void 0) mods.push({
|
|
136
|
+
kind,
|
|
137
|
+
val: v / 1e5
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return mods;
|
|
141
|
+
}
|
|
142
|
+
function resolveColorNode(c, resolveColor) {
|
|
143
|
+
const isSrgb = poIs(c, "a:srgbClr");
|
|
144
|
+
if (!isSrgb && !poIs(c, "a:schemeClr")) return void 0;
|
|
145
|
+
const v = poAttr(c, "val");
|
|
146
|
+
if (!v) return void 0;
|
|
147
|
+
const mods = readColorMods(c);
|
|
148
|
+
const raw = isSrgb ? { srgb: v } : { scheme: v };
|
|
149
|
+
return resolveColor(mods.length > 0 ? {
|
|
150
|
+
...raw,
|
|
151
|
+
mods
|
|
152
|
+
} : raw);
|
|
153
|
+
}
|
|
124
154
|
//#endregion
|
|
125
|
-
export { DEFAULT_THEME_PALETTE, defaultColorResolver, makeColorResolver };
|
|
155
|
+
export { DEFAULT_THEME_PALETTE, defaultColorResolver, makeColorResolver, resolveColorNode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { poAttr, poChildren, poFindByPath, poIs, poTag } from "../
|
|
1
|
+
import { poAttr, poChildren, poFindByPath, poIs, poTag } from "../po-helpers.js";
|
|
2
2
|
import { XMLParser } from "fast-xml-parser";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/core/drawingml/theme-parser.ts
|
|
4
4
|
var decoder = new TextDecoder("utf-8");
|
|
5
5
|
var parser = new XMLParser({
|
|
6
6
|
ignoreAttributes: false,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ParsedTtf } from './ttf-parser.js';
|
|
2
2
|
export type FontVariant = 'regular' | 'bold' | 'italic' | 'boldItalic';
|
|
3
|
+
export declare function pickVariant(has: (variant: FontVariant) => boolean, bold: boolean, italic: boolean): FontVariant | undefined;
|
|
3
4
|
export interface FontBytesByVariant {
|
|
4
5
|
readonly regular: Uint8Array;
|
|
5
6
|
readonly bold?: Uint8Array;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { parseTtf } from "./ttf-parser.js";
|
|
2
|
-
//#region src/font/font-registry.ts
|
|
2
|
+
//#region src/core/font/font-registry.ts
|
|
3
|
+
function pickVariant(has, bold, italic) {
|
|
4
|
+
return (bold && italic ? [
|
|
5
|
+
"boldItalic",
|
|
6
|
+
"bold",
|
|
7
|
+
"italic",
|
|
8
|
+
"regular"
|
|
9
|
+
] : bold ? ["bold", "regular"] : italic ? ["italic", "regular"] : ["regular"]).find(has);
|
|
10
|
+
}
|
|
3
11
|
var FontRegistry = class FontRegistry {
|
|
4
12
|
constructor(fonts) {
|
|
5
13
|
this.fonts = fonts;
|
|
@@ -13,20 +21,13 @@ var FontRegistry = class FontRegistry {
|
|
|
13
21
|
return new FontRegistry(map);
|
|
14
22
|
}
|
|
15
23
|
resolveByStyle(bold, italic) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const parsed = this.fonts.get(v);
|
|
24
|
-
if (parsed) return {
|
|
25
|
-
variant: v,
|
|
26
|
-
parsed
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
throw new Error("FontRegistry has no regular font");
|
|
24
|
+
const variant = pickVariant((v) => this.fonts.has(v), bold, italic);
|
|
25
|
+
const parsed = variant ? this.fonts.get(variant) : void 0;
|
|
26
|
+
if (!variant || !parsed) throw new Error("FontRegistry has no regular font");
|
|
27
|
+
return {
|
|
28
|
+
variant,
|
|
29
|
+
parsed
|
|
30
|
+
};
|
|
30
31
|
}
|
|
31
32
|
entries() {
|
|
32
33
|
return this.fonts.entries();
|
|
@@ -36,4 +37,4 @@ var FontRegistry = class FontRegistry {
|
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
//#endregion
|
|
39
|
-
export { FontRegistry };
|
|
40
|
+
export { FontRegistry, pickVariant };
|
|
@@ -3,5 +3,6 @@ export type { ParsedTtf, TtfTableInfo } from './ttf-parser.js';
|
|
|
3
3
|
export { subsetTtf, glyphClosure } from './ttf-subset.js';
|
|
4
4
|
export { FontRegistry } from './font-registry.js';
|
|
5
5
|
export type { FontVariant, FontBytesByVariant } from './font-registry.js';
|
|
6
|
+
export { pickVariant } from './font-registry.js';
|
|
6
7
|
export { parseGposKerning, parseGsubLigatures, shapeText } from './opentype-layout.js';
|
|
7
8
|
export type { KerningMap, LigatureMap, ShapedRun } from './opentype-layout.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigEndianReader } from "./binary-reader.js";
|
|
2
2
|
import { assignArabicForms } from "./arabic-joining.js";
|
|
3
|
-
//#region src/font/opentype-layout.ts
|
|
3
|
+
//#region src/core/font/opentype-layout.ts
|
|
4
4
|
var EMPTY_JOINING_FORMS = {
|
|
5
5
|
init: /* @__PURE__ */ new Map(),
|
|
6
6
|
medi: /* @__PURE__ */ new Map(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigEndianReader } from "./binary-reader.js";
|
|
2
2
|
import { parseGposKerning, parseGsubArabicForms, parseGsubLigatures } from "./opentype-layout.js";
|
|
3
|
-
//#region src/font/ttf-parser.ts
|
|
3
|
+
//#region src/core/font/ttf-parser.ts
|
|
4
4
|
var SFNT_TRUETYPE = 65536;
|
|
5
5
|
var SFNT_OPENTYPE_CFF = 1330926671;
|
|
6
6
|
function parseTtf(raw) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FetchLike } from './remote-fonts.js';
|
|
2
|
+
import { FontBytesByVariant, FontRegistry } from '../font/index.js';
|
|
3
|
+
export interface FontRequest {
|
|
4
|
+
/** Family name as the document references it (e.g. "Times New Roman"). */
|
|
5
|
+
readonly family?: string;
|
|
6
|
+
readonly bold: boolean;
|
|
7
|
+
readonly italic: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type FontAnswer = {
|
|
10
|
+
readonly kind: 'bytes';
|
|
11
|
+
readonly bytes: Uint8Array;
|
|
12
|
+
/** Face the bytes actually are (for substitution reporting). */
|
|
13
|
+
readonly faceName: string;
|
|
14
|
+
/** Which provider answered (chain bookkeeping). */
|
|
15
|
+
readonly providerId: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'none';
|
|
18
|
+
};
|
|
19
|
+
export declare const NO_FONT: FontAnswer;
|
|
20
|
+
export interface FontProvider {
|
|
21
|
+
/** 'embedded' | 'caller' | 'local' | 'remote' | custom ids. */
|
|
22
|
+
readonly id: string;
|
|
23
|
+
resolve: (req: FontRequest) => Promise<FontAnswer>;
|
|
24
|
+
}
|
|
25
|
+
/** First byte-level answer wins; 'none' falls through to the next provider. */
|
|
26
|
+
export declare function chainProviders(providers: ReadonlyArray<FontProvider>): FontProvider;
|
|
27
|
+
/**
|
|
28
|
+
* Caller-supplied bytes — answers every family (the caller chose these fonts
|
|
29
|
+
* deliberately). Falls back through bold/italic → regular like the registry.
|
|
30
|
+
*/
|
|
31
|
+
export declare function callerFontProvider(fonts: FontBytesByVariant): FontProvider;
|
|
32
|
+
/**
|
|
33
|
+
* Fonts embedded in the source document itself (docx fontTable), keyed by the
|
|
34
|
+
* normalized family name — an exact-name match, never a substitution.
|
|
35
|
+
*/
|
|
36
|
+
export declare function embeddedDocFontProvider(embedded: ReadonlyMap<string, FontRegistry>): FontProvider;
|
|
37
|
+
/**
|
|
38
|
+
* Open CDN substitutes (Roboto / Tinos / Cousine — the LibreOffice mapping).
|
|
39
|
+
* Always answers; the chain reports it as a substitution.
|
|
40
|
+
*/
|
|
41
|
+
export declare function remoteFontProvider(options?: {
|
|
42
|
+
readonly fetch?: FetchLike;
|
|
43
|
+
}): FontProvider;
|
|
44
|
+
/**
|
|
45
|
+
* OS/2 fsType embedding permissions (OpenType §OS/2). Returns undefined when
|
|
46
|
+
* the table is absent/corrupt. The licensing nibble: 0 = installable,
|
|
47
|
+
* 2 = RESTRICTED (no embedding), 4 = preview & print, 8 = editable.
|
|
48
|
+
*/
|
|
49
|
+
export declare function readOs2FsType(bytes: Uint8Array): number | undefined;
|
|
50
|
+
/** True when the fsType licensing nibble forbids embedding entirely. */
|
|
51
|
+
export declare function isEmbeddingRestricted(fsType: number | undefined): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* System fonts via the Local Font Access API (Chromium 103+, permission
|
|
54
|
+
* prompt). OPT-IN by design: never wired in implicitly. Returns 'none' when
|
|
55
|
+
* the API is unavailable (Node, Safari, Firefox), the family is not installed,
|
|
56
|
+
* or the face's OS/2 fsType marks embedding as restricted — embedding a
|
|
57
|
+
* restricted font into a PDF would violate its license, so the chain falls
|
|
58
|
+
* through to a substitute instead.
|
|
59
|
+
*/
|
|
60
|
+
export declare function localFontProvider(): FontProvider;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { fetchFontSet, resolveFamilyKey } from "./remote-fonts.js";
|
|
2
|
+
import { pickVariant } from "../font/font-registry.js";
|
|
3
|
+
//#region src/core/fonts/provider.ts
|
|
4
|
+
var NO_FONT = { kind: "none" };
|
|
5
|
+
/** First byte-level answer wins; 'none' falls through to the next provider. */
|
|
6
|
+
function chainProviders(providers) {
|
|
7
|
+
return {
|
|
8
|
+
id: "chain",
|
|
9
|
+
resolve: async (req) => {
|
|
10
|
+
for (const p of providers) {
|
|
11
|
+
const answer = await p.resolve(req);
|
|
12
|
+
if (answer.kind !== "none") return answer;
|
|
13
|
+
}
|
|
14
|
+
return NO_FONT;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function variantFor(req) {
|
|
19
|
+
if (req.bold && req.italic) return "boldItalic";
|
|
20
|
+
if (req.bold) return "bold";
|
|
21
|
+
if (req.italic) return "italic";
|
|
22
|
+
return "regular";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Caller-supplied bytes — answers every family (the caller chose these fonts
|
|
26
|
+
* deliberately). Falls back through bold/italic → regular like the registry.
|
|
27
|
+
*/
|
|
28
|
+
function callerFontProvider(fonts) {
|
|
29
|
+
return {
|
|
30
|
+
id: "caller",
|
|
31
|
+
resolve: (req) => {
|
|
32
|
+
const v = variantFor(req);
|
|
33
|
+
const bytes = fonts[pickVariant((x) => fonts[x] !== void 0, req.bold, req.italic) ?? "regular"] ?? fonts.regular;
|
|
34
|
+
return Promise.resolve({
|
|
35
|
+
kind: "bytes",
|
|
36
|
+
bytes,
|
|
37
|
+
faceName: `caller:${v}`,
|
|
38
|
+
providerId: "caller"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fonts embedded in the source document itself (docx fontTable), keyed by the
|
|
45
|
+
* normalized family name — an exact-name match, never a substitution.
|
|
46
|
+
*/
|
|
47
|
+
function embeddedDocFontProvider(embedded) {
|
|
48
|
+
return {
|
|
49
|
+
id: "embedded",
|
|
50
|
+
resolve: (req) => {
|
|
51
|
+
const name = req.family?.trim().toLowerCase();
|
|
52
|
+
const registry = name ? embedded.get(name) : void 0;
|
|
53
|
+
if (!registry) return Promise.resolve(NO_FONT);
|
|
54
|
+
const { parsed } = registry.resolveByStyle(req.bold, req.italic);
|
|
55
|
+
return Promise.resolve({
|
|
56
|
+
kind: "bytes",
|
|
57
|
+
bytes: parsed.raw,
|
|
58
|
+
faceName: req.family,
|
|
59
|
+
providerId: "embedded"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Open CDN substitutes (Roboto / Tinos / Cousine — the LibreOffice mapping).
|
|
66
|
+
* Always answers; the chain reports it as a substitution.
|
|
67
|
+
*/
|
|
68
|
+
function remoteFontProvider(options = {}) {
|
|
69
|
+
const cache = /* @__PURE__ */ new Map();
|
|
70
|
+
return {
|
|
71
|
+
id: "remote",
|
|
72
|
+
resolve: async (req) => {
|
|
73
|
+
const family = resolveFamilyKey(req.family ?? "");
|
|
74
|
+
let set = cache.get(family);
|
|
75
|
+
if (!set) {
|
|
76
|
+
set = fetchFontSet({
|
|
77
|
+
family,
|
|
78
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
79
|
+
});
|
|
80
|
+
cache.set(family, set);
|
|
81
|
+
}
|
|
82
|
+
const fonts = await set;
|
|
83
|
+
return {
|
|
84
|
+
kind: "bytes",
|
|
85
|
+
bytes: fonts[pickVariant((x) => fonts[x] !== void 0, req.bold, req.italic) ?? "regular"] ?? fonts.regular,
|
|
86
|
+
faceName: family,
|
|
87
|
+
providerId: "remote"
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* OS/2 fsType embedding permissions (OpenType §OS/2). Returns undefined when
|
|
94
|
+
* the table is absent/corrupt. The licensing nibble: 0 = installable,
|
|
95
|
+
* 2 = RESTRICTED (no embedding), 4 = preview & print, 8 = editable.
|
|
96
|
+
*/
|
|
97
|
+
function readOs2FsType(bytes) {
|
|
98
|
+
if (bytes.length < 12) return void 0;
|
|
99
|
+
const u16 = (o) => bytes[o] << 8 | bytes[o + 1];
|
|
100
|
+
const u32 = (o) => u16(o) * 65536 + u16(o + 2);
|
|
101
|
+
const numTables = u16(4);
|
|
102
|
+
for (let i = 0; i < numTables; i++) {
|
|
103
|
+
const rec = 12 + i * 16;
|
|
104
|
+
if (rec + 16 > bytes.length) return void 0;
|
|
105
|
+
if (String.fromCharCode(bytes[rec], bytes[rec + 1], bytes[rec + 2], bytes[rec + 3]) !== "OS/2") continue;
|
|
106
|
+
const offset = u32(rec + 8);
|
|
107
|
+
if (offset + 10 > bytes.length) return void 0;
|
|
108
|
+
return u16(offset + 8);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** True when the fsType licensing nibble forbids embedding entirely. */
|
|
112
|
+
function isEmbeddingRestricted(fsType) {
|
|
113
|
+
if (fsType === void 0) return false;
|
|
114
|
+
return (fsType & 15) === 2;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* System fonts via the Local Font Access API (Chromium 103+, permission
|
|
118
|
+
* prompt). OPT-IN by design: never wired in implicitly. Returns 'none' when
|
|
119
|
+
* the API is unavailable (Node, Safari, Firefox), the family is not installed,
|
|
120
|
+
* or the face's OS/2 fsType marks embedding as restricted — embedding a
|
|
121
|
+
* restricted font into a PDF would violate its license, so the chain falls
|
|
122
|
+
* through to a substitute instead.
|
|
123
|
+
*/
|
|
124
|
+
function localFontProvider() {
|
|
125
|
+
const query = globalThis.queryLocalFonts;
|
|
126
|
+
return {
|
|
127
|
+
id: "local",
|
|
128
|
+
resolve: async (req) => {
|
|
129
|
+
if (!query || !req.family) return NO_FONT;
|
|
130
|
+
let faces;
|
|
131
|
+
try {
|
|
132
|
+
faces = await query();
|
|
133
|
+
} catch {
|
|
134
|
+
return NO_FONT;
|
|
135
|
+
}
|
|
136
|
+
const family = req.family.trim().toLowerCase();
|
|
137
|
+
const wantBold = req.bold;
|
|
138
|
+
const wantItalic = req.italic;
|
|
139
|
+
const candidates = faces.filter((f) => f.family.trim().toLowerCase() === family);
|
|
140
|
+
if (candidates.length === 0) return NO_FONT;
|
|
141
|
+
const styleMatches = (f) => {
|
|
142
|
+
const s = f.style.toLowerCase();
|
|
143
|
+
return s.includes("bold") === wantBold && (s.includes("italic") || s.includes("oblique")) === wantItalic;
|
|
144
|
+
};
|
|
145
|
+
const face = candidates.find(styleMatches) ?? candidates[0];
|
|
146
|
+
try {
|
|
147
|
+
const blob = await face.blob();
|
|
148
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
149
|
+
if (isEmbeddingRestricted(readOs2FsType(bytes))) return NO_FONT;
|
|
150
|
+
return {
|
|
151
|
+
kind: "bytes",
|
|
152
|
+
bytes,
|
|
153
|
+
faceName: face.fullName,
|
|
154
|
+
providerId: "local"
|
|
155
|
+
};
|
|
156
|
+
} catch {
|
|
157
|
+
return NO_FONT;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { NO_FONT, callerFontProvider, chainProviders, embeddedDocFontProvider, isEmbeddingRestricted, localFontProvider, readOs2FsType, remoteFontProvider };
|