From 288081ddf00799921ef20c93f1cb68453cc8e73c Mon Sep 17 00:00:00 2001 From: Nicolas Predella Date: Thu, 30 Jul 2026 15:11:27 +0300 Subject: [PATCH] pt to mm --- core/nodeslicer/nodes/output.py | 4 ++-- core/pdf_exporter/writer.py | 8 +++++--- tests/test_pdf_exporter.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/nodeslicer/nodes/output.py b/core/nodeslicer/nodes/output.py index 40d990c..c196b48 100644 --- a/core/nodeslicer/nodes/output.py +++ b/core/nodeslicer/nodes/output.py @@ -373,7 +373,7 @@ class SLICENODE_MeshToPdf(ExecSliceNode): show_bbox_size: NfBoolProperty(name="Bounding Box Sizes", default=False) # pyright: ignore[reportInvalidTypeForm] line_width: NfFloatProperty(name="Line Width (mm)", default=0.0, min=0.0, max=50.0) # pyright: ignore[reportInvalidTypeForm] - font_size: NfFloatProperty(name="Font Size (pt)", default=0.0, min=0.0, max=100.0) # pyright: ignore[reportInvalidTypeForm] + font_size: NfFloatProperty(name="Font Size (mm)", default=0.0, min=0.0, max=100.0) # pyright: ignore[reportInvalidTypeForm] margin: NfFloatProperty(name="Margin (mm)", default=10.0, min=0.0, max=500.0) # pyright: ignore[reportInvalidTypeForm] bg_color: NfFloatVectorProperty( @@ -508,7 +508,7 @@ class SLICENODE_MeshToPdf(ExecSliceNode): crease_angle=self.crease_angle, margin_mm=self.margin, line_width_mm=self.line_width, - font_size_pt=self.font_size, + font_size_mm=self.font_size * 2.834645669291339, stroke_color=(float(self.wire_color[0]), float(self.wire_color[1]), float(self.wire_color[2])), bg_color=(float(self.bg_color[0]), float(self.bg_color[1]), float(self.bg_color[2])), bbox_color=(float(self.bbox_color[0]), float(self.bbox_color[1]), float(self.bbox_color[2])), diff --git a/core/pdf_exporter/writer.py b/core/pdf_exporter/writer.py index 10e08fe..b13e0a4 100644 --- a/core/pdf_exporter/writer.py +++ b/core/pdf_exporter/writer.py @@ -81,7 +81,7 @@ def export_mesh_to_pdf( crease_angle: float = 30.0, margin_mm: float = 10.0, line_width_mm: float = 0.5, - font_size_pt: float | None = None, + font_size_mm: float = 0.0, stroke_color: tuple[float, float, float] = (0.0, 0.0, 0.0), bg_color: tuple[float, float, float] = (1.0, 1.0, 1.0), bbox_color: tuple[float, float, float] = (0.0, 0.0, 1.0), @@ -211,9 +211,11 @@ def export_mesh_to_pdf( else: line_width_pt = line_width_mm * MM_TO_PT - # Automatic font size: equal to minor grid spacing - if font_size_pt is None or font_size_pt <= 0: + # Convert font_size_mm to pt and apply multiplier + if font_size_mm <= 0: font_size_pt = minor_step * MM_TO_PT + else: + font_size_pt = font_size_mm * MM_TO_PT def to_pdf_pt(pt_mm: NDArray[np.float64]) -> NDArray[np.float64]: x_pt = (pt_mm[:, 0] - grid_min_x + total_margin_mm) * MM_TO_PT diff --git a/tests/test_pdf_exporter.py b/tests/test_pdf_exporter.py index ee20355..04508d4 100644 --- a/tests/test_pdf_exporter.py +++ b/tests/test_pdf_exporter.py @@ -677,7 +677,7 @@ class TestPdfExporter(unittest.TestCase): export_mesh_to_pdf( edges_2d, pdf_path, - font_size_pt=14.5, + font_size_mm=5.12, show_name=True, raw_geometry=so )