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

OS Error on Ubuntu 22.04 #17

Closed
neverorfrog opened this issue Jun 1, 2023 · 1 comment
Closed

OS Error on Ubuntu 22.04 #17

neverorfrog opened this issue Jun 1, 2023 · 1 comment

Comments

@neverorfrog
Copy link

Hi Professor Corke, thank you for your precious work. when opening bdedit, I was encountering the following error (with the program crashing on startup):

Traceback (most recent call last):
File "/home/flavio/University/robotics/project/bdsim/bdsim/bdedit/interface_scene.py", line 143, in determineFont
self._system_font = ImageFont.truetype("arial.ttf", 14)
File "/home/flavio/Programs/anaconda3/envs/robotics/lib/python3.10/site-packages/PIL/ImageFont.py", line 996, in truetype
return freetype(font)
File "/home/flavio/Programs/anaconda3/envs/robotics/lib/python3.10/site-packages/PIL/ImageFont.py", line 993, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/flavio/Programs/anaconda3/envs/robotics/lib/python3.10/site-packages/PIL/ImageFont.py", line 248, in init
self.font = core.getfont(
OSError: cannot open resource

I don't know if this can be useful, but I (for now) fixed it by modifying this function :

def determineFont(self):
    """
    This method sets the truetype font with which socket labels should be drawn.
    Originally, this property was set within the sockets themselves, but when
    they are constantly drawn/redrawn (i.e. when undo/redo is spammed) and as a
    result, multiple attemps are made to access the truetype font, Windows issues
    an OSError crashing the program... So since this font only needs to be defined
    on startup, the font is accessed whenever the scene is created.
    """
    try:
        self._system_font = ImageFont.truetype("arial.ttf", 14)
    except OSError:
        self._system_font = ImageFont.load_default()

Thank you again

petercorke added a commit that referenced this issue Jun 21, 2023
@petercorke
Copy link
Owner

Thanks for finding this, it's now on master branch but not yet on PyPI.

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