pptx-glimpse 1.1.2 → 3.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/dist/index.d.cts CHANGED
@@ -1,207 +1,7 @@
1
- /**
2
- * テキスト→パス変換用のフォントリゾルバーコンテキスト。
3
- * opentype.js の getPath() メソッドを持つ Font オブジェクトへのアクセスを提供する。
4
- */
5
- interface OpentypePath {
6
- toPathData(decimalPlaces?: number): string;
7
- }
8
- interface OpentypeFullFont {
9
- unitsPerEm: number;
10
- ascender: number;
11
- descender: number;
12
- getPath(text: string, x: number, y: number, fontSize: number): OpentypePath;
13
- getAdvanceWidth(text: string, fontSize: number): number;
14
- }
15
- interface TextPathFontResolver {
16
- resolveFont(fontFamily: string | null | undefined, fontFamilyEa: string | null | undefined, jpanFallback?: string | null): OpentypeFullFont | null;
17
- }
1
+ export { C as ConversionDiagnostic, a as ConvertOptions, D as DEFAULT_FONT_MAPPING, F as FontBuffer, b as FontMapping, L as LogLevel, O as OpentypeSetup, P as PngConversionReport, S as SlideImage, d as SlideSupportCoverage, e as SlideSvg, h as SupportCoverage, i as SupportCoverageCounts, j as SvgConversionReport, U as UsedFonts, W as WarningEntry, k as WarningSummary, l as clearFontCache, m as collectUsedFonts, n as convertPptxToPng, p as convertPptxToSvg, q as createFontMapping, r as createOpentypeSetupFromBuffers, s as createOpentypeTextMeasurerFromBuffers, t as getMappedFont, u as getWarningEntries, v as getWarningSummary } from './font-collector-DYooJP6L.cjs';
18
2
 
19
- /**
20
- * PPTX フォント名 → OSS 代替フォント (Google Fonts) のマッピング。
21
- * ユーザーが拡張・上書き可能。
22
- */
23
- /** フォントマッピングテーブルの型 */
24
- type FontMapping = Record<string, string>;
25
- /** デフォルトのフォントマッピングテーブル */
26
- declare const DEFAULT_FONT_MAPPING: Readonly<FontMapping>;
27
- /**
28
- * デフォルトマッピングとユーザーマッピングをマージしたテーブルを生成する。
29
- * ユーザー指定が優先される。
30
- */
31
- declare function createFontMapping(userMapping?: FontMapping): FontMapping;
32
- declare function getMappedFont(fontFamily: string | null | undefined, mapping: FontMapping): string | null;
3
+ type ResvgWasmInput = ArrayBuffer | Uint8Array | Response;
33
4
 
34
- /**
35
- * テキストの幅と行高さを計測するインターフェース。
36
- * デフォルトでは静的フォントメトリクスによる計測が使われる。
37
- * ユーザーが独自の実装を ConvertOptions.textMeasurer に渡すことで、
38
- * Canvas API や opentype.js など任意の計測バックエンドに差し替えられる。
39
- */
40
- interface TextMeasurer {
41
- /**
42
- * テキストの推定幅をピクセル単位で返す。
43
- * @param text - 計測対象のテキスト
44
- * @param fontSizePt - フォントサイズ (ポイント)
45
- * @param bold - 太字かどうか
46
- * @param fontFamily - ラテン文字用フォントファミリー名
47
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
48
- */
49
- measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
50
- /**
51
- * フォントの自然な行高さ比率 (行高さ / フォントサイズ) を返す。
52
- * メトリクスが不明な場合は 1.2 をフォールバック値として返す。
53
- * @param fontFamily - ラテン文字用フォントファミリー名
54
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
55
- */
56
- getLineHeightRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
57
- /**
58
- * フォントの ascender 比率 (ascender / unitsPerEm) を返す。
59
- * 1行目のベースラインオフセット計算に使用する。
60
- * メトリクスが不明な場合は 1.0 をフォールバック値として返す。
61
- * @param fontFamily - ラテン文字用フォントファミリー名
62
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
63
- */
64
- getAscenderRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
65
- }
5
+ declare function initResvgWasm(wasm?: ResvgWasmInput): Promise<void>;
66
6
 
