@mlightcad/mtext-renderer 0.13.2 → 0.13.3
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.
|
@@ -69,9 +69,14 @@ export interface MTextBaseRenderer {
|
|
|
69
69
|
* Implementations should load and cache missing fonts; repeated calls should be cheap.
|
|
70
70
|
*
|
|
71
71
|
* @param fonts Font names to load (without extension for built-ins).
|
|
72
|
-
* @
|
|
72
|
+
* @param options.scope - Worker pool only: `one` warms a single isolate
|
|
73
|
+
* (default); `all` loads into every worker.
|
|
74
|
+
* @returns Fonts confirmed loaded in the target isolate(s). With
|
|
75
|
+
* `scope: 'all'`, only faces present in every worker.
|
|
73
76
|
*/
|
|
74
|
-
loadFonts(fonts: readonly string[]
|
|
77
|
+
loadFonts(fonts: readonly string[], options?: {
|
|
78
|
+
scope?: 'one' | 'all';
|
|
79
|
+
}): Promise<{
|
|
75
80
|
loaded: string[];
|
|
76
81
|
}>;
|
|
77
82
|
/**
|
|
@@ -39,7 +39,9 @@ export declare class MainThreadRenderer implements MTextBaseRenderer {
|
|
|
39
39
|
/**
|
|
40
40
|
* Load fonts in the main thread
|
|
41
41
|
*/
|
|
42
|
-
loadFonts(fonts: readonly string[]
|
|
42
|
+
loadFonts(fonts: readonly string[], _options?: {
|
|
43
|
+
scope?: 'one' | 'all';
|
|
44
|
+
}): Promise<{
|
|
43
45
|
loaded: string[];
|
|
44
46
|
}>;
|
|
45
47
|
/**
|
|
@@ -101,9 +101,15 @@ export declare class UnifiedRenderer {
|
|
|
101
101
|
*/
|
|
102
102
|
getSymbolFontsPreset(preset: DefaultFontsPreset): readonly string[];
|
|
103
103
|
/**
|
|
104
|
-
* Load fonts using the current mode
|
|
104
|
+
* Load fonts using the current mode.
|
|
105
|
+
*
|
|
106
|
+
* In worker mode, `options.scope` defaults to `one` (warm a single isolate).
|
|
107
|
+
* Pass `{ scope: 'all' }` only when every worker must have the faces;
|
|
108
|
+
* `loaded` then lists only faces confirmed in every isolate.
|
|
105
109
|
*/
|
|
106
|
-
loadFonts(fonts: readonly string[]
|
|
110
|
+
loadFonts(fonts: readonly string[], options?: {
|
|
111
|
+
scope?: 'one' | 'all';
|
|
112
|
+
}): Promise<{
|
|
107
113
|
loaded: string[];
|
|
108
114
|
}>;
|
|
109
115
|
/**
|
|
@@ -141,12 +141,14 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
141
141
|
private isInitialized;
|
|
142
142
|
private defaultStyleManager;
|
|
143
143
|
/**
|
|
144
|
-
* Fonts known to be present in
|
|
145
|
-
*
|
|
144
|
+
* Fonts known to be present in a given worker isolate after an explicit
|
|
145
|
+
* {@link loadFonts} or a lazy `fontLoaded` notification from that worker.
|
|
146
|
+
*
|
|
147
|
+
* Intentionally per-worker: fanning a mesh face (e.g. simsun) into every
|
|
148
|
+
* isolate re-parses tens of MB of opentype data N times and makes worker
|
|
149
|
+
* mode slower than main-thread rendering.
|
|
146
150
|
*/
|
|
147
|
-
private
|
|
148
|
-
/** In-flight pool-wide font syncs keyed by normalized font name. */
|
|
149
|
-
private poolFontSyncInFlight;
|
|
151
|
+
private fontsPerWorker;
|
|
150
152
|
/** Fonts already forwarded as main-thread fontLoaded for this pool lifetime. */
|
|
151
153
|
private poolFontLoadedDispatched;
|
|
152
154
|
constructor(config?: WebWorkerRendererConfig);
|
|
@@ -160,11 +162,6 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
160
162
|
* Handles messages coming from any worker.
|
|
161
163
|
*/
|
|
162
164
|
private handleWorkerMessage;
|
|
163
|
-
/**
|
|
164
|
-
* Ensures every worker has `fontName`, then returns whether the main thread
|
|
165
|
-
* should emit {@link FontManager.events.fontLoaded} for this name.
|
|
166
|
-
*/
|
|
167
|
-
private syncFontToWorkerPool;
|
|
168
165
|
/**
|
|
169
166
|
* Attaches message and error handlers to a worker.
|
|
170
167
|
*/
|
|
@@ -212,7 +209,20 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
212
209
|
syncRenderMText(_mtextContent: MTextData, _textStyle: TextStyle, _colorSettings?: ColorSettings): MTextObject;
|
|
213
210
|
asyncRenderShape(_shapeContent: ShapeData, _textStyle: TextStyle, _colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
214
211
|
syncRenderShape(_shapeContent: ShapeData, _textStyle: TextStyle, _colorSettings?: ColorSettings): MTextObject;
|
|
215
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Loads fonts into the worker pool.
|
|
214
|
+
*
|
|
215
|
+
* @param fonts - Logical font names (extensions stripped by workers).
|
|
216
|
+
* @param options.scope - `one` (default) warms a single least-loaded /
|
|
217
|
+
* already-warm worker so open-time preload does not re-parse large mesh
|
|
218
|
+
* fonts into every isolate. Pass `all` only when every worker must have
|
|
219
|
+
* the faces before the first draw (rare; expensive for mesh fonts).
|
|
220
|
+
* @returns Fonts confirmed loaded in the target isolate(s). With
|
|
221
|
+
* `scope: 'all'`, only faces present in every worker.
|
|
222
|
+
*/
|
|
223
|
+
loadFonts(fonts: readonly string[], options?: {
|
|
224
|
+
scope?: 'one' | 'all';
|
|
225
|
+
}): Promise<{
|
|
216
226
|
loaded: string[];
|
|
217
227
|
}>;
|
|
218
228
|
getAvailableFonts(): Promise<{
|