Skip to content

Commit 259e03d

Browse files
committed
add an API to use smoother curves for the text extrude
1 parent 572bec7 commit 259e03d

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
@SuppressWarnings("restriction")
3535
public class TextExtrude {
36+
private static int TextResolutionPoints = 10;
3637
private static final String default_font = "FreeSerif";
3738
private final static int POINTS_CURVE = 10;
3839
private static final double CURVE_SEGMENTS = 4; // Number of segments to approximate curves
@@ -242,7 +243,7 @@ private static List<List<Vector3d>> extractRawOutlines(Path textPath) {
242243
if (element instanceof MoveTo) {
243244
// If we have a current path, process it with BezierPath
244245
if (pathBuilder.length() > 0) {
245-
BezierPath bezierPath = new BezierPath(5);
246+
BezierPath bezierPath = new BezierPath(getTextResolutionPoints());
246247
bezierPath.parsePathString(pathBuilder.toString());
247248
List<Vector3d> pathPoints = bezierPath.evaluate();
248249
if (!pathPoints.isEmpty()) {
@@ -284,4 +285,12 @@ private static List<List<Vector3d>> extractRawOutlines(Path textPath) {
284285
return allOutlines;
285286
}
286287

288+
public static int getTextResolutionPoints() {
289+
return TextResolutionPoints;
290+
}
291+
292+
public static void setTextResolutionPoints(int textResolutionPoints) {
293+
TextResolutionPoints = textResolutionPoints;
294+
}
295+
287296
}

src/main/java/eu/mihosoft/vrl/v3d/svg/SVGLoad.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import eu.mihosoft.vrl.v3d.Edge;
4242
import eu.mihosoft.vrl.v3d.Extrude;
4343
import eu.mihosoft.vrl.v3d.Polygon;
44+
import eu.mihosoft.vrl.v3d.TextExtrude;
4445
import eu.mihosoft.vrl.v3d.Transform;
4546
import eu.mihosoft.vrl.v3d.Vector3d;
4647
import eu.mihosoft.vrl.v3d.ext.org.poly2tri.PolygonUtil;
@@ -646,7 +647,7 @@ private void loadSingle(String code, Transform startingFrame, String encapsulati
646647
if (encapsulatingLayer == null)
647648
throw new RuntimeException("Layer Name can not be null");
648649
// println code
649-
BezierPath path = new BezierPath(5);
650+
BezierPath path = new BezierPath(TextExtrude.getTextResolutionPoints());
650651
path.parsePathString(code);
651652

652653
ArrayList<Vector3d> p = path.evaluate();

0 commit comments

Comments
 (0)