@mlightcad/mtext-renderer 0.12.6 → 0.12.7

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.
@@ -224,6 +224,12 @@ export declare class FontManager {
224
224
  loadFonts(fonts: FontInfo | FontInfo[]): Promise<FontLoadStatus[]>;
225
225
  /**
226
226
  * Tries to find the specified font. If not found, uses a replacement font and returns its name.
227
+ *
228
+ * When the requested face is not loaded, the original name is recorded in
229
+ * {@link missedFonts} and {@link events.fontNotFound} is dispatched (once per
230
+ * miss cycle) so hosts can surface missing-font UI. Lazy loading still
231
+ * schedules {@link requestFont} for the face that will be fetched.
232
+ *
227
233
  * @param fontName - The font name to find
228
234
  * @returns The original font name if found, or the replacement font name if not found
229
235
  */
@@ -310,9 +316,40 @@ export declare class FontManager {
310
316
  * @returns True if the font is loaded, false otherwise
311
317
  */
312
318
  isFontLoaded(fontName: string): boolean;
319
+ /**
320
+ * Applies a missed-font report from another isolate (e.g. a web worker).
321
+ * Updates {@link missedFonts} and dispatches {@link events.fontNotFound} on
322
+ * first sighting. Does not call {@link requestFont} — the remote isolate owns loading.
323
+ */
324
+ applyRemoteFontNotFound(fontName: string, count?: number): void;
325
+ /**
326
+ * Clears a missed-font entry after a remote isolate reports the font loaded.
327
+ * Call before dispatching {@link events.fontLoaded} on the main thread.
328
+ */
329
+ applyRemoteFontLoaded(fontName: string): void;
330
+ /**
331
+ * Replaces session-scoped missed-font bookkeeping without dispatching events.
332
+ * Entries for faces that are already loaded are dropped.
333
+ */
334
+ replaceMissedFonts(fonts: Record<string, number>): void;
335
+ /**
336
+ * Clears {@link missedFonts}. Does not unload faces or cancel in-flight loads.
337
+ */
338
+ clearMissedFonts(): void;
339
+ /**
340
+ * Strips a trailing `.ttf` / `.otf` / `.woff` / `.shx` extension when present.
341
+ * Matches the normalization used by {@link getFontByName}.
342
+ */
343
+ private stripFontFileExtension;
344
+ /**
345
+ * Removes {@link missedFonts} entries whose name matches `fontName`
346
+ * case-insensitively (CAD style names and loaded face names often differ in case).
347
+ */
348
+ private clearMissedFontEntry;
313
349
  /**
314
350
  * Records a font that was requested but not found
315
351
  * @param fontName - The name of the font that was not found
352
+ * @param scheduleLoad - When true (default), also {@link requestFont} on first miss if lazy loading is on
316
353
  */
317
354
  private recordMissedFonts;
318
355
  /**
@@ -82,6 +82,14 @@ export declare class UnifiedRenderer {
82
82
  * any existing worker pool.
83
83
  */
84
84
  setAwaitFontsBeforeDraw(enabled: boolean): Promise<void>;
85
+ /**
86
+ * Replaces session-scoped missed-font bookkeeping on the main thread and workers.
87
+ * When a worker pool is active, {@link WebWorkerRenderer.replaceMissedFonts}
88
+ * owns the final main-thread map (intersection of worker-filtered results).
89
+ */
90
+ replaceMissedFonts(fonts: Record<string, number>): Promise<void>;
91
+ /** Clears session-scoped missed-font bookkeeping on the main thread and workers. */
92
+ clearMissedFonts(): Promise<void>;
85
93
  /**
86
94
  * Returns font names for a predefined default-font preset.
87
95
  */
@@ -190,6 +190,17 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
190
190
  * Mirrors {@link FontManager.awaitFontsBeforeDraw} into every worker isolate.
191
191
  */
192
192
  setAwaitFontsBeforeDraw(enabled: boolean): Promise<void>;
193
+ /**
194
+ * Replaces session-scoped {@link FontManager.missedFonts} on every worker,
195
+ * then adopts the intersection of worker-filtered maps on the main thread.
196
+ *
197
+ * Workers drop faces they have already loaded; in worker-only mode the main
198
+ * isolate often has an empty {@link FontManager.loadedFontMap}, so the
199
+ * authoritative "still missing" set comes from the pool responses.
200
+ */
201
+ replaceMissedFonts(fonts: Record<string, number>): Promise<void>;
202
+ /** Clears {@link FontManager.missedFonts} on the main thread and every worker. */
203
+ clearMissedFonts(): Promise<void>;
193
204
  /**
194
205
  * Render MText in one worker and return serialized data asynchronously.
195
206
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.12.6",
3
+ "version": "0.12.7",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",