OpenSCAD: Handle missing script element from text()

This commit is contained in:
Chris Hennes
2021-12-18 16:23:25 -06:00
parent d88165c284
commit 0b50daec4d
2 changed files with 17 additions and 2 deletions

View File

@@ -128,7 +128,19 @@ class TestImportCSG(unittest.TestCase):
self.assertTrue (text is not None)
FreeCAD.closeDocument(doc.Name)
except Exception:
pass # We may not have the DXF importer available
return # We may not have the DXF importer available
# Try a number with a set script:
doc = self.utility_create_scad("text(\"2\",script=\"latin\");","two_text")
text = doc.getObject("text")
self.assertTrue (text is not None)
FreeCAD.closeDocument(doc.Name)
# Leave off the script (which is supposed to default to "latin")
doc = self.utility_create_scad("text(\"1\");","one_text")
text = doc.getObject("text")
self.assertTrue (text is not None)
FreeCAD.closeDocument(doc.Name)
def test_import_polygon_nopath(self):
doc = self.utility_create_scad("polygon(points=[[0,0],[100,0],[130,50],[30,50]]);","polygon_nopath")

View File

@@ -1204,7 +1204,10 @@ def p_text_action(p) :
t = addString(t,'font',p)
t = addString(t,'direction',p)
t = addString(t,'language',p)
t = addString(t,'script',p)
if "script" in p[3]:
t = addString(t,'script',p)
else:
t += ', script="latin"'
t = addString(t,'halign',p)
t = addString(t,'valign',p)
t = addValue(t,'$fn',p)