@mlightcad/mtext-renderer 0.11.9 → 0.12.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.js +2485 -2144
- package/dist/index.umd.cjs +9 -8
- package/dist/mtext-renderer-worker.js +1961 -1746
- package/lib/cache/fontCacheManager.d.ts +9 -0
- package/lib/common/lruCache.d.ts +12 -0
- package/lib/font/baseFont.d.ts +16 -0
- package/lib/font/charGeometryCache.d.ts +6 -0
- package/lib/font/fontManager.d.ts +17 -0
- package/lib/font/meshFont.d.ts +9 -0
- package/lib/font/shxFont.d.ts +9 -0
- package/lib/font/shxTextShape.d.ts +8 -0
- package/lib/index.d.ts +1 -0
- package/lib/memory/collectIsolateMemoryStats.d.ts +20 -0
- package/lib/memory/estimateGeometryBytes.d.ts +18 -0
- package/lib/memory/formatMemoryUsageReport.d.ts +5 -0
- package/lib/memory/index.d.ts +5 -0
- package/lib/memory/types.d.ts +107 -0
- package/lib/renderer/constants.d.ts +10 -3
- package/lib/renderer/defaultStyleManager.d.ts +5 -0
- package/lib/renderer/mtextProcessor.d.ts +9 -3
- package/lib/renderer/types.d.ts +5 -1
- package/lib/worker/mainThreadRenderer.d.ts +5 -0
- package/lib/worker/unifiedRenderer.d.ts +14 -0
- package/lib/worker/webWorkerRenderer.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FontData } from '../font';
|
|
2
|
+
import { IndexedDbFontCacheStats } from '../memory/types';
|
|
2
3
|
/**
|
|
3
4
|
* A simple font cache interface that provides map-like operations for font data
|
|
4
5
|
*/
|
|
@@ -42,6 +43,14 @@ export declare class FontCacheManager {
|
|
|
42
43
|
* @returns An array of all font data in the cache
|
|
43
44
|
*/
|
|
44
45
|
getAll(): Promise<FontData[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Estimates IndexedDB font-blob storage size.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* This loads all cached font payloads into the JS heap temporarily via
|
|
51
|
+
* {@link getAll}, then measures each `data` ArrayBuffer.
|
|
52
|
+
*/
|
|
53
|
+
getStorageStats(): Promise<IndexedDbFontCacheStats>;
|
|
45
54
|
/**
|
|
46
55
|
* Clears all fonts from the cache
|
|
47
56
|
*/
|
package/lib/common/lruCache.d.ts
CHANGED
|
@@ -53,6 +53,18 @@ export declare class LRUCache<K, V> {
|
|
|
53
53
|
* @returns True if the key is present; otherwise, false.
|
|
54
54
|
*/
|
|
55
55
|
has(key: K): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Number of entries currently stored in the cache.
|
|
58
|
+
*/
|
|
59
|
+
get size(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Maximum number of entries this cache may retain.
|
|
62
|
+
*/
|
|
63
|
+
get capacity(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Iterates over cached values without updating recency order.
|
|
66
|
+
*/
|
|
67
|
+
values(): IterableIterator<V>;
|
|
56
68
|
/**
|
|
57
69
|
* Removes all entries from the cache.
|
|
58
70
|
*
|
package/lib/font/baseFont.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FontMemoryStats } from '../memory/types';
|
|
1
2
|
import { BaseTextShape } from './baseTextShape';
|
|
2
3
|
import { CharGeometryCache } from './charGeometryCache';
|
|
3
4
|
import { FontData, FontType } from './font';
|
|
@@ -23,11 +24,26 @@ export declare abstract class BaseFont {
|
|
|
23
24
|
* https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings
|
|
24
25
|
*/
|
|
25
26
|
encoding?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Byte length of the original font file payload when known (ArrayBuffer / TypedArray).
|
|
29
|
+
* Used as the basis for parsed-font memory heuristics.
|
|
30
|
+
*/
|
|
31
|
+
readonly sourceByteLength: number;
|
|
26
32
|
/**
|
|
27
33
|
* Caching of font character geometries to improve text rendering performance.
|
|
28
34
|
*/
|
|
29
35
|
cache: CharGeometryCache;
|
|
30
36
|
constructor(fontData: FontData);
|
|
37
|
+
/**
|
|
38
|
+
* Estimates memory used by this font instance (parsed data + caches).
|
|
39
|
+
* Only reports resources still retained by this font (not disposed/released caches).
|
|
40
|
+
*/
|
|
41
|
+
abstract estimateMemoryUsage(): FontMemoryStats;
|
|
42
|
+
/**
|
|
43
|
+
* Releases cache resources held by this font so they are eligible for GC
|
|
44
|
+
* and no longer appear in {@link estimateMemoryUsage}.
|
|
45
|
+
*/
|
|
46
|
+
dispose(): void;
|
|
31
47
|
/**
|
|
32
48
|
* Return true if this font contains glyph of the specified character. Otherwise, return false.
|
|
33
49
|
* @param char - The character to check
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CacheBucketStats } from '../memory/types';
|
|
1
2
|
import * as THREE from 'three';
|
|
2
3
|
/**
|
|
3
4
|
* Manages caching of font character geometries to improve text rendering performance.
|
|
@@ -5,6 +6,7 @@ import * as THREE from 'three';
|
|
|
5
6
|
*/
|
|
6
7
|
export declare class CharGeometryCache {
|
|
7
8
|
private readonly cache;
|
|
9
|
+
private readonly maxSize;
|
|
8
10
|
constructor(maxSize?: number);
|
|
9
11
|
/**
|
|
10
12
|
* Returns true if the geometry of the specified character code exists in the cache.
|
|
@@ -31,6 +33,10 @@ export declare class CharGeometryCache {
|
|
|
31
33
|
* @param geometry The geometry to set.
|
|
32
34
|
*/
|
|
33
35
|
setGeometry(code: number, size: number, geometry: THREE.BufferGeometry): void;
|
|
36
|
+
/**
|
|
37
|
+
* Estimates memory used by cached BufferGeometry attribute/index buffers.
|
|
38
|
+
*/
|
|
39
|
+
getStats(): CacheBucketStats;
|
|
34
40
|
/**
|
|
35
41
|
* Dispose all cached geometries.
|
|
36
42
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShxFontType } from '@mlightcad/shx-parser';
|
|
2
2
|
import { EventManager } from '../common';
|
|
3
|
+
import { IsolateMemoryStats, MaterialMemoryStats } from '../memory/types';
|
|
3
4
|
import { BaseFont } from './baseFont';
|
|
4
5
|
import { BaseTextShape } from './baseTextShape';
|
|
5
6
|
import { DefaultFontsPreset } from './defaultFontsPresets';
|
|
@@ -292,6 +293,9 @@ export declare class FontManager {
|
|
|
292
293
|
* - If no argument is provided, all loaded fonts are released and the font map is cleared.
|
|
293
294
|
* - If a font name is provided, only that specific font is released from the font map.
|
|
294
295
|
*
|
|
296
|
+
* Disposes per-font caches before dropping references so released resources are
|
|
297
|
+
* not retained and are excluded from {@link estimateMemoryUsage}.
|
|
298
|
+
*
|
|
295
299
|
* This is useful for freeing up memory, especially when working with large font files (e.g., Chinese mesh fonts).
|
|
296
300
|
* Notes: Based on testing, one Chinese mesh font file may take 40M memory.
|
|
297
301
|
*
|
|
@@ -299,4 +303,17 @@ export declare class FontManager {
|
|
|
299
303
|
* @returns `true` if the operation succeeded (all fonts released or the specified font was found and deleted), `false` if the specified font was not found.
|
|
300
304
|
*/
|
|
301
305
|
release(fontToRelease?: string): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Estimates memory used by loaded fonts in this isolate.
|
|
308
|
+
*
|
|
309
|
+
* Font aliases that point at the same instance are counted once.
|
|
310
|
+
* Does not include IndexedDB blobs or other isolates (workers).
|
|
311
|
+
*
|
|
312
|
+
* @param options - Optional isolate id, material stats, and in-flight request count.
|
|
313
|
+
*/
|
|
314
|
+
estimateMemoryUsage(options?: {
|
|
315
|
+
id?: string;
|
|
316
|
+
materials?: MaterialMemoryStats;
|
|
317
|
+
inFlightRequests?: number;
|
|
318
|
+
}): IsolateMemoryStats;
|
|
302
319
|
}
|
package/lib/font/meshFont.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FontData as ThreeFontData } from 'three/examples/jsm/loaders/FontLoader.js';
|
|
2
|
+
import { FontMemoryStats } from '../memory/types';
|
|
2
3
|
import { BaseFont } from './baseFont';
|
|
3
4
|
import { FontData } from './font';
|
|
4
5
|
import { MeshTextShape } from './meshTextShape';
|
|
@@ -148,5 +149,13 @@ export declare class MeshFont extends BaseFont {
|
|
|
148
149
|
* @returns The shape data for the not found indicator
|
|
149
150
|
*/
|
|
150
151
|
getNotFoundTextShape(size: number): MeshTextShape;
|
|
152
|
+
/**
|
|
153
|
+
* Estimates memory used by this mesh font (parsed opentype + glyphs + geometry cache).
|
|
154
|
+
*/
|
|
155
|
+
estimateMemoryUsage(): FontMemoryStats;
|
|
156
|
+
/**
|
|
157
|
+
* Clears glyph and geometry caches. Does not unload the opentype parse until GC.
|
|
158
|
+
*/
|
|
159
|
+
dispose(): void;
|
|
151
160
|
}
|
|
152
161
|
export {};
|
package/lib/font/shxFont.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ShxFontData, ShxFontMetrics } from '@mlightcad/shx-parser';
|
|
2
|
+
import { FontMemoryStats } from '../memory/types';
|
|
2
3
|
import { BaseFont } from './baseFont';
|
|
3
4
|
import { FontData } from './font';
|
|
4
5
|
import { ShxTextShape } from './shxTextShape';
|
|
@@ -93,6 +94,14 @@ export declare class ShxFont extends BaseFont {
|
|
|
93
94
|
* @returns The fallback shape, or undefined if it cannot be built.
|
|
94
95
|
*/
|
|
95
96
|
getNotFoundTextShape(size: number): ShxTextShape | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Estimates memory used by this SHX font (parsed tables + layout/geometry caches).
|
|
99
|
+
*/
|
|
100
|
+
estimateMemoryUsage(): FontMemoryStats;
|
|
101
|
+
/**
|
|
102
|
+
* Clears layout/code caches and disposes retained shape geometries.
|
|
103
|
+
*/
|
|
104
|
+
dispose(): void;
|
|
96
105
|
/**
|
|
97
106
|
* Resolves the internal SHX character code for a given Unicode character.
|
|
98
107
|
* @param char - The input character.
|
|
@@ -41,4 +41,12 @@ export declare class ShxTextShape extends BaseTextShape {
|
|
|
41
41
|
toGeometry(): THREE.BufferGeometry<THREE.NormalBufferAttributes>;
|
|
42
42
|
/** @inheritdoc */
|
|
43
43
|
hasStrokeGeometry(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Estimated bytes of the lazily built BufferGeometry, or 0 if not built / disposed.
|
|
46
|
+
*/
|
|
47
|
+
estimateMemoryBytes(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Disposes the lazily built BufferGeometry, if any.
|
|
50
|
+
*/
|
|
51
|
+
dispose(): void;
|
|
44
52
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FontManager } from '../font/fontManager';
|
|
2
|
+
import { StyleManager } from '../renderer/styleManager';
|
|
3
|
+
import { IsolateMemoryStats, MaterialMemoryStats, MemoryUsageReport } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Reads material stats from a style manager when it exposes `getMaterialStats`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getMaterialStatsFromStyleManager(styleManager?: StyleManager | null): MaterialMemoryStats;
|
|
8
|
+
/**
|
|
9
|
+
* Builds isolate stats from a FontManager and optional style manager.
|
|
10
|
+
*/
|
|
11
|
+
export declare function collectIsolateMemoryStats(fontManager: FontManager, options: {
|
|
12
|
+
id: string;
|
|
13
|
+
styleManager?: StyleManager | null;
|
|
14
|
+
materials?: MaterialMemoryStats;
|
|
15
|
+
inFlightRequests?: number;
|
|
16
|
+
}): IsolateMemoryStats;
|
|
17
|
+
/**
|
|
18
|
+
* Reads Chrome `performance.memory` when available.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readJsHeapStats(): MemoryUsageReport['jsHeap'] | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Sums TypedArray byte lengths of all attributes and the index on a BufferGeometry.
|
|
4
|
+
* Returns 0 for missing or already-disposed geometries.
|
|
5
|
+
*/
|
|
6
|
+
export declare function estimateGeometryBytes(geometry: THREE.BufferGeometry | undefined | null): number;
|
|
7
|
+
/**
|
|
8
|
+
* UTF-16 string byte length (JavaScript strings are UTF-16 code units).
|
|
9
|
+
*/
|
|
10
|
+
export declare function estimateStringBytes(value: string | undefined | null): number;
|
|
11
|
+
/**
|
|
12
|
+
* Best-effort source byte length from raw font payload.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSourceByteLength(data: unknown): number;
|
|
15
|
+
/**
|
|
16
|
+
* Formats a byte count as a short human-readable string.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatBytes(bytes: number): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { collectIsolateMemoryStats, getMaterialStatsFromStyleManager, readJsHeapStats } from './collectIsolateMemoryStats';
|
|
2
|
+
export { estimateGeometryBytes, estimateStringBytes, formatBytes, getSourceByteLength } from './estimateGeometryBytes';
|
|
3
|
+
export { formatMemoryUsageReport } from './formatMemoryUsageReport';
|
|
4
|
+
export { emptyMaterialStats, estimateMaterialBytes, MATERIAL_ESTIMATED_BYTES, MESH_PARSED_FONT_OVERHEAD, SHX_PARSED_FONT_OVERHEAD } from './types';
|
|
5
|
+
export type { CacheBucketStats, FontMemoryStats, IndexedDbFontCacheStats, IsolateMemoryStats, MaterialMemoryStats, MemoryUsageReport } from './types';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approximate byte size of one cached Three.js material entry.
|
|
3
|
+
* Materials are small compared to fonts; this is a fixed heuristic.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MATERIAL_ESTIMATED_BYTES = 512;
|
|
6
|
+
/**
|
|
7
|
+
* Estimates material cache bytes from counts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function estimateMaterialBytes(meshCount: number, lineCount: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Multiplier applied to mesh font source bytes to estimate opentype.js parse overhead.
|
|
12
|
+
* Aligned with the documented ~40MB resident cost for large CJK mesh fonts.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MESH_PARSED_FONT_OVERHEAD = 2.5;
|
|
15
|
+
/**
|
|
16
|
+
* Multiplier applied to SHX font source bytes to estimate parsed SHX tables.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SHX_PARSED_FONT_OVERHEAD = 1.5;
|
|
19
|
+
/**
|
|
20
|
+
* Entry-count and estimated byte size for one cache bucket.
|
|
21
|
+
*/
|
|
22
|
+
export interface CacheBucketStats {
|
|
23
|
+
entries: number;
|
|
24
|
+
maxEntries: number;
|
|
25
|
+
estimatedBytes: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Material cache occupancy for a style manager.
|
|
29
|
+
*/
|
|
30
|
+
export interface MaterialMemoryStats {
|
|
31
|
+
meshCount: number;
|
|
32
|
+
lineCount: number;
|
|
33
|
+
estimatedBytes: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Empty material stats when no style manager is available.
|
|
37
|
+
*/
|
|
38
|
+
export declare function emptyMaterialStats(): MaterialMemoryStats;
|
|
39
|
+
/**
|
|
40
|
+
* Per-font memory estimate (parsed font + caches).
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* `parsedFontEstimatedBytes` is heuristic (source size × overhead). Geometry
|
|
44
|
+
* buffers and outline strings are measured from TypedArrays / string lengths.
|
|
45
|
+
*/
|
|
46
|
+
export interface FontMemoryStats {
|
|
47
|
+
names: string[];
|
|
48
|
+
type: 'mesh' | 'shx';
|
|
49
|
+
sourceByteLength: number;
|
|
50
|
+
parsedFontEstimatedBytes: number;
|
|
51
|
+
charGeometryCache: CacheBucketStats;
|
|
52
|
+
meshGlyphs?: {
|
|
53
|
+
glyphCount: number;
|
|
54
|
+
outlineStringBytes: number;
|
|
55
|
+
};
|
|
56
|
+
shxLayoutCache?: CacheBucketStats;
|
|
57
|
+
estimatedBytes: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Memory estimate for one JS isolate (main thread or a single worker).
|
|
61
|
+
*/
|
|
62
|
+
export interface IsolateMemoryStats {
|
|
63
|
+
id: string;
|
|
64
|
+
inFlightRequests?: number;
|
|
65
|
+
fonts: FontMemoryStats[];
|
|
66
|
+
materials: MaterialMemoryStats;
|
|
67
|
+
totalEstimatedBytes: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* IndexedDB persistent font-blob storage stats.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* Collecting these stats loads font blobs into the JS heap temporarily.
|
|
74
|
+
*/
|
|
75
|
+
export interface IndexedDbFontCacheStats {
|
|
76
|
+
fontCount: number;
|
|
77
|
+
totalBytes: number;
|
|
78
|
+
fonts: Array<{
|
|
79
|
+
name: string;
|
|
80
|
+
type: string;
|
|
81
|
+
bytes: number;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Aggregated memory usage report for mtext-renderer.
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* This is an estimate, not a heap snapshot.
|
|
89
|
+
* {@link MemoryUsageReport.totalEstimatedBytes} counts live isolate memory only
|
|
90
|
+
* (still-loaded fonts and caches). IndexedDB storage is listed separately and
|
|
91
|
+
* is not part of the total. Scene-held MText objects created by the application
|
|
92
|
+
* are not included. Released / disposed font caches are excluded.
|
|
93
|
+
*/
|
|
94
|
+
export interface MemoryUsageReport {
|
|
95
|
+
collectedAt: number;
|
|
96
|
+
/** Live isolate memory only; excludes IndexedDB and disposed resources. */
|
|
97
|
+
totalEstimatedBytes: number;
|
|
98
|
+
mainThread: IsolateMemoryStats;
|
|
99
|
+
workers: IsolateMemoryStats[];
|
|
100
|
+
/** Persistent disk/IDB cache; not included in {@link totalEstimatedBytes}. */
|
|
101
|
+
indexedDbFontCache: IndexedDbFontCacheStats;
|
|
102
|
+
jsHeap?: {
|
|
103
|
+
usedJSHeapSize: number;
|
|
104
|
+
totalJSHeapSize: number;
|
|
105
|
+
jsHeapSizeLimit: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* AutoCAD single-line spacing as a multiple of text height ("3-on-5").
|
|
3
|
+
*
|
|
4
|
+
* DXF group 44 (`lineSpaceFactor`) is a ratio relative to this single spacing,
|
|
5
|
+
* so baseline-to-baseline distance =
|
|
6
|
+
* `lineSpaceFactor × LINE_SPACING_SCALE_FACTOR × textHeight`.
|
|
4
7
|
*/
|
|
5
|
-
export declare const LINE_SPACING_SCALE_FACTOR
|
|
8
|
+
export declare const LINE_SPACING_SCALE_FACTOR: number;
|
|
9
|
+
/**
|
|
10
|
+
* Default DXF group-44 line spacing factor (AutoCAD single spacing).
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_LINE_SPACE_FACTOR = 1;
|
|
6
13
|
/**
|
|
7
14
|
* Vertical compensation needed after switching normal glyph placement from
|
|
8
15
|
* top-anchored to baseline-anchored coordinates.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MaterialMemoryStats } from '../memory/types';
|
|
1
2
|
import { StyleManager } from './styleManager';
|
|
2
3
|
import { ColorSettings } from './types';
|
|
3
4
|
import * as THREE from 'three';
|
|
@@ -10,6 +11,10 @@ export declare class DefaultStyleManager implements StyleManager {
|
|
|
10
11
|
unsupportedTextStyles: Record<string, number>;
|
|
11
12
|
getMeshBasicMaterial(colorSettings: ColorSettings): THREE.Material;
|
|
12
13
|
getLineBasicMaterial(colorSettings: ColorSettings): THREE.Material;
|
|
14
|
+
/**
|
|
15
|
+
* Returns occupancy of the material caches (counts + heuristic bytes).
|
|
16
|
+
*/
|
|
17
|
+
getMaterialStats(): MaterialMemoryStats;
|
|
13
18
|
/**
|
|
14
19
|
* Builds a stable material key from traits.
|
|
15
20
|
* Key differs for shader vs basic, ByLayer vs ByEntity.
|
|
@@ -16,7 +16,8 @@ export interface MTextFormatOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
widthFactor: number;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* AutoCAD DXF group-44 line spacing factor: ratio of actual line spacing to
|
|
20
|
+
* single spacing (`5/3` of text height). Default is `1.0`.
|
|
20
21
|
*/
|
|
21
22
|
lineSpaceFactor: number;
|
|
22
23
|
/**
|
|
@@ -165,7 +166,8 @@ export declare class MTextProcessor {
|
|
|
165
166
|
*/
|
|
166
167
|
get defaultFontSize(): number;
|
|
167
168
|
/**
|
|
168
|
-
*
|
|
169
|
+
* AutoCAD DXF group-44 line spacing factor (multiple of single spacing).
|
|
170
|
+
* Single spacing is {@link LINE_SPACING_SCALE_FACTOR} × text height.
|
|
169
171
|
*/
|
|
170
172
|
get defaultLineSpaceFactor(): number;
|
|
171
173
|
/**
|
|
@@ -191,7 +193,11 @@ export declare class MTextProcessor {
|
|
|
191
193
|
*/
|
|
192
194
|
get currentLayoutFontSize(): number;
|
|
193
195
|
/**
|
|
194
|
-
*
|
|
196
|
+
* Baseline-to-baseline advance for the current line (AutoCAD MTEXT semantics).
|
|
197
|
+
*
|
|
198
|
+
* Single spacing is `5/3` of the drawing-space text height; `lineSpaceFactor`
|
|
199
|
+
* (DXF group 44) scales that distance. Font glyph scale factors must not
|
|
200
|
+
* affect this layout metric — use {@link currentLayoutFontSize}.
|
|
195
201
|
*/
|
|
196
202
|
get currentLineHeight(): number;
|
|
197
203
|
/**
|
package/lib/renderer/types.d.ts
CHANGED
|
@@ -170,7 +170,11 @@ export interface MTextData {
|
|
|
170
170
|
attachmentPoint?: MTextAttachmentPoint;
|
|
171
171
|
/** Determines the primary direction in which text flows */
|
|
172
172
|
drawingDirection?: MTextFlowDirection;
|
|
173
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* AutoCAD DXF group-44 line spacing factor.
|
|
175
|
+
* Ratio of actual baseline spacing to single spacing (`5/3` of text height).
|
|
176
|
+
* Default is `1.0`.
|
|
177
|
+
*/
|
|
174
178
|
lineSpaceFactor?: number;
|
|
175
179
|
/** The width scaling factor applied to each character. Default is 1.0 */
|
|
176
180
|
widthFactor?: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IsolateMemoryStats } from '../memory';
|
|
1
2
|
import { StyleManager } from '../renderer/styleManager';
|
|
2
3
|
import { ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
|
|
3
4
|
import { MTextBaseRenderer, MTextObject } from './baseRenderer';
|
|
@@ -46,6 +47,10 @@ export declare class MainThreadRenderer implements MTextBaseRenderer {
|
|
|
46
47
|
name: string[];
|
|
47
48
|
}>;
|
|
48
49
|
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Estimates memory used by fonts and materials in the main-thread isolate.
|
|
52
|
+
*/
|
|
53
|
+
estimateMemoryUsage(): IsolateMemoryStats;
|
|
49
54
|
destroy(): void;
|
|
50
55
|
private ensureInitialized;
|
|
51
56
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DefaultFontsPreset, FontLoadStatus } from '../font';
|
|
2
|
+
import { MemoryUsageReport } from '../memory';
|
|
2
3
|
import { StyleManager } from '../renderer';
|
|
3
4
|
import { ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
|
|
4
5
|
import { MTextObject } from './baseRenderer';
|
|
@@ -89,6 +90,19 @@ export declare class UnifiedRenderer {
|
|
|
89
90
|
name: string[];
|
|
90
91
|
}>;
|
|
91
92
|
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Estimates memory used by mtext-renderer across the main thread and workers.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* `totalEstimatedBytes` covers **live** isolate memory only (fonts still loaded
|
|
98
|
+
* in memory, caches, materials). IndexedDB font blobs are reported separately
|
|
99
|
+
* under {@link MemoryUsageReport.indexedDbFontCache} and are **not** included
|
|
100
|
+
* in the total — they remain after {@link FontManager.release}. Disposed /
|
|
101
|
+
* released font caches are excluded. Application-held scene graphs are not
|
|
102
|
+
* included. Collecting IndexedDB stats temporarily loads cached blobs into
|
|
103
|
+
* the JS heap.
|
|
104
|
+
*/
|
|
105
|
+
estimateMemoryUsage(): Promise<MemoryUsageReport>;
|
|
92
106
|
/**
|
|
93
107
|
* Parse and cache a user-uploaded font file in IndexedDB.
|
|
94
108
|
* Always runs on the main-thread {@link FontManager} so the cache is shared
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IsolateMemoryStats } from '../memory/types';
|
|
1
2
|
import { StyleManager } from '../renderer/styleManager';
|
|
2
3
|
import { CharBox, ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
|
|
3
4
|
import { MTextBaseRenderer, MTextObject } from './baseRenderer';
|
|
@@ -181,6 +182,13 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
|
|
|
181
182
|
name: string[];
|
|
182
183
|
}>;
|
|
183
184
|
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Collects memory estimates from each worker in the pool.
|
|
187
|
+
*
|
|
188
|
+
* Worker ids are rewritten to `worker-0`, `worker-1`, … and
|
|
189
|
+
* {@link inFlightPerWorker} counts are attached.
|
|
190
|
+
*/
|
|
191
|
+
estimateMemoryUsage(): Promise<IsolateMemoryStats[]>;
|
|
184
192
|
/**
|
|
185
193
|
* Reconstruct MText object from JSON serialized data
|
|
186
194
|
*/
|