three-text 0.4.11 → 0.5.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.
Files changed (94) hide show
  1. package/LICENSE +5 -660
  2. package/LICENSE_THIRD_PARTY +15 -49
  3. package/README.md +265 -44
  4. package/dist/index.cjs +3424 -3450
  5. package/dist/index.d.ts +163 -9
  6. package/dist/index.js +3420 -3451
  7. package/dist/index.min.cjs +718 -676
  8. package/dist/index.min.js +721 -679
  9. package/dist/index.umd.js +3561 -3579
  10. package/dist/index.umd.min.js +803 -756
  11. package/dist/p5/index.cjs +2738 -5
  12. package/dist/p5/index.js +2738 -5
  13. package/dist/patterns/index.js +0 -4
  14. package/dist/slug/index.cjs +380 -0
  15. package/dist/slug/index.d.ts +62 -0
  16. package/dist/slug/index.js +374 -0
  17. package/dist/three/index.cjs +50 -35
  18. package/dist/three/index.js +50 -35
  19. package/dist/three/react.cjs +5 -2
  20. package/dist/three/react.d.ts +66 -120
  21. package/dist/three/react.js +6 -3
  22. package/dist/types/core/Text.d.ts +3 -10
  23. package/dist/types/core/cache/sharedCaches.d.ts +2 -1
  24. package/dist/types/core/shaping/DrawCallbacks.d.ts +11 -3
  25. package/dist/types/core/shaping/TextShaper.d.ts +1 -5
  26. package/dist/types/core/types.d.ts +84 -0
  27. package/dist/types/index.d.ts +7 -3
  28. package/dist/types/{core/cache → mesh}/GlyphContourCollector.d.ts +4 -4
  29. package/dist/types/{core/cache → mesh}/GlyphGeometryBuilder.d.ts +5 -5
  30. package/dist/types/mesh/MeshGeometryBuilder.d.ts +18 -0
  31. package/dist/types/{core → mesh}/geometry/BoundaryClusterer.d.ts +1 -1
  32. package/dist/types/{core → mesh}/geometry/Extruder.d.ts +1 -1
  33. package/dist/types/{core → mesh}/geometry/PathOptimizer.d.ts +1 -1
  34. package/dist/types/{core → mesh}/geometry/Polygonizer.d.ts +1 -1
  35. package/dist/types/{core → mesh}/geometry/Tessellator.d.ts +1 -1
  36. package/dist/types/react/utils.d.ts +2 -0
  37. package/dist/types/vector/GlyphOutlineCollector.d.ts +25 -0
  38. package/dist/types/vector/GlyphVectorGeometryBuilder.d.ts +26 -0
  39. package/dist/types/vector/LoopBlinnGeometry.d.ts +68 -0
  40. package/dist/types/vector/index.d.ts +29 -0
  41. package/dist/types/vector/loopBlinnTSL.d.ts +11 -0
  42. package/dist/types/vector/react.d.ts +24 -0
  43. package/dist/types/vector/webgl/index.d.ts +7 -0
  44. package/dist/types/vector/webgpu/index.d.ts +11 -0
  45. package/dist/vector/index.cjs +1458 -0
  46. package/dist/vector/index.d.ts +122 -0
  47. package/dist/vector/index.js +1434 -0
  48. package/dist/vector/react.cjs +153 -0
  49. package/dist/vector/react.d.ts +317 -0
  50. package/dist/vector/react.js +132 -0
  51. package/dist/vector/types/slug-lib/src/SlugPacker.d.ts +17 -0
  52. package/dist/vector/types/slug-lib/src/WebGL2Renderer.d.ts +21 -0
  53. package/dist/vector/types/slug-lib/src/WebGPURenderer.d.ts +16 -0
  54. package/dist/vector/types/slug-lib/src/index.d.ts +15 -0
  55. package/dist/vector/types/slug-lib/src/shaderStrings.d.ts +9 -0
  56. package/dist/vector/types/slug-lib/src/types.d.ts +34 -0
  57. package/dist/vector/types/src/core/types.d.ts +381 -0
  58. package/dist/vector/types/src/hyphenation/HyphenationPatternLoader.d.ts +2 -0
  59. package/dist/vector/types/src/hyphenation/index.d.ts +7 -0
  60. package/dist/vector/types/src/hyphenation/types.d.ts +6 -0
  61. package/dist/vector/types/src/utils/Cache.d.ts +14 -0
  62. package/dist/vector/types/src/utils/vectors.d.ts +75 -0
  63. package/dist/vector/types/src/vector/VectorDataBuilder.d.ts +30 -0
  64. package/dist/vector/types/src/vector/VectorThreeAdapter.d.ts +27 -0
  65. package/dist/vector/types/src/vector/index.d.ts +15 -0
  66. package/dist/vector/webgl/index.cjs +229 -0
  67. package/dist/vector/webgl/index.d.ts +53 -0
  68. package/dist/vector/webgl/index.js +227 -0
  69. package/dist/vector/webgpu/index.cjs +321 -0
  70. package/dist/vector/webgpu/index.d.ts +57 -0
  71. package/dist/vector/webgpu/index.js +319 -0
  72. package/dist/webgl-vector/index.cjs +243 -0
  73. package/dist/webgl-vector/index.d.ts +34 -0
  74. package/dist/webgl-vector/index.js +241 -0
  75. package/dist/webgpu-vector/index.cjs +336 -0
  76. package/dist/webgpu-vector/index.d.ts +38 -0
  77. package/dist/webgpu-vector/index.js +334 -0
  78. package/package.json +49 -4
  79. package/dist/patterns/cs.cjs +0 -14
  80. package/dist/patterns/cs.d.ts +0 -28
  81. package/dist/patterns/cs.js +0 -14
  82. package/dist/patterns/cs.umd.js +0 -14
  83. package/dist/patterns/id.cjs +0 -14
  84. package/dist/patterns/id.d.ts +0 -28
  85. package/dist/patterns/id.js +0 -14
  86. package/dist/patterns/id.umd.js +0 -14
  87. package/dist/patterns/mk.cjs +0 -14
  88. package/dist/patterns/mk.d.ts +0 -28
  89. package/dist/patterns/mk.js +0 -14
  90. package/dist/patterns/mk.umd.js +0 -14
  91. package/dist/patterns/sr-cyrl.cjs +0 -14
  92. package/dist/patterns/sr-cyrl.d.ts +0 -28
  93. package/dist/patterns/sr-cyrl.js +0 -14
  94. package/dist/patterns/sr-cyrl.umd.js +0 -14
