Skip to content

use() functionality to import fonts #165

Description

@rockstorm101

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 

Activity

  1. etjones commented on Feb 22, 2021

    @etjones
    Contributor

    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!

  2. changed the title [-]use() functionaly to import fonts[/-] [+]use() functionality to import fonts[/+] on Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions