adafruit / Adafruit_CircuitPython_framebuf

CircuitPython framebuf module, based on the Python framebuf module
MIT License
39 stars 36 forks source link

Add font_name to BitmapFont call for custom fonts #32

Closed xdmtk closed 4 years ago

xdmtk commented 4 years ago

Hi all,

I've been using this package as part of the Adafruit_Python_SSD1306 package for few weeks now and I've been having issues making calls to the text drawing function using custom font paths (and consequently custom fonts as well).

As it is right now, any call made to adafruit_ssd1306.SSD1306_I2C.text() with or without a font_name= parameter specified expects a file font5x8.bin in the current working directory of the calling script despite what may be specified, rendering the font_name= keyword param useless.

After some digging it looks like the BitmapFont class is never instantiated with the font_name parameter, despite the BitmapFont class having a default parameter available to override. I have added the font_name parameter in the call to instantiate BitmapFont in this pull request, and it has fixed my build (allowing me to keep my font files out of the working directory of the active script).

Hopefully this pull request helps and this repo is still alive and well. Thanks

ladyada commented 4 years ago

nice, we do recommend PILLOW for drawing fonts, the built in font is really minimal :)