three-text 0.4.3 → 0.4.4
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/dist/index.cjs +33 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -5
- package/dist/index.min.cjs +288 -285
- package/dist/index.min.js +379 -376
- package/dist/index.umd.js +33 -5
- package/dist/index.umd.min.js +264 -261
- package/dist/types/core/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.4.
|
|
2
|
+
* three-text v0.4.4
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -557,6 +557,31 @@ class LineBreak {
|
|
|
557
557
|
currentIndex += token.length;
|
|
558
558
|
}
|
|
559
559
|
else {
|
|
560
|
+
if (lineWidth && token.includes('-') && !token.includes('\u00AD')) {
|
|
561
|
+
const tokenWidth = measureText(token);
|
|
562
|
+
if (tokenWidth > lineWidth) {
|
|
563
|
+
// Break long hyphenated tokens into characters (break-all behavior)
|
|
564
|
+
const chars = Array.from(token);
|
|
565
|
+
for (let i = 0; i < chars.length; i++) {
|
|
566
|
+
items.push({
|
|
567
|
+
type: ItemType.BOX,
|
|
568
|
+
width: measureText(chars[i]),
|
|
569
|
+
text: chars[i],
|
|
570
|
+
originIndex: tokenStartIndex + i
|
|
571
|
+
});
|
|
572
|
+
if (i < chars.length - 1) {
|
|
573
|
+
items.push({
|
|
574
|
+
type: ItemType.PENALTY,
|
|
575
|
+
width: 0,
|
|
576
|
+
penalty: 5000,
|
|
577
|
+
originIndex: tokenStartIndex + i + 1
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
currentIndex += token.length;
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
560
585
|
const segments = token.split(/(-)/);
|
|
561
586
|
let segmentIndex = tokenStartIndex;
|
|
562
587
|
for (const segment of segments) {
|
|
@@ -2569,7 +2594,8 @@ class Tessellator {
|
|
|
2569
2594
|
vertices: triangleResult.vertices,
|
|
2570
2595
|
indices: triangleResult.indices || []
|
|
2571
2596
|
},
|
|
2572
|
-
contours: extrusionContours
|
|
2597
|
+
contours: extrusionContours,
|
|
2598
|
+
contoursAreBoundary: removeOverlaps
|
|
2573
2599
|
};
|
|
2574
2600
|
}
|
|
2575
2601
|
tessellateContours(contours, removeOverlaps, isCFF, needsExtrusionContours) {
|
|
@@ -2631,7 +2657,8 @@ class Tessellator {
|
|
|
2631
2657
|
vertices: triangleResult.vertices,
|
|
2632
2658
|
indices: triangleResult.indices || []
|
|
2633
2659
|
},
|
|
2634
|
-
contours: extrusionContours
|
|
2660
|
+
contours: extrusionContours,
|
|
2661
|
+
contoursAreBoundary: removeOverlaps
|
|
2635
2662
|
};
|
|
2636
2663
|
}
|
|
2637
2664
|
pathsToContours(paths, reversePoints = false) {
|
|
@@ -2827,14 +2854,15 @@ class Extruder {
|
|
|
2827
2854
|
const points = geometry.triangles.vertices;
|
|
2828
2855
|
const triangleIndices = geometry.triangles.indices;
|
|
2829
2856
|
const contours = geometry.contours;
|
|
2857
|
+
const contoursAreBoundary = geometry.contoursAreBoundary === true;
|
|
2830
2858
|
const pointLen = points.length;
|
|
2831
2859
|
const numPoints = pointLen / 2;
|
|
2832
|
-
//
|
|
2860
|
+
// Use boundary contours for side walls when available
|
|
2833
2861
|
let boundaryEdges = [];
|
|
2834
2862
|
let sideEdgeCount = 0;
|
|
2835
2863
|
let useContours = false;
|
|
2836
2864
|
if (depth !== 0) {
|
|
2837
|
-
if (contours.length > 0) {
|
|
2865
|
+
if (contoursAreBoundary && contours.length > 0) {
|
|
2838
2866
|
useContours = true;
|
|
2839
2867
|
for (const contour of contours) {
|
|
2840
2868
|
const contourPointCount = contour.length >> 1;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.4.
|
|
2
|
+
* three-text v0.4.4
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -554,6 +554,31 @@ class LineBreak {
|
|
|
554
554
|
currentIndex += token.length;
|
|
555
555
|
}
|
|
556
556
|
else {
|
|
557
|
+
if (lineWidth && token.includes('-') && !token.includes('\u00AD')) {
|
|
558
|
+
const tokenWidth = measureText(token);
|
|
559
|
+
if (tokenWidth > lineWidth) {
|
|
560
|
+
// Break long hyphenated tokens into characters (break-all behavior)
|
|
561
|
+
const chars = Array.from(token);
|
|
562
|
+
for (let i = 0; i < chars.length; i++) {
|
|
563
|
+
items.push({
|
|
564
|
+
type: ItemType.BOX,
|
|
565
|
+
width: measureText(chars[i]),
|
|
566
|
+
text: chars[i],
|
|
567
|
+
originIndex: tokenStartIndex + i
|
|
568
|
+
});
|
|
569
|
+
if (i < chars.length - 1) {
|
|
570
|
+
items.push({
|
|
571
|
+
type: ItemType.PENALTY,
|
|
572
|
+
width: 0,
|
|
573
|
+
penalty: 5000,
|
|
574
|
+
originIndex: tokenStartIndex + i + 1
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
currentIndex += token.length;
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
557
582
|
const segments = token.split(/(-)/);
|
|
558
583
|
let segmentIndex = tokenStartIndex;
|
|
559
584
|
for (const segment of segments) {
|
|
@@ -2566,7 +2591,8 @@ class Tessellator {
|
|
|
2566
2591
|
vertices: triangleResult.vertices,
|
|
2567
2592
|
indices: triangleResult.indices || []
|
|
2568
2593
|
},
|
|
2569
|
-
contours: extrusionContours
|
|
2594
|
+
contours: extrusionContours,
|
|
2595
|
+
contoursAreBoundary: removeOverlaps
|
|
2570
2596
|
};
|
|
2571
2597
|
}
|
|
2572
2598
|
tessellateContours(contours, removeOverlaps, isCFF, needsExtrusionContours) {
|
|
@@ -2628,7 +2654,8 @@ class Tessellator {
|
|
|
2628
2654
|
vertices: triangleResult.vertices,
|
|
2629
2655
|
indices: triangleResult.indices || []
|
|
2630
2656
|
},
|
|
2631
|
-
contours: extrusionContours
|
|
2657
|
+
contours: extrusionContours,
|
|
2658
|
+
contoursAreBoundary: removeOverlaps
|
|
2632
2659
|
};
|
|
2633
2660
|
}
|
|
2634
2661
|
pathsToContours(paths, reversePoints = false) {
|
|
@@ -2824,14 +2851,15 @@ class Extruder {
|
|
|
2824
2851
|
const points = geometry.triangles.vertices;
|
|
2825
2852
|
const triangleIndices = geometry.triangles.indices;
|
|
2826
2853
|
const contours = geometry.contours;
|
|
2854
|
+
const contoursAreBoundary = geometry.contoursAreBoundary === true;
|
|
2827
2855
|
const pointLen = points.length;
|
|
2828
2856
|
const numPoints = pointLen / 2;
|
|
2829
|
-
//
|
|
2857
|
+
// Use boundary contours for side walls when available
|
|
2830
2858
|
let boundaryEdges = [];
|
|
2831
2859
|
let sideEdgeCount = 0;
|
|
2832
2860
|
let useContours = false;
|
|
2833
2861
|
if (depth !== 0) {
|
|
2834
|
-
if (contours.length > 0) {
|
|
2862
|
+
if (contoursAreBoundary && contours.length > 0) {
|
|
2835
2863
|
useContours = true;
|
|
2836
2864
|
for (const contour of contours) {
|
|
2837
2865
|
const contourPointCount = contour.length >> 1;
|