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

problem with ImageFont.py #16

Closed
marcoalicera opened this issue Dec 19, 2017 · 4 comments · Fixed by #56
Closed

problem with ImageFont.py #16

marcoalicera opened this issue Dec 19, 2017 · 4 comments · Fixed by #56
Assignees
Milestone

Comments

@marcoalicera
Copy link

When I tried to ru sg.draw_model(mymodel) I got the following error:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-16-c8ed5de8abd8> in <module>()
      1 from swmmio.graphics import swmm_graphics as sg
----> 2 sg.draw_model(mymodel)

C:\Users\Test\AppData\Local\Continuum\anaconda2\lib\site-packages\swmmio\graphics\swmm_graphics.pyc in draw_model(model, nodes, conduits, parcels, title, annotation, file_path, bbox, px_width)
    111         if title: annotate_title(title, draw)
    112         if annotation: annotate_details(annotation, draw)
--> 113         annotate_timestamp(draw)
    114 
    115         #SAVE IMAGE TO DISK

C:\Users\Test\AppData\Local\Continuum\anaconda2\lib\site-packages\swmmio\graphics\drawing.pyc in annotate_timestamp(draw)
    206         size = (draw.im.getbbox()[2], draw.im.getbbox()[3])
    207         scale = 1 * size[0] / 2048
--> 208         fnt = ImageFont.truetype(config.font_file, int(20 *scale))
    209 
    210         timestamp = strftime("%b-%d-%Y %H:%M:%S")

C:\Users\Test\AppData\Local\Continuum\anaconda2\lib\site-packages\PIL\ImageFont.pyc in truetype(font, size, index, encoding)
    242 
    243     try:
--> 244         return FreeTypeFont(font, size, index, encoding)
    245     except IOError:
    246         ttf_filename = os.path.basename(font)

C:\Users\Test\AppData\Local\Continuum\anaconda2\lib\site-packages\PIL\ImageFont.pyc in __init__(self, font, size, index, encoding)
    131 
    132         if isPath(font):
--> 133             self.font = core.getfont(font, size, index, encoding)
    134         else:
    135             self.font_bytes = font.read()

IOError: cannot open resource

I should say that I have no admin rights on this machine and I won't have them

@aerispaha
Copy link
Member

@marcoalicera, it looks like the default font is set in definitions.py on line 26 here. At first glance this looks like a hard coded bug. Drawing methods should have a fallback font or use a default font that is OS agnostic. Want to take a stab at fixing this?

More broadly, I don't like how configuration is handled. I like adopt a best practice for providing users access to certain config setting. Does anyone have any ideas or examples of best practices to that end?

@marcoalicera
Copy link
Author

@aerispaha, I would like to help to fix it, but I have no idea how to start. I already had had a problem with the definitions.py, which was not part of my installation and I don not think I solved properly.

@aerispaha
Copy link
Member

@marcoalicera, understood. I don't want to get too ahead of ourselves, but I feel like this issue stems from broader project-level set up that I'd like to address. For now, I can try to find time to debug this directly. Can you share a requirements.txt file so I can see exactly how your environment it set up?

You can run conda list -e > requirements.txt from a command line and attach the resulting file here.

@marcoalicera
Copy link
Author

requirements.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants