@mlightcad/mtext-renderer 0.4.9 → 0.4.11

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.
@@ -77,12 +77,22 @@ export declare class FontManager {
77
77
  * @throws {Error} If font metadata cannot be loaded from the CDN
78
78
  */
79
79
  getAvaiableFonts(): Promise<import('./fontLoader').FontInfo[]>;
80
+ /**
81
+ * Return true if the default font was loaded.
82
+ * @returns True if the default font was loaded. False otherwise.
83
+ */
84
+ isDefaultFontLoaded(): boolean;
85
+ /**
86
+ * Loads the default font
87
+ * @returns Promise that resolves to the font load statuses
88
+ */
89
+ loadDefaultFont(): Promise<FontLoadStatus>;
80
90
  /**
81
91
  * Loads the specified fonts from font names
82
92
  * @param names - Font names to load.
83
93
  * @returns Promise that resolves to an array of font load statuses
84
94
  */
85
- loadFontsByNames(names: string | string[]): Promise<FontLoadStatus[]>;
95
+ loadFontsByNames(names: string | string[]): Promise<FontLoadStatus>;
86
96
  /**
87
97
  * Loads the specified fonts from URLs
88
98
  * @param urls - URLs of font files to load.
@@ -20,6 +20,8 @@ export declare class MText extends THREE.Object3D {
20
20
  private _box;
21
21
  /** Array of bounding boxes for individual text elements */
22
22
  private _boxes;
23
+ /** Raw mtext data to draw on demand */
24
+ private _mtextData;
23
25
  /**
24
26
  * Extracts all unique font names used in an MText string.
25
27
  * This function searches for font commands in the format \f{fontname}| or \f{fontname}; and returns a set of unique font names.
@@ -50,6 +52,12 @@ export declare class MText extends THREE.Object3D {
50
52
  * @returns The FontManager instance
51
53
  */
52
54
  get fontManager(): FontManager;
55
+ /**
56
+ * Draw the MText object. This method loads required fonts on demand and builds the object graph.
57
+ *
58
+ * @param isLoadFontsOnDemand - The flag indicate whether to load required fonts on demand
59
+ */
60
+ draw(isLoadFontsOnDemand?: boolean): Promise<void>;
53
61
  /**
54
62
  * Gets the style manager instance associated with this MText object.
55
63
  * @returns The StyleManager instance
@@ -7,6 +7,7 @@ import { MTextBaseRenderer, MTextObject } from './baseRenderer';
7
7
  export declare class MainThreadRenderer implements MTextBaseRenderer {
8
8
  private fontManager;
9
9
  private styleManager;
10
+ private isInitialized;
10
11
  constructor();
11
12
  /**
12
13
  * Render MText directly in the main thread
@@ -27,4 +28,5 @@ export declare class MainThreadRenderer implements MTextBaseRenderer {
27
28
  }>;
28
29
  }>;
29
30
  destroy(): void;
31
+ private ensureInitialized;
30
32
  }
@@ -14,6 +14,12 @@ export interface WebWorkerRendererConfig {
14
14
  * @default './mtext-renderer-worker.js'
15
15
  */
16
16
  workerUrl?: string;
17
+ /**
18
+ * The flag indicate whether to load required fonts on demand
19
+ *
20
+ * @default false
21
+ */
22
+ isLoadFontsOnDemand?: boolean;
17
23
  }
18
24
  interface SerializedMText {
19
25
  type: string;
@@ -100,13 +106,16 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
100
106
  private pendingRequests;
101
107
  private requestId;
102
108
  private poolSize;
109
+ private isLoadFontsOnDemand;
103
110
  private readyPromise;
111
+ private isInitialized;
104
112
  constructor(config?: WebWorkerRendererConfig);
113
+ private ensureInitialized;
105
114
  private handleWorkerMessage;
106
115
  private attachWorkerHandlers;
107
116
  private pickLeastLoadedWorker;
108
117
  private sendMessage;
109
- private ensureInitialized;
118
+ private ensureTasksFinished;
110
119
  /**
111
120
  * Render MText in the worker and return serialized data
112
121
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",