peterhinch / micropython-font-to-py

A Python 3 utility to convert fonts to Python source capable of being frozen as bytecode
MIT License
368 stars 67 forks source link

Writer hangs if font.height larger than device.height #33

Closed Ian9231 closed 3 years ago

Ian9231 commented 3 years ago

I had modified the SSD1306 driver to have two frame buffers (display is 128 x 64 with the top 16 row yellow and remainder blue). the upper buffer is 128 x 16 and the lower 128 x 48. Writer works fine on the lower buffer and can be instantiated on the upper using the freesans10.py font. Writer then hangs when printstring is called. If row clipping is set True the printstring returns but no text is displayed.
Note freesans10.py is 17 pixels high.

My work around in _init is self.row_clip = (self.font.height() > self.screenheight) to prevent hanging.

peterhinch commented 3 years ago

That is an extreme case. Maybe the constructor should throw an exception: such a Writer really isn't much practical use.

Ian9231 commented 3 years ago

True, an exception would be better, as it was not initialy apparent to me that the freesans10.py font was 17 height. And my work around results in no text being displayed.  

peterhinch commented 3 years ago

Update which throws a ValueError now pushed.