@@ -9,25 +9,57 @@ interface HyphenationTrieNode {
9
9
  };
10
10
  }
11
11
 
12
- interface CacheStats {
13
- size: number;
12
+ declare class Vec3 {
13
+ x: number;
14
+ y: number;
15
+ z: number;
16
+ constructor(x?: number, y?: number, z?: number);
17
+ set(x: number, y: number, z: number): Vec3;
18
+ clone(): Vec3;
19
+ copy(v: Vec3): Vec3;
20
+ add(v: Vec3): Vec3;
21
+ sub(v: Vec3): Vec3;
22
+ multiply(scalar: number): Vec3;
23
+ divide(scalar: number): Vec3;
24
+ length(): number;
25
+ lengthSq(): number;
26
+ normalize(): Vec3;
27
+ dot(v: Vec3): number;
28
+ cross(v: Vec3): Vec3;
29
+ distanceTo(v: Vec3): number;
30
+ distanceToSquared(v: Vec3): number;
31
+ equals(v: Vec3): boolean;
14
32
  }
15
33
 
16
- interface BoundingBox {
17
- min: {
18
- x: number;
19
- y: number;
20
- z: number;
21
- };
22
- max: {
23
- x: number;
24
- y: number;
25
- z: number;
26
- };
34
+ interface HarfBuzzGlyph {
35
+ g: number;
36
+ cl: number;
37
+ ax: number;
38
+ ay: number;
39
+ dx: number;
40
+ dy: number;
41
+ x?: number;
42
+ y?: number;
43
+ lineIndex: number;
44
+ absoluteTextIndex: number;
45
+ }
46
+ interface GlyphCluster {
47
+ text: string;
48
+ glyphs: HarfBuzzGlyph[];
49
+ position: Vec3;
27
50
  }
28
-
29
51
  type TextAlign = 'left' | 'center' | 'right' | 'justify';
30
52
  type TextDirection = 'ltr' | 'rtl';
53
+ interface LineInfo {
54
+ text: string;
55
+ originalStart: number;
56
+ originalEnd: number;
57
+ xOffset: number;
58
+ adjustmentRatio?: number;
59
+ isLastLine?: boolean;
60
+ naturalWidth?: number;
61
+ endedWithHyphen?: boolean;
62
+ }
31
63
  interface LoadedFont {
32
64
  hb: HarfBuzzAPI;
33
65
  fontBlob: HarfBuzzBlob;
@@ -120,87 +152,28 @@ interface FontMetrics {
120
152
  unitsPerEm: number;
121
153
  naturalLineHeight: number;
122
154
  }
123
- interface PathInfo {
124
- start: number;
125
- count: number;
126
- }
127
- interface GlyphGeometryInfo {
128
- textIndex: number;
129
- lineIndex: number;
130
- vertexStart: number;
131
- vertexCount: number;
132
- bounds: {
133
- min: {
134
- x: number;
135
- y: number;
136
- z: number;
137
- };
138
- max: {
139
- x: number;
140
- y: number;
141
- z: number;
142
- };
143
- };
144
- paths?: PathInfo[];
145
- }
146
- interface TextRange {
147
- start: number;
148
- end: number;
149
- originalText: string;
150
- bounds: {
151
- min: {
152
- x: number;
153
- y: number;
154
- z: number;
155
- };
156
- max: {
157
- x: number;
158
- y: number;
159
- z: number;
160
- };
161
- }[];
162
- glyphs: GlyphGeometryInfo[];
163
- lineIndices: number[];
155
+ interface TextLayoutData {
156
+ lines: LineInfo[];
157
+ scaledLineHeight: number;
158
+ letterSpacing: number;
159
+ align: string;
160
+ direction: TextDirection;
161
+ depth: number;
162
+ size: number;
163
+ pixelsPerFontUnit: number;
164
164
  }
165
- interface TextQueryOptions {
166
- byText?: string[];
167
- byCharRange?: {
168
- start: number;
169
- end: number;
170
- }[];
165
+ interface TextLayoutResult {
166
+ clustersByLine: GlyphCluster[][];
167
+ layoutData: TextLayoutData;
168
+ options: TextOptions;
169
+ loadedFont: LoadedFont;
170
+ fontId: string;
171
171
  }
172
- interface TextGeometryInfo {
173
- vertices: Float32Array;
174
- normals: Float32Array;
175
- indices: Uint32Array;
176
- colors?: Float32Array;
177
- glyphAttributes?: {
178
- glyphCenter: Float32Array;
179
- glyphIndex: Float32Array;
180
- glyphLineIndex: Float32Array;
181
- glyphProgress: Float32Array;
182
- glyphBaselineY: Float32Array;
183
- };
184
- glyphs: GlyphGeometryInfo[];
185
- planeBounds: BoundingBox;
186
- stats: {
187
- trianglesGenerated: number;
188
- verticesGenerated: number;
189
- pointsRemovedByVisvalingam: number;
190
- originalPointCount: number;
191
- } & Partial<CacheStats & {
192
- hitRate: number;
193
- memoryUsageMB: number;
194
- }>;
195
- query(options: TextQueryOptions): TextRange[];
196
- coloredRanges?: ColoredRange[];
197
- }
198
- interface TextHandle extends TextGeometryInfo {
172
+ interface TextLayoutHandle extends TextLayoutResult {
199
173
  getLoadedFont(): LoadedFont | undefined;
200
- getCacheSize(): number;
201
- clearCache(): void;
202
174
  measureTextWidth(text: string, letterSpacing?: number): number;
203
- update(options: Partial<TextOptions>): Promise<TextHandle>;
175
+ update(options: Partial<TextOptions>): Promise<TextLayoutHandle>;
176
+ dispose(): void;
204
177
  }
205
178
  interface ColorByRange {
206
179
  start: number;
@@ -214,26 +187,6 @@ interface ColorOptions {
214
187
  };
215
188
  byCharRange?: ColorByRange[];
216
189
  }
217
- interface ColoredRange {
218
- start: number;
219
- end: number;
220
- originalText: string;
221
- color: [number, number, number];
222
- bounds: {
223
- min: {
224
- x: number;
225
- y: number;
226
- z: number;
227
- };
228
- max: {
229
- x: number;
230
- y: number;
231
- z: number;
232
- };
233
- }[];
234
- glyphs: GlyphGeometryInfo[];
235
- lineIndices: number[];
236
- }
237
190
  interface TextOptions {
238
191
  text: string;
239
192
  font: string | ArrayBuffer;
@@ -310,14 +263,13 @@ declare class Text$1 {
310
263
  private fontLoader;
311
264
  private loadedFont?;
312
265
  private currentFontId;
313
- private geometryBuilder?;
314
266
  private textShaper?;
315
267
  private textLayout?;
316
268
  private constructor();
317
269
  static setHarfBuzzPath(path: string): void;
318
270
  static setHarfBuzzBuffer(wasmBuffer: ArrayBuffer): void;
319
271
  static init(): Promise<HarfBuzzInstance>;
320
- static create(options: TextOptions): Promise<TextHandle>;
272
+ static create(options: TextOptions): Promise<TextLayoutHandle>;
321
273
  private static resolveFont;
322
274
  private static loadAndCacheFont;
323
275
  private static trackFontCacheAdd;
@@ -326,23 +278,17 @@ declare class Text$1 {
326
278
  private static generateFontContentHash;
327
279
  private setLoadedFont;
328
280
  private loadFont;
329
- private createGeometry;
281
+ private createLayout;
330
282
  private prepareHyphenation;
331
283
  private validateOptions;
332
284
  private updateFontVariations;
333
285
  private prepareLayout;
334
- private applyColorSystem;
335
- private calculateGlyphBounds;
336
- private finalizeGeometry;
337
286
  getFontMetrics(): FontMetrics;
338
287
  static preloadPatterns(languages: string[], patternsPath?: string): Promise<void>;
339
288
  static registerPattern(language: string, pattern: HyphenationTrieNode): void;
340
289
  static setMaxFontCacheMemoryMB(limitMB: number): void;
341
290
  getLoadedFont(): LoadedFont | undefined;
342
291
  measureTextWidth(text: string, letterSpacing?: number): number;
343
- getCacheSize(): number;
344
- clearCache(): void;
345
- private createGlyphAttributes;
346
292
  private resetHelpers;
347
293
  destroy(): void;
348
294
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useState, useRef, useMemo, useEffect } from 'react';
2
+ import { useRef, forwardRef, useState, useMemo, useEffect } from 'react';
3
3
  import * as THREE from 'three';
4
4
  import { Text as Text$2 } from './index.js';
5
5
 
@@ -10,7 +10,6 @@ function deepEqual(a, b) {
10
10
  return false;
11
11
  if (typeof a !== 'object' || typeof b !== 'object')
12
12
  return false;
13
- // Arrays (common in options like color, byCharRange, etc.)
14
13
  if (Array.isArray(a) || Array.isArray(b)) {
15
14
  if (!Array.isArray(a) || !Array.isArray(b))
16
15
  return false;
@@ -29,11 +28,14 @@ function deepEqual(a, b) {
29
28
  for (const key of keysA) {
30
29
  if (!Object.prototype.hasOwnProperty.call(b, key))
31
30
  return false;
32
- if (!deepEqual(a[key], b[key]))
31
+ if (!deepEqual(a[key], b[key])) {
33
32
  return false;
33
+ }
34
34
  }
35
35
  return true;
36
36
  }
37
+ // Stabilizes an object reference across renders so long as
38
+ // its contents haven't changed (by deep comparison)
37
39
  function useDeepCompareMemo(value) {
38
40
  const ref = useRef(value);
39
41
  if (!deepEqual(value, ref.current)) {
@@ -41,6 +43,7 @@ function useDeepCompareMemo(value) {
41
43
  }
42
44
  return ref.current;
43
45
  }
46
+
44
47
  const Text$1 = forwardRef(function Text(props, ref) {
45
48
  const { children, font, material, position = [0, 0, 0], rotation = [0, 0, 0], scale = [1, 1, 1], onLoad, onError, vertexColors = true, ...restOptions } = props;
46
49
  const [geometry, setGeometry] = useState(null);
@@ -1,4 +1,4 @@
1
- import type { TextOptions, TextHandle, FontMetrics, LoadedFont, HarfBuzzInstance } from './types';
1
+ import type { TextOptions, TextLayoutHandle, FontMetrics, LoadedFont, HarfBuzzInstance } from './types';
2
2
  import type { HyphenationTrieNode } from '../hyphenation';
3
3
  declare global {
4
4
  interface Window {
@@ -18,14 +18,13 @@ export declare class Text {
18
18
  private fontLoader;
19
19
  private loadedFont?;
20
20
  private currentFontId;
21
- private geometryBuilder?;
22
21
  private textShaper?;
23
22
  private textLayout?;
24
23
  private constructor();
25
24
  static setHarfBuzzPath(path: string): void;
26
25
  static setHarfBuzzBuffer(wasmBuffer: ArrayBuffer): void;
27
26
  static init(): Promise<HarfBuzzInstance>;
28
- static create(options: TextOptions): Promise<TextHandle>;
27
+ static create(options: TextOptions): Promise<TextLayoutHandle>;
29
28
  private static resolveFont;
30
29
  private static loadAndCacheFont;
31
30
  private static trackFontCacheAdd;
@@ -34,23 +33,17 @@ export declare class Text {
34
33
  private static generateFontContentHash;
35
34
  private setLoadedFont;
36
35
  private loadFont;
37
- private createGeometry;
36
+ private createLayout;
38
37
  private prepareHyphenation;
39
38
  private validateOptions;
40
39
  private updateFontVariations;
41
40
  private prepareLayout;
42
- private applyColorSystem;
43
- private calculateGlyphBounds;
44
- private finalizeGeometry;
45
41
  getFontMetrics(): FontMetrics;
46
42
  static preloadPatterns(languages: string[], patternsPath?: string): Promise<void>;
47
43
  static registerPattern(language: string, pattern: HyphenationTrieNode): void;
48
44
  static setMaxFontCacheMemoryMB(limitMB: number): void;
49
45
  getLoadedFont(): LoadedFont | undefined;
50
46
  measureTextWidth(text: string, letterSpacing?: number): number;
51
- getCacheSize(): number;
52
- clearCache(): void;
53
- private createGlyphAttributes;
54
47
  private resetHelpers;
55
48
  destroy(): void;
56
49
  }
@@ -1,5 +1,5 @@
1
1
  import { Cache } from '../../utils/Cache';
2
- import type { GlyphData, GlyphContours } from '../types';
2
+ import type { GlyphData, GlyphContours, GlyphOutline } from '../types';
3
3
  export declare function getGlyphCacheKey(fontId: string, glyphId: number, depth: number, removeOverlaps: boolean): string;
4
4
  export declare const globalGlyphCache: Cache<string, GlyphData>;
5
5
  export declare function createGlyphCache(): Cache<string, GlyphData>;
@@ -13,3 +13,4 @@ export declare const globalClusteringCache: Cache<string, {
13
13
  }[];
14
14
  groups: number[][];
15
15
  }>;
16
+ export declare const globalOutlineCache: Cache<string, GlyphOutline>;
@@ -1,5 +1,13 @@
1
1
  import { LoadedFont } from '../types';
2
- import { GlyphContourCollector } from '../cache/GlyphContourCollector';
2
+ export interface GlyphDrawCollector {
3
+ setPosition(x: number, y: number): void;
4
+ updatePosition(dx: number, dy: number): void;
5
+ onMoveTo(x: number, y: number): void;
6
+ onLineTo(x: number, y: number): void;
7
+ onQuadTo(cx: number, cy: number, x: number, y: number): void;
8
+ onCubicTo(c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number): void;
9
+ onClosePath(): void;
10
+ }
3
11
  export declare class DrawCallbackHandler {
4
12
  private moveTo_func;
5
13
  private lineTo_func;
@@ -11,8 +19,8 @@ export declare class DrawCallbackHandler {
11
19
  private position;
12
20
  setPosition(x: number, y: number): void;
13
21
  updatePosition(dx: number, dy: number): void;
14
- setCollector(collector: GlyphContourCollector): void;
15
- createDrawFuncs(font: LoadedFont, collector: GlyphContourCollector): void;
22
+ setCollector(collector: GlyphDrawCollector): void;
23
+ createDrawFuncs(font: LoadedFont, collector: GlyphDrawCollector): void;
16
24
  getDrawFuncsPtr(): number;
17
25
  destroy(font: LoadedFont): void;
18
26
  }
@@ -1,5 +1,4 @@
1
1
  import { LoadedFont, GlyphGeometryInfo, LineInfo, TextDirection, GlyphCluster, ColorOptions } from '../types';
2
- import { GlyphGeometryBuilder } from '../cache/GlyphGeometryBuilder';
3
2
  export interface ShapedResult {
4
3
  geometry: any;
5
4
  glyphInfos: GlyphGeometryInfo[];
@@ -23,13 +22,10 @@ export interface ShapedResult {
23
22
  }
24
23
  export declare class TextShaper {
25
24
  private loadedFont;
26
- private geometryBuilder;
27
25
  private cachedSpaceWidth;
28
- constructor(loadedFont: LoadedFont, geometryBuilder: GlyphGeometryBuilder);
26
+ constructor(loadedFont: LoadedFont);
29
27
  shapeLines(lineInfos: LineInfo[], scaledLineHeight: number, letterSpacing: number, align: string, direction: TextDirection, color?: [number, number, number] | ColorOptions, originalText?: string): GlyphCluster[][];
30
28
  private shapeLineIntoClusters;
31
29
  private calculateSpaceAdjustment;
32
30
  private calculateCJKAdjustment;
33
- clearCache(): void;
34
- getCacheStats(): import("../..").CacheStats;
35
31
  }
@@ -266,6 +266,90 @@ export interface TextHandle extends TextGeometryInfo {
266
266
  measureTextWidth(text: string, letterSpacing?: number): number;
267
267
  update(options: Partial<TextOptions>): Promise<TextHandle>;
268
268
  }
269
+ export type OutlineSegmentType = 0 | 1 | 2;
270
+ export interface OutlineSegment {
271
+ type: OutlineSegmentType;
272
+ contourId: number;
273
+ p0: Vec2;
274
+ p1: Vec2;
275
+ p2?: Vec2;
276
+ p3?: Vec2;
277
+ }
278
+ export interface GlyphOutline {
279
+ glyphId: number;
280
+ textIndex: number;
281
+ segments: OutlineSegment[];
282
+ bounds: {
283
+ min: {
284
+ x: number;
285
+ y: number;
286
+ };
287
+ max: {
288
+ x: number;
289
+ y: number;
290
+ };
291
+ };
292
+ }
293
+ export interface VectorGlyphInfo extends GlyphGeometryInfo {
294
+ segmentStart: number;
295
+ segmentCount: number;
296
+ }
297
+ export interface PackedFloatTexture {
298
+ width: number;
299
+ height: number;
300
+ data: Float32Array;
301
+ }
302
+ export interface VectorTextGeometryInfo {
303
+ quadVertices: Float32Array;
304
+ quadIndices: Uint16Array;
305
+ instances: {
306
+ position: Float32Array;
307
+ bounds: Float32Array;
308
+ segmentRange: Uint32Array;
309
+ glyphDataIndex: Uint32Array;
310
+ glyphIndex: Uint32Array;
311
+ textIndex: Uint32Array;
312
+ lineIndex: Uint32Array;
313
+ };
314
+ segmentTexelsPerSegment: number;
315
+ segments: PackedFloatTexture;
316
+ segmentBounds?: PackedFloatTexture;
317
+ bandCount?: number;
318
+ bandRanges?: PackedFloatTexture;
319
+ bandIndices?: PackedFloatTexture;
320
+ xBandCount?: number;
321
+ xBandRanges?: PackedFloatTexture;
322
+ xBandIndices?: PackedFloatTexture;
323
+ tileCountX?: number;
324
+ tileCountY?: number;
325
+ tileRanges?: PackedFloatTexture;
326
+ tileIndices?: PackedFloatTexture;
327
+ glyphs: VectorGlyphInfo[];
328
+ planeBounds: BoundingBox;
329
+ }
330
+ export interface TextLayoutData {
331
+ lines: LineInfo[];
332
+ scaledLineHeight: number;
333
+ letterSpacing: number;
334
+ align: string;
335
+ direction: TextDirection;
336
+ depth: number;
337
+ size: number;
338
+ pixelsPerFontUnit: number;
339
+ }
340
+ export interface TextLayoutResult {
341
+ clustersByLine: GlyphCluster[][];
342
+ layoutData: TextLayoutData;
343
+ options: TextOptions;
344
+ loadedFont: LoadedFont;
345
+ fontId: string;
346
+ }
347
+ export interface TextLayoutHandle extends TextLayoutResult {
348
+ getLoadedFont(): LoadedFont | undefined;
349
+ measureTextWidth(text: string, letterSpacing?: number): number;
350
+ update(options: Partial<TextOptions>): Promise<TextLayoutHandle>;
351
+ dispose(): void;
352
+ }
269
353
  export interface ColorByRange {
270
354
  start: number;
271
355
  end: number;
@@ -1,7 +1,11 @@
1
1
  export { Text } from './core/Text';
2
- export { DEFAULT_CURVE_FIDELITY } from './core/geometry/Polygonizer';
2
+ export { MeshGeometryBuilder } from './mesh/MeshGeometryBuilder';
3
+ export { DEFAULT_CURVE_FIDELITY } from './mesh/geometry/Polygonizer';
3
4
  export { FontMetadataExtractor } from './core/font/FontMetadata';
4
- export { globalGlyphCache, createGlyphCache } from './core/cache/sharedCaches';
5
+ export { globalGlyphCache, createGlyphCache, globalOutlineCache } from './core/cache/sharedCaches';
6
+ export { DrawCallbackHandler, getSharedDrawCallbackHandler } from './core/shaping/DrawCallbacks';
7
+ export type { GlyphDrawCollector } from './core/shaping/DrawCallbacks';
8
+ export { TextRangeQuery } from './core/layout/TextRangeQuery';
5
9
  export type { CacheStats } from './utils/Cache';
6
- export type { TextAlign, TextDirection, LineInfo, LoadedFont, HarfBuzzModule, HarfBuzzAPI, HarfBuzzBlob, HarfBuzzFace, HarfBuzzFont, HarfBuzzBuffer, HarfBuzzInstance, VariationAxis, ExtractedMetrics, VerticalMetrics, FontMetrics, ProcessedGeometry, Triangles, GlyphData, GlyphGeometryInfo, TextGeometryInfo, TextHandle, TextOptions, ColorOptions, ColorByRange, ColoredRange, PathInfo, HyphenationPatternsMap, CurveFidelityConfig, LayoutOptions, GeometryOptimizationOptions, TextRange, TextQueryOptions } from './core/types';
10
+ export type { TextAlign, TextDirection, LineInfo, LoadedFont, HarfBuzzModule, HarfBuzzAPI, HarfBuzzBlob, HarfBuzzFace, HarfBuzzFont, HarfBuzzBuffer, HarfBuzzInstance, VariationAxis, ExtractedMetrics, VerticalMetrics, FontMetrics, ProcessedGeometry, Triangles, GlyphData, GlyphGeometryInfo, GlyphCluster, TextGeometryInfo, TextHandle, TextLayoutData, TextLayoutResult, TextLayoutHandle, TextOptions, ColorOptions, ColorByRange, ColoredRange, PathInfo, HyphenationPatternsMap, CurveFidelityConfig, LayoutOptions, GeometryOptimizationOptions, TextRange, TextQueryOptions } from './core/types';
7
11
  export type { HyphenationTrieNode } from './hyphenation';
@@ -1,7 +1,7 @@
1
- import { Vec2 } from '../../utils/vectors';
2
- import { GlyphContours } from '../types';
3
- import { OptimizationStats } from '../geometry/PathOptimizer';
4
- import { CurveFidelityConfig, GeometryOptimizationOptions } from '../types';
1
+ import { Vec2 } from '../utils/vectors';
2
+ import { GlyphContours } from '../core/types';
3
+ import { OptimizationStats } from './geometry/PathOptimizer';
4
+ import { CurveFidelityConfig, GeometryOptimizationOptions } from '../core/types';
5
5
  export declare class GlyphContourCollector {
6
6
  private currentGlyphId;
7
7
  private currentTextIndex;
@@ -1,6 +1,6 @@
1
- import { GlyphGeometryInfo, LoadedFont, GlyphCluster, GlyphData } from '../types';
2
- import { CurveFidelityConfig, GeometryOptimizationOptions } from '../types';
3
- import { Cache } from '../../utils/Cache';
1
+ import { GlyphGeometryInfo, LoadedFont, GlyphCluster, GlyphData } from '../core/types';
2
+ import { CurveFidelityConfig, GeometryOptimizationOptions } from '../core/types';
3
+ import { Cache } from '../utils/Cache';
4
4
  export interface InstancedTextGeometry {
5
5
  vertices: Float32Array;
6
6
  normals: Float32Array;
@@ -40,7 +40,7 @@ export declare class GlyphGeometryBuilder {
40
40
  private clusterContoursScratch;
41
41
  private taskScratch;
42
42
  constructor(cache: Cache<string, GlyphData>, loadedFont: LoadedFont);
43
- getOptimizationStats(): import("../geometry/PathOptimizer").OptimizationStats;
43
+ getOptimizationStats(): import("./geometry/PathOptimizer").OptimizationStats;
44
44
  setCurveFidelityConfig(config?: CurveFidelityConfig): void;
45
45
  setCurveSteps(curveSteps?: number): void;
46
46
  setGeometryOptimization(options?: GeometryOptimizationOptions): void;
@@ -55,6 +55,6 @@ export declare class GlyphGeometryBuilder {
55
55
  private extrudeAndPackage;
56
56
  private tessellateGlyph;
57
57
  private updatePlaneBounds;
58
- getCacheStats(): import("../../utils/Cache").CacheStats;
58
+ getCacheStats(): import("../utils/Cache").CacheStats;
59
59
  clearCache(): void;
60
60
  }
@@ -0,0 +1,18 @@
1
+ import type { TextOptions, TextGeometryInfo, TextLayoutResult } from '../core/types';
2
+ import type { LoadedFont } from '../core/types';
3
+ export declare class MeshGeometryBuilder {
4
+ private geometryBuilder?;
5
+ private textLayout?;
6
+ private loadedFont;
7
+ private fontId;
8
+ constructor(loadedFont: LoadedFont, fontId: string);
9
+ setFont(loadedFont: LoadedFont, fontId: string): void;
10
+ build(layout: TextLayoutResult, options: TextOptions): TextGeometryInfo;
11
+ getCacheSize(): number;
12
+ clearCache(): void;
13
+ reset(): void;
14
+ private finalizeGeometry;
15
+ private applyColorSystem;
16
+ private calculateGlyphBounds;
17
+ private createGlyphAttributes;
18
+ }
@@ -1,5 +1,5 @@
1
1
  import { Vec3 } from '../../utils/vectors';
2
- import type { GlyphContours } from '../types';
2
+ import type { GlyphContours } from '../../core/types';
3
3
  export declare class BoundaryClusterer {
4
4
  constructor();
5
5
  cluster(glyphContoursList: GlyphContours[], positions: Vec3[]): number[][];
@@ -1,4 +1,4 @@
1
- import type { ProcessedGeometry } from '../types';
1
+ import type { ProcessedGeometry } from '../../core/types';
2
2
  export interface ExtrusionResult {
3
3
  vertices: Float32Array;
4
4
  normals: Float32Array;
@@ -1,4 +1,4 @@
1
- import type { Path } from '../types';
1
+ import type { Path } from '../../core/types';
2
2
  export interface OptimizationConfig {
3
3
  enabled: boolean;
4
4
  areaThreshold: number;
@@ -36,7 +36,7 @@
36
36
  * POSSIBILITY OF SUCH DAMAGE.
37
37
  */
38
38
  import { Vec2 } from '../../utils/vectors';
39
- import { CurveFidelityConfig } from '../types';
39
+ import { CurveFidelityConfig } from '../../core/types';
40
40
  export declare const DEFAULT_CURVE_FIDELITY: CurveFidelityConfig;
41
41
  export declare const COLLINEARITY_EPSILON: number;
42
42
  export declare class Polygonizer {
@@ -1,4 +1,4 @@
1
- import type { Path, ProcessedGeometry } from '../types';
1
+ import type { Path, ProcessedGeometry } from '../../core/types';
2
2
  export declare class Tessellator {
3
3
  process(paths: Path[], removeOverlaps?: boolean, isCFF?: boolean, needsExtrusionContours?: boolean): ProcessedGeometry;
4
4
  processContours(contours: number[][], removeOverlaps?: boolean, isCFF?: boolean, needsExtrusionContours?: boolean): ProcessedGeometry;
@@ -0,0 +1,2 @@
1
+ export declare function deepEqual(a: unknown, b: unknown): boolean;
2
+ export declare function useDeepCompareMemo<T>(value: T): T;
@@ -0,0 +1,25 @@
1
+ import type { GlyphOutline } from '../core/types';
2
+ export declare class GlyphOutlineCollector {
3
+ private currentGlyphId;
4
+ private currentTextIndex;
5
+ private inGlyph;
6
+ private currentSegments;
7
+ private currentPoint;
8
+ private contourStartPoint;
9
+ private contourId;
10
+ private currentGlyphBounds;
11
+ private collectedGlyphs;
12
+ private currentPosition;
13
+ setPosition(x: number, y: number): void;
14
+ updatePosition(dx: number, dy: number): void;
15
+ beginGlyph(glyphId: number, textIndex: number): void;
16
+ finishGlyph(): void;
17
+ onMoveTo(x: number, y: number): void;
18
+ onLineTo(x: number, y: number): void;
19
+ onQuadTo(cx: number, cy: number, x: number, y: number): void;
20
+ onCubicTo(c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number): void;
21
+ onClosePath(): void;
22
+ getCollectedGlyphs(): GlyphOutline[];
23
+ reset(): void;
24
+ private updateBounds;
25
+ }
@@ -0,0 +1,26 @@
1
+ import type { GlyphCluster, LoadedFont, GlyphOutline, VectorGlyphInfo, VectorTextGeometryInfo } from '../core/types';
2
+ import { Cache } from '../utils/Cache';
3
+ import type { LoopBlinnInput } from './LoopBlinnGeometry';
4
+ export declare class GlyphVectorGeometryBuilder {
5
+ private outlineCache;
6
+ private drawCallbacks;
7
+ private collector;
8
+ private loadedFont;
9
+ private fontId;
10
+ private cacheKeyPrefix;
11
+ private emptyGlyphs;
12
+ constructor(loadedFont: LoadedFont, cache?: Cache<string, GlyphOutline>);
13
+ setFontId(fontId: string): void;
14
+ clearCache(): void;
15
+ getCacheStats(): import("../utils/Cache").CacheStats;
16
+ private collectUniqueGlyphIds;
17
+ private computePlaneBounds;
18
+ buildForLoopBlinn(clustersByLine: GlyphCluster[][], scale: number): {
19
+ loopBlinnInput: LoopBlinnInput;
20
+ glyphs: VectorGlyphInfo[];
21
+ };
22
+ private getOutlineForGlyph;
23
+ private writeSegmentToTexture;
24
+ private segmentAABB;
25
+ buildVectorGeometry(clustersByLine: GlyphCluster[][], scale: number, segmentTextureWidth?: number, bandCount?: number, tileCountX?: number, tileCountY?: number): Omit<VectorTextGeometryInfo, 'query'>;
26
+ }