Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use() functionality to import fonts #165

Open
rockstorm101 opened this issue Feb 22, 2021 · 1 comment
Open

use() functionality to import fonts #165

rockstorm101 opened this issue Feb 22, 2021 · 1 comment

Comments

@rockstorm101
Copy link
Contributor

This is somewhat a feature request more than an issue really as I guess I'm attempting something a bit borderline here. According to OpenSCAD docs one should be able to use fonts "importing" them like:
use <ttf/super-font/my-super-font-in-italics.ttf>

However, attempting such thing through SP via solid.use() does not work.

Traceback (most recent call last):
  File "/tmp/test/venv/lib/python3.9/site-packages/solid/objects.py", line 856, in use
    contents = scad_file_path.read_text()
  File "/usr/lib/python3.9/pathlib.py", line 1256, in read_text
    return f.read()
  File "/usr/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 16: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/src/test.py", line 15, in <module>
    sp.use("../aux/awesome-font-bold.ttf")
  File "/tmp/test/venv/lib/python3.9/site-packages/solid/objects.py", line 858, in use
    raise Exception(f"Failed to import SCAD module '{scad_file_path}' with error: {e} ")
Exception: Failed to import SCAD module '../aux/awesome-font-bold.ttf' with error: 'utf-8' codec can't decode byte 0x92 in position 16: invalid start byte 
@etjones
Copy link
Contributor

etjones commented Feb 22, 2021

Hm. So in this situation, the correct SolidPython translation would be just to pass through a use <PATH.*tf> string?
I'm not in love with that design choice on OpenSCAD's part ("Let's just use use<> for any interaction with the filesystem!"), but SolidPython's is not to reason why.

I think this is an entirely reasonable feature to request and I think it's probably pretty straightforward to add. My work is a little crazy at the moment so this may not happen right away, but I'll look to take care of this in the next release. Thanks for submitting!

@etjones etjones changed the title use() functionaly to import fonts use() functionality to import fonts Mar 7, 2021
jeff-dh added a commit to jeff-dh/SolidPython that referenced this issue May 31, 2021
jeff-dh added a commit to jeff-dh/SolidPython that referenced this issue Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants