Skip to content

Commit 7493e61

Browse files
authored
Convert int text sizes to floats (#764)
Avoids a segfault when using integer text sizes. Also adds a test for integer text size.
1 parent 85663cb commit 7493e61

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,9 @@ def makeText(
30503050

30513051
builder = Font_BRepTextBuilder()
30523052
font_i = StdPrs_BRepFont(
3053-
NCollection_Utf8String(font_t.FontName().ToCString()), font_kind, size
3053+
NCollection_Utf8String(font_t.FontName().ToCString()),
3054+
font_kind,
3055+
float(size),
30543056
)
30553057
text_flat = Shape(builder.Perform(font_i, NCollection_Utf8String(text)))
30563058

tests/test_cadquery.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,6 +3293,15 @@ def testText(self):
32933293
# verify that the number of solids is correct
32943294
self.assertEqual(len(obj5.solids().vals()), 5)
32953295

3296+
# check it doesn't fall over with int sizes
3297+
obj1 = (
3298+
box.faces(">Z")
3299+
.workplane()
3300+
.text(
3301+
"CQ 2.0", 10, -1, cut=True, halign="left", valign="bottom", font="Sans",
3302+
)
3303+
)
3304+
32963305
def testParametricCurve(self):
32973306

32983307
from math import sin, cos, pi

0 commit comments

Comments
 (0)