@shbernal/ts-pptx 3.2.0 → 3.4.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 +19 -20
- package/dist/{autopage-QQyfRtoK.js → autopage-BYlTzX-l.js} +21 -17
- package/dist/autopage-BYlTzX-l.js.map +1 -0
- package/dist/browser.d.ts +6 -6
- package/dist/browser.js +11 -12
- package/dist/browser.js.map +1 -1
- package/dist/{diagnostics-Chjz_4_Q.d.ts → diagnostics-B0OmTOoz.d.ts} +65 -16
- package/dist/diagnostics-B0OmTOoz.d.ts.map +1 -0
- package/dist/{diagnostics-DYQC7xLV.js → diagnostics-CPVADSL1.js} +0 -0
- package/dist/{diagnostics-DYQC7xLV.js.map → diagnostics-CPVADSL1.js.map} +1 -1
- package/dist/{enums-CoXnxiCI.d.ts → enums-CvRYniUA.d.ts} +13 -3
- package/dist/{enums-CoXnxiCI.d.ts.map → enums-CvRYniUA.d.ts.map} +1 -1
- package/dist/{errors-BVLCFr-t.d.ts → errors-fB1KDJKQ.d.ts} +5 -5
- package/dist/{errors-BVLCFr-t.d.ts.map → errors-fB1KDJKQ.d.ts.map} +1 -1
- package/dist/{fit-DhMbQG5O.js → fit-TjpNbMru.js} +0 -0
- package/dist/fit-TjpNbMru.js.map +1 -0
- package/dist/{html-dom-DajBuobe.js → html-dom-yUSdCExA.js} +5 -6
- package/dist/html-dom-yUSdCExA.js.map +1 -0
- package/dist/html.d.ts +3 -3
- package/dist/html.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -34
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +1 -1
- package/dist/inspect.js +5 -4
- package/dist/inspect.js.map +1 -1
- package/dist/math.d.ts +1 -1
- package/dist/measure.d.ts +96 -6
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +2 -2
- package/dist/{st-enums-evQG2A7Z.js → namespaces-Sy_m7Nhd.js} +318 -209
- package/dist/namespaces-Sy_m7Nhd.js.map +1 -0
- package/dist/node.d.ts +6 -6
- package/dist/node.js +7 -20
- package/dist/node.js.map +1 -1
- package/dist/notes-bWApshah.js +1727 -0
- package/dist/notes-bWApshah.js.map +1 -0
- package/dist/{pres-C-EU3SkN.d.ts → pres-Dybf7ZUl.d.ts} +4 -4
- package/dist/{pres-C-EU3SkN.d.ts.map → pres-Dybf7ZUl.d.ts.map} +1 -1
- package/dist/{presentation-CxnUVhK9.js → presentation-3rAKKRfm.js} +1247 -743
- package/dist/presentation-3rAKKRfm.js.map +1 -0
- package/dist/{presentation-Osx1cDdJ.d.ts → presentation-types-D7cgT-eG.d.ts} +867 -24
- package/dist/presentation-types-D7cgT-eG.d.ts.map +1 -0
- package/dist/read.d.ts +4 -5
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +3 -3
- package/dist/script.d.ts +2 -2
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +0 -0
- package/dist/script.js.map +1 -1
- package/dist/{shapes-DoJBPrwN.js → shapes-Dyw5bxwO.js} +371 -52
- package/dist/shapes-Dyw5bxwO.js.map +1 -0
- package/dist/{slide-BTfn1Pyp.d.ts → slide-B_aInw3N.d.ts} +246 -182
- package/dist/slide-B_aInw3N.d.ts.map +1 -0
- package/dist/{text-C4P9MNdf.js → text-DSN3anEh.js} +3609 -4932
- package/dist/text-DSN3anEh.js.map +1 -0
- package/dist/{units-internal-CR8s8YQa.js → units-internal-DNvK2I6o.js} +207 -35
- package/dist/units-internal-DNvK2I6o.js.map +1 -0
- package/dist/zip.d.ts +2 -2
- package/package.json +36 -27
- package/dist/autopage-QQyfRtoK.js.map +0 -1
- package/dist/diagnostics-Chjz_4_Q.d.ts.map +0 -1
- package/dist/embedded-fonts-MaynAHa9.js +0 -94
- package/dist/embedded-fonts-MaynAHa9.js.map +0 -1
- package/dist/fit-DhMbQG5O.js.map +0 -1
- package/dist/html-dom-DajBuobe.js.map +0 -1
- package/dist/presentation-CxnUVhK9.js.map +0 -1
- package/dist/presentation-Osx1cDdJ.d.ts.map +0 -1
- package/dist/presentation-types-Dj4riuDs.d.ts +0 -538
- package/dist/presentation-types-Dj4riuDs.d.ts.map +0 -1
- package/dist/shapes-DoJBPrwN.js.map +0 -1
- package/dist/slide-BTfn1Pyp.d.ts.map +0 -1
- package/dist/st-enums-evQG2A7Z.js.map +0 -1
- package/dist/text-C4P9MNdf.js.map +0 -1
- package/dist/units-C7QM1KgH.js +0 -144
- package/dist/units-C7QM1KgH.js.map +0 -1
- package/dist/units-internal-CR8s8YQa.js.map +0 -1
package/dist/measure.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as TsPptxError, d as InvalidOptionErrorCode, f as MediaErrorCode, h as UnsupportedFeatureErrorCode, i as PackageReadError, l as ErrorCode, m as TsPptxCode, n as InvalidOptionError, o as TsPptxErrorOptions, p as PackageReadErrorCode, r as MediaError, s as UnsupportedFeatureError, t as InternalError, u as InternalErrorCode } from "./errors-
|
|
1
|
+
import { dn as TextMeasurement, en as MeasureTextOptions, fn as TextProps, i as ObjectOptions, pn as TextPropsOptions, rn as OverflowBoxOptions } from "./slide-B_aInw3N.js";
|
|
2
|
+
import { a as TsPptxError, d as InvalidOptionErrorCode, f as MediaErrorCode, h as UnsupportedFeatureErrorCode, i as PackageReadError, l as ErrorCode, m as TsPptxCode, n as InvalidOptionError, o as TsPptxErrorOptions, p as PackageReadErrorCode, r as MediaError, s as UnsupportedFeatureError, t as InternalError, u as InternalErrorCode } from "./errors-fB1KDJKQ.js";
|
|
3
3
|
//#region src/measure/font-metrics.d.ts
|
|
4
4
|
/** Per-(face,bold,italic) advance-width source backed by a parsed font file. */
|
|
5
5
|
interface FontMetrics {
|
|
@@ -26,8 +26,34 @@ interface FontMetrics {
|
|
|
26
26
|
* registered metrics at all does not engage measured fit, so this never fires there.
|
|
27
27
|
*/
|
|
28
28
|
declare function getHeuristicFontMetrics(): FontMetrics;
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/** Options for {@link parseFontMetrics}. */
|
|
30
|
+
interface ParseFontMetricsOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Which font to read out of a file that holds several: a 0-based index, or a name
|
|
33
|
+
* matched case-insensitively against the family, full, and PostScript names
|
|
34
|
+
* (`listFontFaces` lists them). Omitted selects the first.
|
|
35
|
+
*
|
|
36
|
+
* Collections (`.ttc`/`.otc`) are why this exists: `msgothic.ttc` is three fonts and
|
|
37
|
+
* `cambria.ttc` is two. The selector means the same thing for a plain TTF/OTF, which
|
|
38
|
+
* is a one-entry list, so a wrong index or an unmatched name is an error there rather
|
|
39
|
+
* than being ignored.
|
|
40
|
+
*/
|
|
41
|
+
readonly font?: number | string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse a font file into a `FontMetrics`. Lazily imports opentype.js.
|
|
45
|
+
*
|
|
46
|
+
* Reads plain TTF/OTF and **font collections** (`.ttc`/`.otc`); for a collection, pass
|
|
47
|
+
* `font` to say which member, since a collection has no single answer. The underlying
|
|
48
|
+
* parser does not read the `ttcf` wrapper, so the selected member is unwrapped into a
|
|
49
|
+
* standalone sfnt first (see `measure/font-collection.ts`).
|
|
50
|
+
* @param {Uint8Array} data - the font file's bytes
|
|
51
|
+
* @param {ParseFontMetricsOptions} [opts] - which font, for a file holding several
|
|
52
|
+
* @returns {Promise<FontMetrics>} advance widths and cmap coverage for that font
|
|
53
|
+
* @example await parseFontMetrics(bytes) // a plain .ttf
|
|
54
|
+
* @example await parseFontMetrics(ttcBytes, { font: 'MS PGothic' })
|
|
55
|
+
*/
|
|
56
|
+
declare function parseFontMetrics(data: Uint8Array, opts?: ParseFontMetricsOptions): Promise<FontMetrics>;
|
|
31
57
|
/**
|
|
32
58
|
* Registry of `FontMetrics` keyed by `(face, bold, italic)`. Variant advances
|
|
33
59
|
* differ, so bold/italic are stored separately; lookup falls back to the regular
|
|
@@ -188,6 +214,68 @@ type ResizeOutcome = {
|
|
|
188
214
|
declare function solveResize(paragraphs: FitParagraph[], box: FitBox, resolve: MetricsResolver): ResizeOutcome;
|
|
189
215
|
declare function solveShrink(paragraphs: FitParagraph[], box: FitBox, resolve: MetricsResolver): ShrinkOutcome;
|
|
190
216
|
//#endregion
|
|
217
|
+
//#region src/measure/font-collection.d.ts
|
|
218
|
+
/**
|
|
219
|
+
* Font **collection** (`.ttc` / `.otc`) support for the write-side metrics.
|
|
220
|
+
*
|
|
221
|
+
* A collection is a single file holding several fonts that share their heavy tables.
|
|
222
|
+
* `msgothic.ttc` is three fonts (MS Gothic, MS UI Gothic, MS PGothic) over one 5.5 MB
|
|
223
|
+
* `glyf`; `cambria.ttc` is Cambria plus Cambria Math over one outline set. On Windows
|
|
224
|
+
* that is how most of the East Asian faces ship, and Cambria too, so a measurement API
|
|
225
|
+
* that only reads a bare sfnt cannot measure them at all.
|
|
226
|
+
*
|
|
227
|
+
* `opentype.js` does not read the `ttcf` wrapper (it throws `Unsupported OpenType
|
|
228
|
+
* signature ttcf` from `parseBuffer`, still true in 2.0.0), so this module unwraps one
|
|
229
|
+
* member into a standalone sfnt before handing the bytes over. It parses only the two
|
|
230
|
+
* structures that requires: the table directories and the `name` table.
|
|
231
|
+
*
|
|
232
|
+
* Upstream tracks the gap as opentypejs/opentype.js#379, open since 2019, with #866 an
|
|
233
|
+
* unmerged PR implementing it; check both before rewriting any of this.
|
|
234
|
+
*
|
|
235
|
+
* ## Layout
|
|
236
|
+
*
|
|
237
|
+
* ```text
|
|
238
|
+
* 0 'ttcf' uint16 major, uint16 minor, uint32 numFonts, uint32 dirOffset[numFonts]
|
|
239
|
+
* ... per member: uint32 sfntVersion, uint16 numTables, uint16 searchRange,
|
|
240
|
+
* uint16 entrySelector, uint16 rangeShift, then numTables x 16-byte records
|
|
241
|
+
* { char tag[4], uint32 checksum, uint32 offset, uint32 length }
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* The record `offset` is **absolute from the start of the file**, which is the whole
|
|
245
|
+
* trick: two members name the same `glyf` bytes by pointing at them. So a member does
|
|
246
|
+
* not have to be *copied out* to be read on its own; it is enough to give the reader a
|
|
247
|
+
* buffer whose first bytes are that member's directory, leaving every table where it
|
|
248
|
+
* already sits. See {@link extractFontFace}.
|
|
249
|
+
*/
|
|
250
|
+
/** Identity of one font inside a font file, as read from its `name` table. */
|
|
251
|
+
interface FontFaceInfo {
|
|
252
|
+
/** Position in the file: `0` for a plain TTF/OTF, `0..n-1` inside a collection. */
|
|
253
|
+
readonly index: number;
|
|
254
|
+
/** `name` ID 1, e.g. `'MS PGothic'`. Absent when the table has no readable record. */
|
|
255
|
+
readonly family?: string;
|
|
256
|
+
/** `name` ID 2, e.g. `'Regular'`. */
|
|
257
|
+
readonly subfamily?: string;
|
|
258
|
+
/** `name` ID 4, e.g. `'MS PGothic'`. */
|
|
259
|
+
readonly fullName?: string;
|
|
260
|
+
/** `name` ID 6, e.g. `'MS-PGothic'`. */
|
|
261
|
+
readonly postScriptName?: string;
|
|
262
|
+
}
|
|
263
|
+
/** True when `data` starts with the `ttcf` tag, i.e. holds more than one font. */
|
|
264
|
+
declare function isFontCollection(data: Uint8Array): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* The fonts inside `data`, in file order. A plain TTF/OTF yields exactly one entry, so a
|
|
267
|
+
* caller never has to branch on the container format.
|
|
268
|
+
*
|
|
269
|
+
* Identity comes from each member's own `name` table, which is one of the tables a
|
|
270
|
+
* collection does *not* share. A field is absent when the table carries no readable
|
|
271
|
+
* record for it; a font whose `name` table is missing or malformed still yields an entry
|
|
272
|
+
* (with only `index`), because the metrics do not depend on it.
|
|
273
|
+
* @param {Uint8Array} data - the font file's bytes
|
|
274
|
+
* @returns {FontFaceInfo[]} one entry per font, index-ordered
|
|
275
|
+
* @example listFontFaces(readFileSync('C:/Windows/Fonts/msgothic.ttc')).map((f) => f.family)
|
|
276
|
+
*/
|
|
277
|
+
declare function listFontFaces(data: Uint8Array): FontFaceInfo[];
|
|
278
|
+
//#endregion
|
|
191
279
|
//#region src/measure/fit.d.ts
|
|
192
280
|
/**
|
|
193
281
|
* Layout-time text measurement against registered metrics — the public engine
|
|
@@ -205,7 +293,9 @@ declare function solveShrink(paragraphs: FitParagraph[], box: FitBox, resolve: M
|
|
|
205
293
|
* Synchronous: assumes metrics are pre-registered (lookup is sync). A named face
|
|
206
294
|
* with no exact metrics silently uses the conservative heuristic (same as export)
|
|
207
295
|
* and is reported in `approximatedFaces`; an unnamed theme-default face returns
|
|
208
|
-
* `measurable: false`.
|
|
296
|
+
* `measurable: false`. Code points a *registered* face has no glyph for are reported
|
|
297
|
+
* in `uncoveredCodepoints`, and are the one case where the height may come back short
|
|
298
|
+
* rather than tall — there is no font fallback here, only the font's `.notdef` advance.
|
|
209
299
|
*/
|
|
210
300
|
declare function measureText(registry: FontMetricsRegistry, text: string | TextProps[], opts: MeasureTextOptions): TextMeasurement;
|
|
211
301
|
//#endregion
|
|
@@ -219,5 +309,5 @@ type RunOpts = TextPropsOptions & ObjectOptions;
|
|
|
219
309
|
*/
|
|
220
310
|
declare function buildFitParagraphs(runs: TextProps[], opts: RunOpts): FitParagraph[] | null;
|
|
221
311
|
//#endregion
|
|
222
|
-
export { type ErrorCode, FONT_SCALE_STEP_PCT, type FitBox, type FitParagraph, type FitRun, type FontMetrics, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LayoutResult, MIN_FONT_SCALE_PCT, type MeasureTextOptions, MediaError, type MediaErrorCode, type MetricsResolver, type OverflowBoxOptions, PackageReadError, type PackageReadErrorCode, type ResizeOutcome, SINGLE_LINE_PITCH, type ShrinkOutcome, type ShrinkResult, type TextMeasurement, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
|
|
312
|
+
export { type ErrorCode, FONT_SCALE_STEP_PCT, type FitBox, type FitParagraph, type FitRun, type FontFaceInfo, type FontMetrics, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LayoutResult, MIN_FONT_SCALE_PCT, type MeasureTextOptions, MediaError, type MediaErrorCode, type MetricsResolver, type OverflowBoxOptions, PackageReadError, type PackageReadErrorCode, type ParseFontMetricsOptions, type ResizeOutcome, SINGLE_LINE_PITCH, type ShrinkOutcome, type ShrinkResult, type TextMeasurement, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, isFontCollection, listFontFaces, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
|
|
223
313
|
//# sourceMappingURL=measure.d.ts.map
|
package/dist/measure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure.d.ts","names":[],"sources":["../src/measure/font-metrics.ts","../src/measure/text-fit.ts","../src/measure/fit.ts","../src/measure/paragraphs.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"measure.d.ts","names":[],"sources":["../src/measure/font-metrics.ts","../src/measure/text-fit.ts","../src/measure/font-collection.ts","../src/measure/fit.ts","../src/measure/paragraphs.ts"],"mappings":";;;;UAmBiB;;WAEP;;;;;;EAMT,iBAAiB,cAAc,gBAAgB;;;;;;;EAO/C,eAAe;;;;;;;;iBAgGA,2BAA2B;;UAM1B;;;;;;;;;;;WAWP;;;;;;;;;;;;;;;iBAgBY,iBAAiB,MAAM,YAAY,OAAO,0BAA0B,QAAQ;;;;;;;cA4BrF;mBACK;UAET;EAIR,IAAI,cAAc,SAAS,aAAa;IAAS;IAAgB;;;EAKjE,QAAQ;;;;;;;;;;;;EAiBR,aACC,iCACA,YACA;IAAS;IAAgB;;;EAM1B,IAAI,iCAAiC,gBAAc,mBAAiB;MAahE;;;;;;;iBAUW,qBACf,UAAU,qBACV,eAAe,wBACb;;;;;;;;;;;cCvOU;;cAGA;;cAGA;;;;;;;;;;;cAYA;cACA;;UAGI;EAChB;EACA;EACA;EACA;EACA;;EAEA;;;UAIgB;EAChB,MAAM;;EAEN;;EAEA;EACA;EACA;;;UAIgB;EAChB;EACA;;;;;;;;;;EAUA;;;KAIW,mBAAmB,KAAK,WAAW;UAE9B;EAChB;EACA;;KAGW;EACP;;EACA;;EACA;EAAgB,QAAQ;;;UAiMZ;EAChB;EACA;;;;;;;EAOA;;;;;;;;;iBAUe,cACf,YAAY,gBACZ,sBACA,SAAS,iBACT,sBACA,2BACA,uBACE;;;;;iBA0Ba,gBACf,YAAY,gBACZ,sBACA,SAAS,iBACT,sBACA,2BACA;;;;;;;;;;;KAgBW;EACP;;EACA;EAAgB;;iBAoBL,YAAY,YAAY,gBAAgB,KAAK,QAAQ,SAAS,kBAAkB;iBAMhF,YAAY,YAAY,gBAAgB,KAAK,QAAQ,SAAS,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UClV/E;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;iBA+BM,iBAAiB,MAAM;;;;;;;;;;;;;iBA0HvB,cAAc,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;iBC1GjC,YACf,UAAU,qBACV,eAAe,aACf,MAAM,qBACJ;;;KCzFS,UAAU,mBAAmB;;;;;;;iBA8BzB,mBAAmB,MAAM,aAAa,MAAM,UAAU"}
|
package/dist/measure.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as TsPptxError, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, t as InternalError } from "./errors-Bvln0H-7.js";
|
|
2
|
-
import { _ as parseFontMetrics, a as FONT_SCALE_STEP_PCT, c as SINGLE_LINE_PITCH, d as measureLayout, f as solveResize, g as makeRegistryResolver, h as getHeuristicFontMetrics, i as buildFitParagraphs, l as WIDTH_SAFETY_FACTOR, m as FontMetricsRegistry, n as measureText, o as HEIGHT_SAFETY_FACTOR, p as solveShrink, s as MIN_FONT_SCALE_PCT, u as measureHeightPt } from "./fit-
|
|
3
|
-
export { FONT_SCALE_STEP_PCT, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, InvalidOptionError, MIN_FONT_SCALE_PCT, MediaError, PackageReadError, SINGLE_LINE_PITCH, TsPptxError, UnsupportedFeatureError, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
|
|
2
|
+
import { _ as parseFontMetrics, a as FONT_SCALE_STEP_PCT, c as SINGLE_LINE_PITCH, d as measureLayout, f as solveResize, g as makeRegistryResolver, h as getHeuristicFontMetrics, i as buildFitParagraphs, l as WIDTH_SAFETY_FACTOR, m as FontMetricsRegistry, n as measureText, o as HEIGHT_SAFETY_FACTOR, p as solveShrink, s as MIN_FONT_SCALE_PCT, u as measureHeightPt, v as isFontCollection, y as listFontFaces } from "./fit-TjpNbMru.js";
|
|
3
|
+
export { FONT_SCALE_STEP_PCT, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, InvalidOptionError, MIN_FONT_SCALE_PCT, MediaError, PackageReadError, SINGLE_LINE_PITCH, TsPptxError, UnsupportedFeatureError, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, isFontCollection, listFontFaces, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
|