Inky wHAT and python, fix fonts

I just got an inky wHAT at MicroCenter two days ago.
My first eink display. I’m also new at python. Actually, I know nothing about python.

So, I clicked on the github link to the inky page. I tried out the examples. They all worked as is. Although I did have to guess such as installing fonts based or error messages.

I took the quotes-what.py example and stripped it down to where it only displays some black text and some red text.

I’m having trouble here with fixed fonts. Again, I have no python background. I do not have a computer science background either. I am not a programmer.

Right now I got it to print some lines of text. Keeping it simple.

How do I get that quotes-what.py to print in fixed fonts? Any fixed font. I just want it where ‘iiii’ takes up the same space as ‘MMMM’.
Thanks.

Probably the easiest way to do that is to use a monospace font, they’re generally designed so that each letter is the same width.

Somewhere in your script there is likely to be a line which says something like quote_font = ImageFont.truetype(SourceSansProSemibold, font_size). Try changing SourceSansProSemibold to Liberation Mono, DejaVu Sans Mono or FreeMono.

If that doesn’t work right away I’d have to dig my WHAT out and remind myself how fonts work on it.

How? I do not know where to begin.
There is a line like that, but FreeMono does not work.

There is a line like that, but FreeMono does not work.

So when things fail in Python it should give an error message, and it’s really helpful to know what these are when trying to find out the issue. Could you copy and paste it here?

It should have been as simple as replacing the text SourceSansProSemibold with FreeMono. If I get time later this evening I’ll double check a few things.

Here is the output. And yes, I did try to install it with pip/3. And yes, I did try to google how to install fonts.

pi ./text.py Traceback (most recent call last): File "./text.py", line 18, in <module> import FreeMono ModuleNotFoundError: No module named 'FreeMono' pi ./text.py
Traceback (most recent call last):
File “./text.py”, line 18, in
import DejaVuSansMono
ModuleNotFoundError: No module named ‘DejaVuSansMono’

Ah, sorry, I missed something obvious. You need to wrap the font name in quotes, so "FreeMono", not FreeMono.

I’ve taken a quick skim through Pi OS fonts, and the monos which you should be able to use are:

DejaVuSansMono.
LiberationMono-Bold
VeraMoBI
NotoSansMono-Regular
FreeMonoBoldOblique
LiberationMono-BoldItalic
LiberationMono-Bold
LiberationMono-Italic
VeraMoBd
LiberationMono-Regular
LiberationMono-BoldItalic
DejaVuSansMono-Oblique
DejaVuSansMono-BoldOblique
LiberationMono-Regular
DejaVuSansMono-Bold
DejaVuSansMono-BoldOblique
FreeMonoObliqueDejaVuSansMono-Oblique
DejaVuSansMono-Bold
LiberationMono-Italic
VeraMono
VeraMoIte
NotoSansMono-Bold
NotoMono-Regular
FreeMono
DejaVuSansMono
FreeMonoBold

Use any of these in the same way, just wrap it in quotation marks.

Thank you. that works.