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

Transparency of Fonts? #14

Closed dlashua closed 4 years ago

dlashua commented 5 years ago

First of all, thanks for a fantastic library making fonts easy with Micropython.

I'm working on a Fork of Writer to allow for text alignment that I'll put on github when complete.

One thing I'd like to add/change -- but my byte shifting knowledge isn't up to par -- is to allow the fonts to be transparent. That is, for non inverted text, the "on" pixels would be set to "on" in the frame buffer, but the "off" pixels would not be set to "off". For inverted text, the "on" pixels would be set to "off" but the "off" pixels would not be set to "on".

I'm hoping you can shed some light on how I might do this and that it doesn't require a change to the generated font files.

Thanks...

peterhinch commented 5 years ago

Transparency is outside of my experience but I think this would need to be handled at display driver level. The CWriter class supports colour displays. I think certain colours would need to be defined as partially transparent, and this would need to be handled by the device driver. But I can see numerous potential problems if transparent text is removed or moved: you'd somehow need to restore the underlying image. I suspect this would imply multiple buffers.

To be honest I think you need to raise this on the forum, or possibly elsewhere: there is doubtless plenty of know how about this, but alas I don't possess it.