@mlightcad/mtext-renderer 0.12.2 → 0.12.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.
- package/dist/index.js +363 -330
- package/dist/index.umd.cjs +8 -8
- package/dist/mtext-renderer-worker.js +121 -100
- package/lib/font/fontManager.d.ts +15 -3
- package/lib/renderer/mtext.d.ts +21 -5
- package/lib/renderer/shape.d.ts +2 -1
- package/lib/worker/mainThreadRenderer.d.ts +3 -1
- package/lib/worker/unifiedRenderer.d.ts +7 -0
- package/lib/worker/webWorkerRenderer.d.ts +4 -0
- package/package.json +1 -1
|
@@ -51,9 +51,19 @@ export declare class FontManager {
|
|
|
51
51
|
/**
|
|
52
52
|
* When true (default), missing fonts are fetched/parsed in the background
|
|
53
53
|
* via {@link requestFont} instead of requiring an open-time preload.
|
|
54
|
-
* Drawing continues with temporary fallbacks until {@link events.fontLoaded}
|
|
54
|
+
* Drawing continues with temporary fallbacks until {@link events.fontLoaded}
|
|
55
|
+
* unless {@link awaitFontsBeforeDraw} (or a per-draw override) waits first.
|
|
55
56
|
*/
|
|
56
57
|
lazyFontLoading: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* When true, {@link MText.asyncDraw} / {@link Shape.asyncDraw} wait for fonts
|
|
60
|
+
* referenced by the content and style to finish loading before building
|
|
61
|
+
* geometry. Useful with {@link lazyFontLoading} when callers prefer a single
|
|
62
|
+
* draw pass instead of redrawing on {@link events.fontLoaded}.
|
|
63
|
+
*
|
|
64
|
+
* Has no effect when {@link lazyFontLoading} is false (draw already awaits).
|
|
65
|
+
*/
|
|
66
|
+
awaitFontsBeforeDraw: boolean;
|
|
57
67
|
/**
|
|
58
68
|
* Default fonts to use when a requested font is not found or lacks a glyph.
|
|
59
69
|
* Insertion order is preserved; earlier entries are tried first.
|
|
@@ -179,9 +189,11 @@ export declare class FontManager {
|
|
|
179
189
|
*/
|
|
180
190
|
requestFont(fontName: string): Promise<FontLoadStatus[]>;
|
|
181
191
|
/**
|
|
182
|
-
*
|
|
192
|
+
* Requests each font name via {@link requestFont} (deduped per name).
|
|
193
|
+
* Callers may ignore the returned promise for fire-and-forget loads, or
|
|
194
|
+
* await it when they need fonts before drawing.
|
|
183
195
|
*/
|
|
184
|
-
requestFonts(fontNames: readonly string[]):
|
|
196
|
+
requestFonts(fontNames: readonly string[]): Promise<FontLoadStatus[]>;
|
|
185
197
|
private normalizeFontName;
|
|
186
198
|
/**
|
|
187
199
|
* Parses a user-uploaded font file, registers it for rendering, and stores
|
package/lib/renderer/mtext.d.ts
CHANGED
|
@@ -2,6 +2,20 @@ import { FontManager } from '../font';
|
|
|
2
2
|
import { StyleManager } from './styleManager';
|
|
3
3
|
import { ColorSettings, MTextData, MTextLayout, ShapeData, TextStyle } from './types';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
|
+
/**
|
|
6
|
+
* Options for {@link MText.asyncDraw} / {@link Shape.asyncDraw}.
|
|
7
|
+
*/
|
|
8
|
+
export interface MTextDrawOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Wait for fonts referenced by the content/style to finish loading before
|
|
11
|
+
* building geometry.
|
|
12
|
+
*
|
|
13
|
+
* Defaults to `true` when {@link FontManager.lazyFontLoading} is false, or
|
|
14
|
+
* when {@link FontManager.awaitFontsBeforeDraw} is true. Otherwise fonts are
|
|
15
|
+
* scheduled in the background and the first draw may use fallbacks.
|
|
16
|
+
*/
|
|
17
|
+
awaitFonts?: boolean;
|
|
18
|
+
}
|
|
5
19
|
/**
|
|
6
20
|
* Represents an AutoCAD MText object in Three.js.
|
|
7
21
|
* This class extends THREE.Object3D to provide MText rendering capabilities,
|
|
@@ -60,13 +74,15 @@ export declare class MText extends THREE.Object3D {
|
|
|
60
74
|
*/
|
|
61
75
|
dispose(): void;
|
|
62
76
|
/**
|
|
63
|
-
* Draw the MText object.
|
|
64
|
-
* builds the object graph immediately with current fallbacks.
|
|
77
|
+
* Draw the MText object.
|
|
65
78
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
79
|
+
* With {@link FontManager.lazyFontLoading} and without awaiting fonts, this
|
|
80
|
+
* schedules downloads in the background and builds geometry immediately with
|
|
81
|
+
* current fallbacks — redraw after {@link FontManager.events.fontLoaded} if
|
|
82
|
+
* you need the final faces. Pass `{ awaitFonts: true }` or set
|
|
83
|
+
* {@link FontManager.awaitFontsBeforeDraw} to wait for referenced fonts first.
|
|
68
84
|
*/
|
|
69
|
-
asyncDraw(): Promise<void>;
|
|
85
|
+
asyncDraw(options?: MTextDrawOptions): Promise<void>;
|
|
70
86
|
/**
|
|
71
87
|
* Draw the MText object. This method assumes that fonts needed are loaded. If font needed
|
|
72
88
|
* not found, the default font will be used.
|
package/lib/renderer/shape.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FontManager } from '../font';
|
|
2
|
+
import { MTextDrawOptions } from './mtext';
|
|
2
3
|
import { StyleManager } from './styleManager';
|
|
3
4
|
import { ColorSettings, MTextLayout, ShapeData, TextStyle } from './types';
|
|
4
5
|
import * as THREE from 'three';
|
|
@@ -18,7 +19,7 @@ export declare class Shape extends THREE.Object3D {
|
|
|
18
19
|
get styleManager(): StyleManager;
|
|
19
20
|
get textStyle(): TextStyle;
|
|
20
21
|
createLayoutData(): MTextLayout;
|
|
21
|
-
asyncDraw(): Promise<void>;
|
|
22
|
+
asyncDraw(options?: MTextDrawOptions): Promise<void>;
|
|
22
23
|
syncDraw(): void;
|
|
23
24
|
private createPlacementData;
|
|
24
25
|
private getFontName;
|
|
@@ -24,7 +24,9 @@ export declare class MainThreadRenderer implements MTextBaseRenderer {
|
|
|
24
24
|
/**
|
|
25
25
|
* Render MText directly in the main thread asynchronously. Fonts referenced by
|
|
26
26
|
* the text/style are scheduled via {@link FontManager.requestFonts} when
|
|
27
|
-
* {@link FontManager.lazyFontLoading} is enabled
|
|
27
|
+
* {@link FontManager.lazyFontLoading} is enabled (unless
|
|
28
|
+
* {@link FontManager.awaitFontsBeforeDraw} waits for them first); otherwise
|
|
29
|
+
* they are awaited.
|
|
28
30
|
*/
|
|
29
31
|
asyncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
|
|
30
32
|
/**
|
|
@@ -17,6 +17,8 @@ export declare class UnifiedRenderer {
|
|
|
17
17
|
private webWorkerConfigured;
|
|
18
18
|
/** Last lazyFontLoading value pushed to the worker pool, if any. */
|
|
19
19
|
private workerLazyFontLoading;
|
|
20
|
+
/** Last awaitFontsBeforeDraw value pushed to the worker pool, if any. */
|
|
21
|
+
private workerAwaitFontsBeforeDraw;
|
|
20
22
|
/**
|
|
21
23
|
* Constructor
|
|
22
24
|
*
|
|
@@ -75,6 +77,11 @@ export declare class UnifiedRenderer {
|
|
|
75
77
|
* existing worker pool.
|
|
76
78
|
*/
|
|
77
79
|
setLazyFontLoading(enabled: boolean): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Mirrors {@link FontManager.awaitFontsBeforeDraw} onto the main thread and
|
|
82
|
+
* any existing worker pool.
|
|
83
|
+
*/
|
|
84
|
+
setAwaitFontsBeforeDraw(enabled: boolean): Promise<void>;
|
|
78
85
|
/**
|
|
79
86
|
* Returns font names for a predefined default-font preset.
|
|
80
87
|
*/
|
|
@@ -186,6 +186,10 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
186
186
|
* Mirrors {@link FontManager.lazyFontLoading} into every worker isolate.
|
|
187
187
|
*/
|
|
188
188
|
setLazyFontLoading(enabled: boolean): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Mirrors {@link FontManager.awaitFontsBeforeDraw} into every worker isolate.
|
|
191
|
+
*/
|
|
192
|
+
setAwaitFontsBeforeDraw(enabled: boolean): Promise<void>;
|
|
189
193
|
/**
|
|
190
194
|
* Render MText in one worker and return serialized data asynchronously.
|
|
191
195
|
*/
|