@mlightcad/mtext-renderer 0.11.0 → 0.11.1

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.
@@ -60,6 +60,10 @@ export declare abstract class BaseFont {
60
60
  * @returns The shape data for the character code, or undefined if not found
61
61
  */
62
62
  abstract getCodeShape(code: number, size: number): BaseTextShape | undefined;
63
+ /**
64
+ * Gets a named SHX shape glyph when supported by the font implementation.
65
+ */
66
+ getShapeByName(_name: string, _size: number): BaseTextShape | undefined;
63
67
  /**
64
68
  * Gets the scale factor for this font.
65
69
  * This is used to adjust the size of characters when rendering.
@@ -184,6 +184,14 @@ export declare class FontManager {
184
184
  * @returns The text shape for the character, or undefined if not found
185
185
  */
186
186
  getCharShape(char: string, fontName: string, size: number): BaseTextShape | undefined;
187
+ /**
188
+ * Resolves a named SHX shape glyph from the specified font.
189
+ */
190
+ getShapeByName(name: string, fontName: string, size: number): BaseTextShape | undefined;
191
+ /**
192
+ * Resolves an SHX shape glyph by numeric character code from the specified font.
193
+ */
194
+ getShapeByCode(code: number, fontName: string, size: number): BaseTextShape | undefined;
187
195
  /**
188
196
  * Gets the text shape from the first loaded default font that contains the character.
189
197
  * Used after primary and optional bigFont lookups per AutoCAD text-style semantics.
@@ -55,6 +55,12 @@ export declare class ShxFont extends BaseFont {
55
55
  * @returns The shape data for the character code, or undefined if not found
56
56
  */
57
57
  getCodeShape(code: number, size: number): ShxTextShape | undefined;
58
+ /**
59
+ * Gets the shape data for a named SHX shape at a given size.
60
+ *
61
+ * Shape names are matched case-insensitively via the underlying SHX parser.
62
+ */
63
+ getShapeByName(name: string, size: number): ShxTextShape | undefined;
58
64
  /** True when the SHX glyph has drawable strokes or a non-zero pen advance. */
59
65
  private static hasRenderableStrokes;
60
66
  /**
@@ -1,6 +1,7 @@
1
1
  export * from './colorUtils';
2
2
  export * from './constants';
3
3
  export * from './mtext';
4
+ export * from './shape';
4
5
  export * from './mtextDataUtils';
5
6
  export * from './styleManager';
6
7
  export * from './types';
@@ -1,6 +1,6 @@
1
1
  import { FontManager } from '../font';
2
2
  import { StyleManager } from './styleManager';
3
- import { ColorSettings, MTextData, MTextLayout, TextStyle } from './types';
3
+ import { ColorSettings, MTextData, MTextLayout, ShapeData, TextStyle } from './types';
4
4
  import * as THREE from 'three';
5
5
  /**
6
6
  * Represents an AutoCAD MText object in Three.js.
@@ -101,6 +101,12 @@ export declare class MText extends THREE.Object3D {
101
101
  * @returns The created Three.js object, or undefined if creation fails
102
102
  */
103
103
  private loadMText;
104
+ /**
105
+ * Builds and places one SHX shape glyph.
106
+ */
107
+ loadShape(shapeData: ShapeData, style: TextStyle): THREE.Object3D<THREE.Object3DEventMap> | undefined;
108
+ private finalizePlacement;
109
+ private createShapeGroup;
104
110
  /**
105
111
  * Creates a group of text elements from MText data.
106
112
  * @param mtextData - The MText data to process
@@ -275,6 +275,19 @@ export declare class MTextProcessor {
275
275
  * @param group The group to add processed geometries to
276
276
  */
277
277
  private startNewParagraph;
278
+ /**
279
+ * Renders one SHX shape glyph for AutoCAD SHAPE entities.
280
+ *
281
+ * The glyph is resolved by {@link shapeName} first, then by {@link shapeNumber}.
282
+ */
283
+ processShapeGlyph(shapeName?: string, shapeNumber?: number): THREE.Object3D | undefined;
284
+ private resolveShapeGlyph;
285
+ /**
286
+ * Builds geometry for one glyph and appends it to the output buffers.
287
+ *
288
+ * @returns Horizontal advance width after width factor and oblique skew.
289
+ */
290
+ private buildShapeGeometry;
278
291
  /**
279
292
  * Render the specified texts
280
293
  * @param item Input texts to render
@@ -0,0 +1,25 @@
1
+ import { FontManager } from '../font';
2
+ import { StyleManager } from './styleManager';
3
+ import { ColorSettings, MTextLayout, ShapeData, TextStyle } from './types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Represents one AutoCAD SHAPE entity in Three.js.
7
+ */
8
+ export declare class Shape extends THREE.Object3D {
9
+ private _shapeData;
10
+ private _style;
11
+ private _fontsInStyleLoaded;
12
+ private _styleManager;
13
+ private _fontManager;
14
+ private _colorSettings;
15
+ private _box;
16
+ constructor(shapeData: ShapeData, style: TextStyle, styleManager: StyleManager, fontManager: FontManager, colorSettings?: ColorSettings);
17
+ get box(): THREE.Box3;
18
+ get styleManager(): StyleManager;
19
+ get textStyle(): TextStyle;
20
+ createLayoutData(): MTextLayout;
21
+ asyncDraw(): Promise<void>;
22
+ syncDraw(): void;
23
+ private createPlacementData;
24
+ private getFontName;
25
+ }
@@ -177,6 +177,25 @@ export interface MTextData {
177
177
  /** Whether to collect per-character bounding boxes for picking. Default is true */
178
178
  collectCharBoxes?: boolean;
179
179
  }
180
+ /**
181
+ * Describes one AutoCAD SHAPE entity for rendering.
182
+ */
183
+ export interface ShapeData {
184
+ /** Shape name within the SHX font (DXF group 2). */
185
+ name?: string;
186
+ /** Numeric shape code within the SHX font. */
187
+ shapeNumber?: number;
188
+ /** Shape height (DXF group 40). */
189
+ size: number;
190
+ /** Insertion point in WCS coordinates. */
191
+ position: Point3d;
192
+ /** Rotation relative to the shape OCS X axis, in radians. */
193
+ rotation?: number;
194
+ /** Extrusion/normal vector. */
195
+ directionVector?: Point3d;
196
+ /** Relative X-scale factor. */
197
+ widthFactor?: number;
198
+ }
180
199
  /**
181
200
  * Represents a text style configuration that defines the visual appearance and formatting of text.
182
201
  * This interface contains properties that control various aspects of text rendering including font,
@@ -1,5 +1,5 @@
1
1
  import { StyleManager } from '../renderer/styleManager';
2
- import { ColorSettings, MTextData, MTextLayout, TextStyle } from '../renderer/types';
2
+ import { ColorSettings, MTextData, MTextLayout, ShapeData, TextStyle } from '../renderer/types';
3
3
  import * as THREE from 'three';
4
4
  /**
5
5
  * Represents a rendered MText object that extends THREE.Object3D with additional MText-specific properties.
@@ -55,6 +55,14 @@ export interface MTextBaseRenderer {
55
55
  * @returns A Promise resolving to a populated `MTextObject` ready to add to a scene.
56
56
  */
57
57
  syncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
58
+ /**
59
+ * Render one SHX shape glyph synchronously.
60
+ */
61
+ syncRenderShape(shapeContent: ShapeData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
62
+ /**
63
+ * Render one SHX shape glyph asynchronously.
64
+ */
65
+ asyncRenderShape(shapeContent: ShapeData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
58
66
  /**
59
67
  * Ensure the specified fonts are available to the renderer.
60
68
  *
@@ -1,5 +1,5 @@
1
1
  import { StyleManager } from '../renderer/styleManager';
2
- import { ColorSettings, MTextData, TextStyle } from '../renderer/types';
2
+ import { ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
3
3
  import { MTextBaseRenderer, MTextObject } from './baseRenderer';
4
4
  /**
5
5
  * Main thread renderer for MText objects
@@ -30,6 +30,8 @@ export declare class MainThreadRenderer implements MTextBaseRenderer {
30
30
  * that default font is loaded and fonts needed in mtext are loaded.
31
31
  */
32
32
  syncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
33
+ asyncRenderShape(shapeContent: ShapeData, textStyle: TextStyle, colorSettings?: ColorSettings): Promise<MTextObject>;
34
+ syncRenderShape(shapeContent: ShapeData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
33
35
  /**
34
36
  * Load fonts in the main thread
35
37
  */
@@ -1,6 +1,6 @@
1
1
  import { DefaultFontsPreset } from '../font';
2
2
  import { StyleManager } from '../renderer';
3
- import { ColorSettings, MTextData, TextStyle } from '../renderer/types';
3
+ import { ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
4
4
  import { MTextObject } from './baseRenderer';
5
5
  import { WebWorkerRendererConfig } from './webWorkerRenderer';
6
6
  export type RenderMode = 'main' | 'worker';
@@ -57,6 +57,8 @@ export declare class UnifiedRenderer {
57
57
  * @param colorSettings - Optional color context (ByLayer, ByBlock colors).
58
58
  */
59
59
  syncRenderMText(mtextContent: MTextData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
60
+ asyncRenderShape(shapeContent: ShapeData, textStyle: TextStyle, colorSettings?: ColorSettings, _mode?: RenderMode): Promise<MTextObject>;
61
+ syncRenderShape(shapeContent: ShapeData, textStyle: TextStyle, colorSettings?: ColorSettings): MTextObject;
60
62
  /**
61
63
  * Sets the default font fallback chain on the active renderer and workers.
62
64
  */
@@ -1,5 +1,5 @@
1
1
  import { StyleManager } from '../renderer/styleManager';
2
- import { CharBox, ColorSettings, MTextData, TextStyle } from '../renderer/types';
2
+ import { CharBox, ColorSettings, MTextData, ShapeData, TextStyle } from '../renderer/types';
3
3
  import { MTextBaseRenderer, MTextObject } from './baseRenderer';
4
4
  /**
5
5
  * Configuration options for WebWorkerRenderer
@@ -171,6 +171,8 @@ export declare class WebWorkerRenderer implements MTextBaseRenderer {
171
171
  * Notes: It isn't supported yet.
172
172
  */
173
173
  syncRenderMText(_mtextContent: MTextData, _textStyle: TextStyle, _colorSettings?: ColorSettings): MTextObject;
174
+ asyncRenderShape(_shapeContent: ShapeData, _textStyle: TextStyle, _colorSettings?: ColorSettings): Promise<MTextObject>;
175
+ syncRenderShape(_shapeContent: ShapeData, _textStyle: TextStyle, _colorSettings?: ColorSettings): MTextObject;
174
176
  loadFonts(fonts: readonly string[]): Promise<{
175
177
  loaded: string[];
176
178
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",