Allen-Synthesis / EuroPi

EuroPi: A reprogrammable Eurorack module based on the Raspberry Pi Pico
Creative Commons Zero v1.0 Universal
431 stars 84 forks source link

Add support for large font. #226

Closed francoisgeorgy closed 1 year ago

francoisgeorgy commented 1 year ago

Here is my proposal for a firmware upgrade to support large fonts.

I put the code in the experimental folder because I'm still very new in this project and my code probably needs some work before being merged in the firmware.

I included four fonts that, imho, display nicely in he EuroPi OLED. Of course, other truetype fonts can be imported with the script mentioned in the largefont_writer.py module.

To use a large font, simply add the font= argument to either Display.text() or Display.centre_text() methods. Example :

import freesans17
oled.centre_text('Hi folks', font=freesans17)

Regarding the centre_text() method, I paid attention not to introduce any regression. I tested the updated method and the current one with the 8x8 monospaced font to be sure there was no differences. There is only one change: the current code allows a text of four lines to be displayed, the first line will be clipped. The new version only allows three lines, like the specifications says. This change comes from using an integer division // instead of round() when computing the number of lines.

I included the contrib/largefont_demo.py script that allows to quickly check if the large font support is working or not. It displays a text using the regular 8x8 font and the four new FreeSans large fonts. The display loops between these five fonts. The screen border is also alternatively displayed in order to get a better overview of how the fonts are aligned.

francoisgeorgy commented 1 year ago

Looks good now. Thank you for your help!

redoxcode commented 1 year ago

Glad that worked. LGTM now

francoisgeorgy commented 1 year ago

Hi @mjaskula . You re right, this PR has become a mess. I created it just before the big changes related to the new configuration feature. And, on top of that, we had a linebreak issue. I'll try to rebase it. Or maybe it's simpler to trash it a simply create a new PR? Do you have a preference?

mjaskula commented 1 year ago

Hi @mjaskula . You re right, this PR has become a mess. I created it just before the big changes related to the new configuration feature. And, on top of that, we had a linebreak issue. I'll try to rebase it. Or maybe it's simpler to trash it a simply create a new PR? Do you have a preference?

Whichever is easier for you is fine.

francoisgeorgy commented 1 year ago

Hi, I tried to rebase my PR and cherry-pick only the commits related to the large_font changes, but this created event more commits. I probably made a mistake somewhere.

I think creating a new PR is the simplest solution, but I fear we my lose all the history of the current PR.

If you know how to clean the current PR I'd would be more than happy to follow your instructions. Otherwise I propose that we close the current PR and I open a new one.

mjaskula commented 1 year ago

Hi, I tried to rebase my PR and cherry-pick only the commits related to the large_font changes, but this created event more commits. I probably made a mistake somewhere.

I think creating a new PR is the simplest solution, but I fear we my lose all the history of the current PR.

If you know how to clean the current PR I'd would be more than happy to follow your instructions. Otherwise I propose that we close the current PR and I open a new one.

I tried looking into it and repairing it on my local checkout, but I do not understand when GH is showing those commits. I think that we might as well cut our losses and open a new PR. You can put links between the new and old PRs such that the history is not lost. It will be more inconvenient, but not lost.

francoisgeorgy commented 1 year ago

This PR is replaced by https://github.com/Allen-Synthesis/EuroPi/pull/234.