@mlightcad/mtext-renderer 0.13.4 → 0.13.5

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.
@@ -128,7 +128,7 @@ export declare class MeshFont extends BaseFont {
128
128
  * @param size - The size of the text
129
129
  * @returns Indexed line-pair BufferGeometry suitable for LineSegments
130
130
  */
131
- generateStrokeGeometry(text: string, size: number): import('three').BufferGeometry<import('three').NormalBufferAttributes>;
131
+ generateStrokeGeometry(text: string, size: number): import('three').BufferGeometry<import('three').NormalBufferAttributes, import('three').BufferGeometryEventMap>;
132
132
  /**
133
133
  * Gets the shape data for a specific character at a given size.
134
134
  * @param char - The character to get the shape for
@@ -38,7 +38,7 @@ export declare class ShxTextShape extends BaseTextShape {
38
38
  * Converts the text shape to a THREE.js geometry.
39
39
  * @returns A BufferGeometry representing the text shape.
40
40
  */
41
- toGeometry(): THREE.BufferGeometry<THREE.NormalBufferAttributes>;
41
+ toGeometry(): THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>;
42
42
  /** @inheritdoc */
43
43
  hasStrokeGeometry(): boolean;
44
44
  /**
@@ -1,51 +1,17 @@
1
- import { BufferGeometry, Shape } from 'three';
1
+ import { BufferGeometry } from 'three';
2
2
  import { Font } from 'three/examples/jsm/loaders/FontLoader.js';
3
3
  type Direction = 'ltr' | 'rtl' | 'tb';
4
4
  /**
5
- * Extended Font that fixes inner holes for problematic fonts like SimSun.
6
- * Certain characters have incorrect inner contours (holes), e.g., 面, 限, 用, 色, 8.
5
+ * Font used for mesh glyphs.
6
+ *
7
+ * Filled outlines come from {@link Font.generateShapes}, which delegates to
8
+ * `ShapePath.toShapes()`. That path correctly classifies holes for fonts such
9
+ * as SimSun (面, 限, 用, 色, 8) starting with three.js r185 (0.185.1).
10
+ *
11
+ * Stroke geometry is still built here: it only needs sampled contours, not
12
+ * hole classification.
7
13
  */
8
14
  export declare class ThreeFont extends Font {
9
- /**
10
- * Generates geometry shapes from the given text and size.
11
- *
12
- * Algorithm overview:
13
- * 1. Split the input text into individual characters.
14
- * 2. For each character:
15
- * a. Retrieve the glyph data from the font.
16
- * b. Convert the glyph outline commands into a ShapePath.
17
- * - 'm' → moveTo
18
- * - 'l' → lineTo
19
- * - 'q' → quadraticCurveTo
20
- * - 'b' → cubic bezierCurveTo
21
- * c. Apply scaling to match the requested font size.
22
- * d. Apply offsets for proper placement (supports multiple lines and directions).
23
- * 3. Handle text direction:
24
- * - 'ltr': left-to-right
25
- * - 'rtl': right-to-left (characters reversed)
26
- * - 'tb': top-to-bottom (vertical layout)
27
- * 4. Collect all ShapePaths for the text.
28
- * 5. Convert each ShapePath into one or more Shape objects:
29
- * a. Sample points along each subPath to approximate geometry.
30
- * b. Determine which subPaths are outer contours and which are holes:
31
- * - For each subPath, check if it is fully contained inside another polygon.
32
- * - Assign the smallest containing polygon as its parent.
33
- * c. Compute the relative depth of each subPath to handle nested holes.
34
- * d. Reverse curves if necessary to maintain correct clockwise/counterclockwise winding:
35
- * - Outer contours: CCW
36
- * - Holes: CW
37
- * e. Build Shape objects with holes properly assigned.
38
- * 6. Return the final array of Shape objects ready for geometry creation.
39
- *
40
- * This algorithm ensures that complex characters with multiple independent contours
41
- * (including intersecting subpaths or holes) are rendered correctly.
42
- *
43
- * @param text - input string to convert to shapes
44
- * @param size - font size in units (default 100)
45
- * @param direction - text direction ('ltr', 'rtl', 'tb')
46
- * @returns array of Shape objects with proper holes and contours
47
- */
48
- generateShapes(text: string, size?: number, direction?: Direction): Shape[];
49
15
  /**
50
16
  * Samples glyph contours into line-segment geometry without hole detection
51
17
  * or triangulation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.13.4",
3
+ "version": "0.13.5",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",
@@ -51,12 +51,13 @@
51
51
  "devDependencies": {
52
52
  "@mlightcad/mtext-parser": "^1.5.5",
53
53
  "@types/opentype.js": "^1.3.10",
54
- "@types/three": "^0.172.0",
54
+ "@types/three": "^0.186.0",
55
+ "three": "^0.186.1",
55
56
  "vitest": "^3.2.4"
56
57
  },
57
58
  "peerDependencies": {
58
59
  "@mlightcad/mtext-parser": "^1.5.5",
59
- "three": "^0.172.0"
60
+ "three": ">=0.185.1"
60
61
  },
61
62
  "scripts": {
62
63
  "build": "tsc && vite build -c vite.config.main.ts && vite build -c vite.config.worker.ts",