Skip to content

Commit

Permalink
OpenSCAD: Handle missing script element from text()
Browse files Browse the repository at this point in the history
  • Loading branch information
chennes committed Dec 18, 2021
1 parent d88165c commit 0b50dae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py
Expand Up @@ -128,7 +128,19 @@ def test_import_text(self):
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")
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/OpenSCAD/importCSG.py
Expand Up @@ -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)
Expand Down

0 comments on commit 0b50dae

Please sign in to comment.