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 class not working on lobo micropython #10

Closed julien123123 closed 5 years ago

julien123123 commented 6 years ago

I'm trying to port one of my scripts that uses the writer class from the official micropython on an ESP32 to the Lobo micropython. When micropython arrives at the writer class, it always rises this error: Traceback (most recent call last): File "<stdin>", line 16, in <module> File "writer.py", line 56, in __init__ ValueError: Font must be horizontally mapped. The converted fonts worked on very well on micropython with the ssd1306 adafruit driver. Any ideas?

peterhinch commented 6 years ago

I have only tested with official builds and the official ssd1306 driver.

That said, a font file is just Python code. If you look at your font file you should find a function hmap in the code which simply returns True if the font is horizontally mapped. The line which throws the exception seems to suggest that your font file has an hmap function which is returning False. If your font file's function returns False then the font is indeed not horizontally mapped. If it returns True then I'm baffled. It looks as if there is something very odd about the Loboris port. Try (at the Loboris REPL):

import MyFont
MyFont.hmap()
julien123123 commented 6 years ago

Nevermind, the Loboris port has a Writer class of its own. After changing the name of your file, it worked just like on normal micropython. The hmap propriety of my fonts returned False indeed. I was just wondering why it was an issue, where it wasn't before.