three-text 0.2.9 → 0.2.11

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/README.md CHANGED
@@ -396,7 +396,7 @@ The Knuth-Plass algorithm provides extensive control over line breaking quality:
396
396
  - **emergencyStretch** (0): Additional stretchability for difficult paragraphs
397
397
  - **autoEmergencyStretch** (0.1): Emergency stretch as percentage of line width (e.g., 0.1 = 10%). Defaults to 10% for non-hyphenated text
398
398
  - **disableShortLineDetection** (false): Disable automatic prevention of short lines
399
- - **shortLineThreshold** (0.5): Width ratio threshold for short line detection (0.0 to 1.0)
399
+ - **shortLineThreshold** (0.7): Width ratio threshold for short line detection (0.0 to 1.0)
400
400
 
401
401
  #### Advanced parameters
402
402
 
@@ -419,7 +419,7 @@ Lower penalty/tolerance values produce tighter spacing but may fail to find acce
419
419
 
420
420
  #### Short line detection
421
421
 
422
- By default, the library detects and prevents short lines (lines occupying less than 50% of the target width on non-final lines) by iteratively applying emergency stretch. This can be customized or disabled:
422
+ By default, the library detects and prevents short lines (lines occupying less than 70% of the target width on non-final lines) by iteratively applying emergency stretch. This can be customized or disabled:
423
423
 
424
424
  ```javascript
425
425
  const text = await Text.create({
@@ -701,7 +701,9 @@ mesh.geometry.dispose();
701
701
  mesh.geometry = updated.geometry;
702
702
  ```
703
703
 
704
- The method preserves custom cache instances if `maxCacheSizeMB` was specified. For most use cases, this is primarily an API convenience.
704
+ The method preserves custom cache instances if `maxCacheSizeMB` was specified. For most use cases, this is primarily an API convenience
705
+
706
+ Options merge at the top level - to remove a nested property like `layout.width`, pass `{ layout: { width: undefined } }`
705
707
 
706
708
  ##### `Text.setHarfBuzzPath(path: string): void`
707
709
 
@@ -781,7 +783,7 @@ interface LayoutOptions {
781
783
  emergencyStretch?: number; // Additional stretchability for difficult paragraphs
782
784
  autoEmergencyStretch?: number; // Emergency stretch as percentage of line width (defaults to 10% for non-hyphenated)
783
785
  disableShortLineDetection?: boolean; // Disable automatic short line prevention (default: false)
784
- shortLineThreshold?: number; // Width ratio threshold for short line detection (default: 0.5)
786
+ shortLineThreshold?: number; // Width ratio threshold for short line detection (default: 0.7)
785
787
  lefthyphenmin?: number; // Minimum characters before hyphen (default: 2)
786
788
  righthyphenmin?: number; // Minimum characters after hyphen (default: 4)
787
789
  linepenalty?: number; // Base penalty per line (default: 10)
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.9
2
+ * three-text v0.2.11
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -155,7 +155,7 @@ const perfLogger = new PerformanceLogger();
155
155
  // TeX defaults
156
156
  const FITNESS_TIGHT_THRESHOLD = 12; // if badness > 12 when shrinking -> tight_fit
157
157
  const FITNESS_NORMAL_THRESHOLD = 99; // if badness > 99 when stretching -> loose_fit
158
- const DEFAULT_TOLERANCE = 200;
158
+ const DEFAULT_TOLERANCE = 800;
159
159
  const DEFAULT_PRETOLERANCE = 100;
160
160
  const DEFAULT_EMERGENCY_STRETCH = 0;
161
161
  // In TeX, interword spacing is defined by font parameters (fontdimen):
@@ -258,7 +258,7 @@ const INF_BAD = 10000;
258
258
  // Non TeX default: emergency stretch for non-hyphenated text (10% of line width)
259
259
  const DEFAULT_EMERGENCY_STRETCH_NO_HYPHEN = 0.1;
260
260
  // Another non TeX default: Short line detection thresholds
261
- const SHORT_LINE_WIDTH_THRESHOLD = 0.5; // Lines < 50% of width are problematic
261
+ const SHORT_LINE_WIDTH_THRESHOLD = 0.7; // Lines < 70% of width are problematic
262
262
  const SHORT_LINE_EMERGENCY_STRETCH_INCREMENT = 0.1; // Add 10% per iteration
263
263
  class LineBreak {
264
264
  // Calculate badness according to TeX's formula (tex.web line 2337)
@@ -1006,6 +1006,7 @@ class LineBreak {
1006
1006
  // Artificial demerits: in final pass with no feasible solution yet
1007
1007
  // and only one active node left, force this break as a last resort
1008
1008
  const isLastResort = isFinalPass &&
1009
+ isForcedBreak &&
1009
1010
  minimumDemerits.value === Infinity &&
1010
1011
  allActiveNodes.length === 1 &&
1011
1012
  node.active;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.9
2
+ * three-text v0.2.11
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -152,7 +152,7 @@ const perfLogger = new PerformanceLogger();
152
152
  // TeX defaults
153
153
  const FITNESS_TIGHT_THRESHOLD = 12; // if badness > 12 when shrinking -> tight_fit
154
154
  const FITNESS_NORMAL_THRESHOLD = 99; // if badness > 99 when stretching -> loose_fit
155
- const DEFAULT_TOLERANCE = 200;
155
+ const DEFAULT_TOLERANCE = 800;
156
156
  const DEFAULT_PRETOLERANCE = 100;
157
157
  const DEFAULT_EMERGENCY_STRETCH = 0;
158
158
  // In TeX, interword spacing is defined by font parameters (fontdimen):
@@ -255,7 +255,7 @@ const INF_BAD = 10000;
255
255
  // Non TeX default: emergency stretch for non-hyphenated text (10% of line width)
256
256
  const DEFAULT_EMERGENCY_STRETCH_NO_HYPHEN = 0.1;
257
257
  // Another non TeX default: Short line detection thresholds
258
- const SHORT_LINE_WIDTH_THRESHOLD = 0.5; // Lines < 50% of width are problematic
258
+ const SHORT_LINE_WIDTH_THRESHOLD = 0.7; // Lines < 70% of width are problematic
259
259
  const SHORT_LINE_EMERGENCY_STRETCH_INCREMENT = 0.1; // Add 10% per iteration
260
260
  class LineBreak {
261
261
  // Calculate badness according to TeX's formula (tex.web line 2337)
@@ -1003,6 +1003,7 @@ class LineBreak {
1003
1003
  // Artificial demerits: in final pass with no feasible solution yet
1004
1004
  // and only one active node left, force this break as a last resort
1005
1005
  const isLastResort = isFinalPass &&
1006
+ isForcedBreak &&
1006
1007
  minimumDemerits.value === Infinity &&
1007
1008
  allActiveNodes.length === 1 &&
1008
1009
  node.active;