Specifying fonts for GFX HAT

Hi there,

I am new to GFX HAT and Python. I got everything installed, and I got the sample Python code for “Hello World” to display. However, i noticed that there are not that many fonts included in the library - the sample code gives the following line:

font = ImageFont.truetype(fonts.AmaticSCBold, 38)

I think that that is a kind of an ugly font, and I would like to display something like Helvetica, or Times New Roman etc. I understand the size obviously, there could also be other fonts available that I just can’t see.

So, the question is - how do I use different more “normal” fonts.

Thanks, Alex.

Find and download a TTF file for the font you like.
Put it in a path accessible by your program.
Then do something like this:

from PIL import Image, ImageDraw, ImageFont

MY_DISPLAY_FONT = './fonts/arial.ttf'

my_font = ImageFont.truetype(MY_DISPLAY_FONT, 12)
my_img = Image.new('RGB', (160, 13))
my_img_draw = ImageDraw.Draw(my_img)
text = 'Hello world!'
my_img_draw.text((0, 0), text, (255,255,255), font=my_font)

Awesome, thank you so much!

Pimimoron Github point to 2 fonts for the gfx hat ,not much, GitHub - pimoroni/gfx-hat: Python library for the Pimoroni GFX HAT Scroll way down near the bottom I its a old Hat, not much added to it foe a long time … I have the display-o-tron hat ,Its more for what the board can do and not the display so much , not the best for fonts, mind you I have never looked for fonts to use with it,