@mlightcad/mtext-renderer 0.12.4 → 0.12.6

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.
@@ -9,6 +9,12 @@ export declare class DefaultFontLoader implements FontLoader {
9
9
  private _avaiableFonts;
10
10
  private _baseUrl;
11
11
  private _avaiableFontMap;
12
+ /**
13
+ * Shared in-flight metadata fetch. Concurrent {@link getAvailableFonts} /
14
+ * {@link load} callers (common with lazy per-entity font requests) must not
15
+ * each hit `fonts.json` independently.
16
+ */
17
+ private _availableFontsPromise;
12
18
  /**
13
19
  * Creates a new instance of DefaultFontLoader
14
20
  */
@@ -31,6 +37,8 @@ export declare class DefaultFontLoader implements FontLoader {
31
37
  /**
32
38
  * Retrieves information about all available fonts in the system.
33
39
  * Loads font metadata from a CDN if not already loaded.
40
+ * Concurrent callers share one in-flight fetch so `fonts.json` is requested
41
+ * at most once per loader instance / baseUrl.
34
42
  * @returns Promise that resolves to an array of FontInfo objects
35
43
  * @throws {Error} If font metadata cannot be loaded from the CDN
36
44
  */
@@ -43,6 +51,10 @@ export declare class DefaultFontLoader implements FontLoader {
43
51
  * @returns Promise that resolves to an array of FontLoadStatus objects
44
52
  */
45
53
  load(fontNames: readonly string[]): Promise<FontLoadStatus[]>;
54
+ /**
55
+ * Fetches and caches remote font metadata for the given base URL.
56
+ */
57
+ private fetchAvailableFonts;
46
58
  /**
47
59
  * Build one font map. The key is font name. The value is font info.
48
60
  */
@@ -9,11 +9,11 @@ export type DefaultFontsPreset =
9
9
  'minimal'
10
10
  /** Classic R12/R14 stack: SHX basics, GB big font, then mesh CJK and AMGDT. */
11
11
  | 'r12r14'
12
- /** Later-era stack: hztxt big font with simsun and AMGDT symbols. */
12
+ /** Later-era stack: simsun first for Latin metrics, then hztxt big font. */
13
13
  | 'modern'
14
14
  /** Western SHX fonts plus simsun and AMGDT; no CJK-specific SHX big fonts. */
15
15
  | 'international'
16
- /** Broad CJK coverage: both GB big-font SHX files plus common mesh fallbacks. */
16
+ /** Broad CJK coverage: simsun first, then GB big-font SHX files. */
17
17
  | 'cjk';
18
18
  /**
19
19
  * Predefined text-font fallback chains (primary / big-font substitutes and CJK
@@ -228,6 +228,13 @@ export declare class FontManager {
228
228
  * @returns The original font name if found, or the replacement font name if not found
229
229
  */
230
230
  findAndReplaceFont(fontName: string): string;
231
+ /**
232
+ * Returns the first loaded font from {@link defaultFonts}.
233
+ *
234
+ * @param skipBigfont When true, ignores SHX BIGFONT faces so ASCII/Latin text
235
+ * is not forced through fullwidth CJK glyph cells.
236
+ */
237
+ private pickLoadedDefaultFont;
231
238
  /**
232
239
  * Gets font by font name. Return undefined if not found.
233
240
  * @param fontName - The font name to find
@@ -288,6 +288,10 @@ export declare class MTextProcessor {
288
288
  private applyColorSnapshotChanges;
289
289
  /**
290
290
  * Apply width factor changes, resolving relative factors to absolute values.
291
+ *
292
+ * Absolute `\Wvalue;` replaces the current width factor. Relative `\Wvaluex;`
293
+ * multiplies the current width factor (AutoCAD / ezdxf semantics).
294
+ *
291
295
  * @param widthFactor Width factor change data.
292
296
  */
293
297
  private applyWidthFactorChange;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Replaces AutoCAD `\U+XXXX` (exactly four hex digits) with the corresponding
3
+ * Unicode character so a following hex digit is not absorbed into the code point.
4
+ */
5
+ export declare function expandUnicodeEscapes(text: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",
@@ -43,7 +43,7 @@
43
43
  "3d-text"
44
44
  ],
45
45
  "dependencies": {
46
- "@mlightcad/mtext-parser": "^1.5.0",
46
+ "@mlightcad/mtext-parser": "^1.5.1",
47
47
  "@mlightcad/shx-parser": "^1.4.5",
48
48
  "iconv-lite": "^0.7.0",
49
49
  "idb": "^8.0.3",