ndevenish / gflabel

Generate 3d-printable labels for gridfinity label systems
BSD 3-Clause "New" or "Revised" License
22 stars 4 forks source link

Default font selection failed when running from poetry #6

Closed PaulBone closed 3 months ago

PaulBone commented 3 months ago

$ poetry run gflabel --base pred -w 1 "{sym(resistor-ieee-standard)} < 100" -o resistor1.step Rendering line 1 ("{sym(resistor-ieee-standard)} < 100")
Traceback (most recent call last): File "", line 1, in File "/home/paul/dev/gflabel/src/gflabel/cli.py", line 306, in run render_divided_label( File "/home/paul/dev/gflabel/src/gflabel/label.py", line 325, in render_divided_label add(renderer.render(label, area_per_label)) File "/home/paul/dev/gflabel/src/gflabel/label.py", line 139, in render self._do_multiline_render( File "/home/paul/dev/gflabel/src/gflabel/label.py", line 179, in _do_multiline_render self._render_single_line( File "/home/paul/dev/gflabel/src/gflabel/label.py", line 264, in _render_single_line rendered[frag] = frag.render(frag_available_y, area.X, self.opts) File "/home/paul/dev/gflabel/src/gflabel/fragments.py", line 280, in render Rectangle(_whitespace_width(self.whitespace, height, options), height) File "/home/paul/dev/gflabel/src/gflabel/fragments.py", line 244, in _whitespace_width Text( File "/home/paul/.cache/pypoetry/virtualenvs/gflabel-giULq7UQ-py3.10/lib/python3.10/site-packages/build123d/objects_sketch.py", line 566, in init text_string = Compound.make_text( File "/home/paul/.cache/pypoetry/virtualenvs/gflabel-giULq7UQ-py3.10/lib/python3.10/site-packages/build123d/topology.py", line 4177, in make_text font_t = mgr.FindFont(TCollection_AsciiString(font), font_kind) OCP.Standard.Standard_NullObject: TCollection_AsciiString(): NULL pointer passed to constructor

I don't know if running from poetry was supported, but that's what I was using to test my changes to gflabel. I had to install the font and then select it with --font "Open Sans" before it worked.

ndevenish commented 3 months ago

It should work in poetry, It's just hard for me to test as my usual platforms don't have ocp wheels (RHEL 8 is too old and MacOS arm wheels via conda only)

ndevenish commented 3 months ago

Okay, so poetry was a red herring here. When I switch to make the fonts built-in, the "calculate width of whitespace next to symbol fragment" code was still using "font name". This should now work.