Open AeroSteveO opened 1 month ago
for those struggling like me, the quote() function in keycap.py is to blame:
def quote(self, legends):
"""
Checks for the edge case of a single quote (') legend and converts it
into `"'"'"'"` so that bash will pass it correclty to OpenSCAD via
`getstatusoutput()`. Also covers the slash (\\) legend for
completeness.
.. note::
Example of what it should look like: `LEGENDS=["'"'"'", "", "\""];`
"""
properly_escaped_quote = r'''"'"'"'"'''
out = "["
for i, legend in enumerate(legends):
if legend == "'":
out += properly_escaped_quote + ","
elif legend == '"':
out += r'"\""'
else:
out += json.dumps(legend, ensure_ascii=False) + ","
out = out.rstrip(',') # Get rid of trailing comma
return out + "]"
it needs the ensure_ascii=False flag in the when calling json.dumps
I've been trying to generate keycaps using material design icons font for the legends. I've installed the font on my system (running ubuntu on WSL), have installed the latest appimage for openscad, and grabbed the latest colorscad. I can generate the keycaps successfully using the keycap_playground.scad file, but i'm unable to do so using the gem_full python script. i've either had it output a square (unable to load icon) before i had the font correctly installed, or now, it outputs no legend at all. When viewing the output from colorscad, it claims one of the colors has no geometry related to it. Opening the .csg file generated in the colorscad process, i can see a bad icon, but at least there is one. i think its related to the font not being handled correctly when the python script runs, but i'm not sure why that would be.
Using python 3.10.12 openscad 2024.10.6
notes: using sublime text and openscad, i can see the icons correctly in the python script, or openscad file. still unsure why when running in python, i either get nothing as the icon, or a box.