67
- interface OpentypeGlyph {
68
- advanceWidth?: number;
69
- }
70
- interface OpentypeFont {
71
- unitsPerEm: number;
72
- ascender: number;
73
- descender: number;
74
- stringToGlyphs(text: string): OpentypeGlyph[];
75
- }
76
- declare class OpentypeTextMeasurer implements TextMeasurer {
77
- private fonts;
78
- private defaultFont;
79
- private warnedFonts;
80
- /**
81
- * @param fonts - フォント名 → opentype.js Font オブジェクトのマップ
82
- * @param defaultFont - フォールバックフォント(省略可)
83
- */
84
- constructor(fonts: Map<string, OpentypeFont>, defaultFont?: OpentypeFont);
85
- measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
86
- getLineHeightRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
87
- getAscenderRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
88
- private resolveBoldFont;
89
- private resolveFont;
90
- }
91
-
92
- /** フォントバッファの入力形式 */
93
- interface FontBuffer {
94
- name?: string;
95
- data: ArrayBuffer | Uint8Array;
96
- }
97
- /**
98
- * フォントバッファ配列から OpentypeTextMeasurer を構築する。
99
- *
100
- * 内部で opentype.js を動的 import してフォントをパースする。
101
- * opentype.js が利用不可な場合は null を返す。
102
- */
103
- declare function createOpentypeTextMeasurerFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeTextMeasurer | null>;
104
- interface OpentypeSetup {
105
- measurer: OpentypeTextMeasurer;
106
- fontResolver: TextPathFontResolver;
107
- }
108
- /**
109
- * フォントバッファ配列から OpentypeTextMeasurer と TextPathFontResolver を同時に構築する。
110
- *
111
- * opentype.parse() が返すオブジェクトは OpentypeFont と OpentypeFullFont の両方を満たすため、
112
- * 同じ Font オブジェクトを measurer と fontResolver の両方に渡す。
113
- */
114
- declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeSetup | null>;
115
- /**
116
- * フォントオブジェクトキャッシュをクリアする。
117
- * 通常は呼び出す必要はないが、フォントのインストール/アンインストール後に
118
- * 強制的に再読み込みしたい場合に使用する。
119
- */
120
- declare function clearFontCache(): void;
121
-
122
- /**
123
- * resvg-wasm の WASM モジュールを初期化する。
124
- * 明示的に呼び出さなくても、初回の PNG 変換時に自動的に初期化される。
125
- * アプリケーション起動時に初期化しておきたい場合に使用する。
126
- */
127
- declare function initResvgWasm(): Promise<void>;
128
-
129
- type LogLevel = "off" | "warn" | "debug";
130
- interface WarningEntry {
131
- /** The feature key, e.g. "sp.style", "bodyPr@vert" */
132
- feature: string;
133
- /** Human-readable description */
134
- message: string;
135
- /** Location context, e.g. "Slide 1" */
136
- context?: string;
137
- }
138
- interface WarningSummary {
139
- totalCount: number;
140
- features: {
141
- feature: string;
142
- message: string;
143
- count: number;
144
- }[];
145
- }
146
- declare function getWarningSummary(): WarningSummary;
147
- declare function getWarningEntries(): readonly WarningEntry[];
148
-
149
- interface ConvertOptions {
150
- /** 変換対象のスライド番号 (1始まり)。未指定で全スライド */
151
- slides?: number[];
152
- /** 出力画像の幅 (ピクセル)。デフォルト: 960 */
153
- width?: number;
154
- /** 出力画像の高さ (ピクセル)。widthと同時指定時はwidthが優先 */
155
- height?: number;
156
- /** 警告ログレベル。デフォルト: "off" */
157
- logLevel?: LogLevel;
158
- /** 追加のフォントディレクトリパス。システムフォントに加えて検索する */
159
- fontDirs?: string[];
160
- /** PPTX フォント名 → OSS 代替フォントのカスタムマッピング。デフォルトマッピングにマージされる */
161
- fontMapping?: FontMapping;
162
- /** true のとき OS のシステムフォントをスキャンせず fontDirs のみを使用する */
163
- skipSystemFonts?: boolean;
164
- /**
165
- * SVG でのテキスト出力方式。デフォルト: "path"
166
- * - "path": グリフをアウトライン化した <path> として出力する。フォント環境に依存しない
167
- * - "text": ネイティブ <text> 要素 + サブセット化フォントの @font-face (data URI) 埋め込みで出力する。
168
- * ブラウザでのインライン表示時にネイティブテキスト描画 (ヒンティング等) が効き、テキスト選択も可能になる。
169
- * <img src="...svg"> 参照やサニタイズ環境では期待どおり描画されないことがある。
170
- * convertPptxToPng では無視され、常に "path" で変換される (resvg は @font-face を解釈しないため)
171
- */
172
- textOutput?: "path" | "text";
173
- }
174
- interface SlideSvg {
175
- slideNumber: number;
176
- svg: string;
177
- }
178
- interface SlideImage {
179
- slideNumber: number;
180
- png: Buffer;
181
- width: number;
182
- height: number;
183
- }
184
- declare function convertPptxToSvg(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SlideSvg[]>;
185
- declare function convertPptxToPng(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SlideImage[]>;
186
-
187
- /** フォント収集結果 */
188
- interface UsedFonts {
189
- /** テーマで定義されたフォント */
190
- theme: {
191
- majorFont: string;
192
- minorFont: string;
193
- majorFontEa: string | null;
194
- minorFontEa: string | null;
195
- majorFontCs: string | null;
196
- minorFontCs: string | null;
197
- };
198
- /** テキストランやテーマで使用されているフォント名の一覧(重複なし、ソート済み) */
199
- fonts: string[];
200
- }
201
- /**
202
- * PPTX をパースして使用されているフォント名を収集する。
203
- * レンダリングは行わないため軽量。
204
- */
205
- declare function collectUsedFonts(input: Buffer | Uint8Array): UsedFonts;
206
-
207
- export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
7
+ export { type ResvgWasmInput, initResvgWasm };
package/dist/index.d.ts CHANGED
@@ -1,207 +1,7 @@
1
- /**
2
- * テキスト→パス変換用のフォントリゾルバーコンテキスト。
3
- * opentype.js の getPath() メソッドを持つ Font オブジェクトへのアクセスを提供する。
4
- */
5
- interface OpentypePath {
6
- toPathData(decimalPlaces?: number): string;
7
- }
8
- interface OpentypeFullFont {
9
- unitsPerEm: number;
10
- ascender: number;
11
- descender: number;
12
- getPath(text: string, x: number, y: number, fontSize: number): OpentypePath;
13
- getAdvanceWidth(text: string, fontSize: number): number;
14
- }
15
- interface TextPathFontResolver {
16
- resolveFont(fontFamily: string | null | undefined, fontFamilyEa: string | null | undefined, jpanFallback?: string | null): OpentypeFullFont | null;
17
- }
1
+ export { C as ConversionDiagnostic, a as ConvertOptions, D as DEFAULT_FONT_MAPPING, F as FontBuffer, b as FontMapping, L as LogLevel, O as OpentypeSetup, P as PngConversionReport, S as SlideImage, d as SlideSupportCoverage, e as SlideSvg, h as SupportCoverage, i as SupportCoverageCounts, j as SvgConversionReport, U as UsedFonts, W as WarningEntry, k as WarningSummary, l as clearFontCache, m as collectUsedFonts, n as convertPptxToPng, p as convertPptxToSvg, q as createFontMapping, r as createOpentypeSetupFromBuffers, s as createOpentypeTextMeasurerFromBuffers, t as getMappedFont, u as getWarningEntries, v as getWarningSummary } from './font-collector-DYooJP6L.js';
18
2
 
19
- /**
20
- * PPTX フォント名 → OSS 代替フォント (Google Fonts) のマッピング。
21
- * ユーザーが拡張・上書き可能。
22
- */
23
- /** フォントマッピングテーブルの型 */
24
- type FontMapping = Record<string, string>;
25
- /** デフォルトのフォントマッピングテーブル */
26
- declare const DEFAULT_FONT_MAPPING: Readonly<FontMapping>;
27
- /**
28
- * デフォルトマッピングとユーザーマッピングをマージしたテーブルを生成する。
29
- * ユーザー指定が優先される。
30
- */
31
- declare function createFontMapping(userMapping?: FontMapping): FontMapping;
32
- declare function getMappedFont(fontFamily: string | null | undefined, mapping: FontMapping): string | null;
3
+ type ResvgWasmInput = ArrayBuffer | Uint8Array | Response;
33
4
 
34
- /**
35
- * テキストの幅と行高さを計測するインターフェース。
36
- * デフォルトでは静的フォントメトリクスによる計測が使われる。
37
- * ユーザーが独自の実装を ConvertOptions.textMeasurer に渡すことで、
38
- * Canvas API や opentype.js など任意の計測バックエンドに差し替えられる。
39
- */
40
- interface TextMeasurer {
41
- /**
42
- * テキストの推定幅をピクセル単位で返す。
43
- * @param text - 計測対象のテキスト
44
- * @param fontSizePt - フォントサイズ (ポイント)
45
- * @param bold - 太字かどうか
46
- * @param fontFamily - ラテン文字用フォントファミリー名
47
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
48
- */
49
- measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
50
- /**
51
- * フォントの自然な行高さ比率 (行高さ / フォントサイズ) を返す。
52
- * メトリクスが不明な場合は 1.2 をフォールバック値として返す。
53
- * @param fontFamily - ラテン文字用フォントファミリー名
54
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
55
- */
56
- getLineHeightRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
57
- /**
58
- * フォントの ascender 比率 (ascender / unitsPerEm) を返す。
59
- * 1行目のベースラインオフセット計算に使用する。
60
- * メトリクスが不明な場合は 1.0 をフォールバック値として返す。
61
- * @param fontFamily - ラテン文字用フォントファミリー名
62
- * @param fontFamilyEa - 東アジア文字用フォントファミリー名
63
- */
64
- getAscenderRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
65
- }
5
+ declare function initResvgWasm(wasm?: ResvgWasmInput): Promise<void>;
66
6
 
67
- interface OpentypeGlyph {
68
- advanceWidth?: number;
69
- }
70
- interface OpentypeFont {
71
- unitsPerEm: number;
72
- ascender: number;
73
- descender: number;
74
- stringToGlyphs(text: string): OpentypeGlyph[];
75
- }
76
- declare class OpentypeTextMeasurer implements TextMeasurer {
77
- private fonts;
78
- private defaultFont;
79
- private warnedFonts;
80
- /**
81
- * @param fonts - フォント名 → opentype.js Font オブジェクトのマップ
82
- * @param defaultFont - フォールバックフォント(省略可)
83
- */
84
- constructor(fonts: Map<string, OpentypeFont>, defaultFont?: OpentypeFont);
85
- measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
86
- getLineHeightRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
87
- getAscenderRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
88
- private resolveBoldFont;
89
- private resolveFont;
90
- }
91
-
92
- /** フォントバッファの入力形式 */
93
- interface FontBuffer {
94
- name?: string;
95
- data: ArrayBuffer | Uint8Array;
96
- }
97
- /**
98
- * フォントバッファ配列から OpentypeTextMeasurer を構築する。
99
- *
100
- * 内部で opentype.js を動的 import してフォントをパースする。
101
- * opentype.js が利用不可な場合は null を返す。
102
- */
103
- declare function createOpentypeTextMeasurerFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeTextMeasurer | null>;
104
- interface OpentypeSetup {
105
- measurer: OpentypeTextMeasurer;
106
- fontResolver: TextPathFontResolver;
107
- }
108
- /**
109
- * フォントバッファ配列から OpentypeTextMeasurer と TextPathFontResolver を同時に構築する。
110
- *
111
- * opentype.parse() が返すオブジェクトは OpentypeFont と OpentypeFullFont の両方を満たすため、
112
- * 同じ Font オブジェクトを measurer と fontResolver の両方に渡す。
113
- */
114
- declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeSetup | null>;
115
- /**
116
- * フォントオブジェクトキャッシュをクリアする。
117
- * 通常は呼び出す必要はないが、フォントのインストール/アンインストール後に
118
- * 強制的に再読み込みしたい場合に使用する。
119
- */
120
- declare function clearFontCache(): void;
121
-
122
- /**
123
- * resvg-wasm の WASM モジュールを初期化する。
124
- * 明示的に呼び出さなくても、初回の PNG 変換時に自動的に初期化される。
125
- * アプリケーション起動時に初期化しておきたい場合に使用する。
126
- */
127
- declare function initResvgWasm(): Promise<void>;
128
-
129
- type LogLevel = "off" | "warn" | "debug";
130
- interface WarningEntry {
131
- /** The feature key, e.g. "sp.style", "bodyPr@vert" */
132
- feature: string;
133
- /** Human-readable description */
134
- message: string;
135
- /** Location context, e.g. "Slide 1" */
136
- context?: string;
137
- }
138
- interface WarningSummary {
139
- totalCount: number;
140
- features: {
141
- feature: string;
142
- message: string;
143
- count: number;
144
- }[];
145
- }
146
- declare function getWarningSummary(): WarningSummary;
147
- declare function getWarningEntries(): readonly WarningEntry[];
148
-
149
- interface ConvertOptions {
150
- /** 変換対象のスライド番号 (1始まり)。未指定で全スライド */
151
- slides?: number[];
152
- /** 出力画像の幅 (ピクセル)。デフォルト: 960 */
153
- width?: number;
154
- /** 出力画像の高さ (ピクセル)。widthと同時指定時はwidthが優先 */
155
- height?: number;
156
- /** 警告ログレベル。デフォルト: "off" */
157
- logLevel?: LogLevel;
158
- /** 追加のフォントディレクトリパス。システムフォントに加えて検索する */
159
- fontDirs?: string[];
160
- /** PPTX フォント名 → OSS 代替フォントのカスタムマッピング。デフォルトマッピングにマージされる */
161
- fontMapping?: FontMapping;
162
- /** true のとき OS のシステムフォントをスキャンせず fontDirs のみを使用する */
163
- skipSystemFonts?: boolean;
164
- /**
165
- * SVG でのテキスト出力方式。デフォルト: "path"
166
- * - "path": グリフをアウトライン化した <path> として出力する。フォント環境に依存しない
167
- * - "text": ネイティブ <text> 要素 + サブセット化フォントの @font-face (data URI) 埋め込みで出力する。
168
- * ブラウザでのインライン表示時にネイティブテキスト描画 (ヒンティング等) が効き、テキスト選択も可能になる。
169
- * <img src="...svg"> 参照やサニタイズ環境では期待どおり描画されないことがある。
170
- * convertPptxToPng では無視され、常に "path" で変換される (resvg は @font-face を解釈しないため)
171
- */
172
- textOutput?: "path" | "text";
173
- }
174
- interface SlideSvg {
175
- slideNumber: number;
176
- svg: string;
177
- }
178
- interface SlideImage {
179
- slideNumber: number;
180
- png: Buffer;
181
- width: number;
182
- height: number;
183
- }
184
- declare function convertPptxToSvg(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SlideSvg[]>;
185
- declare function convertPptxToPng(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SlideImage[]>;
186
-
187
- /** フォント収集結果 */
188
- interface UsedFonts {
189
- /** テーマで定義されたフォント */
190
- theme: {
191
- majorFont: string;
192
- minorFont: string;
193
- majorFontEa: string | null;
194
- minorFontEa: string | null;
195
- majorFontCs: string | null;
196
- minorFontCs: string | null;
197
- };
198
- /** テキストランやテーマで使用されているフォント名の一覧(重複なし、ソート済み) */
199
- fonts: string[];
200
- }
201
- /**
202
- * PPTX をパースして使用されているフォント名を収集する。
203
- * レンダリングは行わないため軽量。
204
- */
205
- declare function collectUsedFonts(input: Buffer | Uint8Array): UsedFonts;
206
-
207
- export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
7
+ export { type ResvgWasmInput, initResvgWasm };