Inky pHAT - add fonts?

I LOVE my Inky pHAT!

Is it possible to add .TTF fonts to Inky pHAT? Is it as simple as dropping a font file in the installed Python module, and if so where can I find it? (I have looked!)

I ask because I would like to install a bitmap-style font that might render better at small sizes so I can cram more text on the display.

I seem to have answered my own question. I downloaded a font (ChiKareGo.ttf), in a terminal window changed directory to the Downloads folder and copied it to the inkyphat module folder with
sudo cp ChiKareGo.ttf /usr/lib/python3/dist-packages/inkyphat/fonts/

It works!

ChiKareGo is my own version of the original Mac font Chicago looks really nice at size 16. You can download it from http://www.pentacom.jp/pentacom/bitfontmaker2/gallery/?id=3778

1 Like

You don’t even need to copy the font file into place, you can use PIL’s font handling to load font files from anywhere you like!

What was the font based upon? Is it ground up? Is Apple going to eat me if we include it in the library? :D

Incidentally I was just reading about Python entry points- http://amir.rachum.com/blog/2017/07/28/python-entry-points/

Which - with a little refactoring - would let anyone ship a font for Inky pHAT just by following a certain pattern.

That’s great news that it’s so easy to reference fonts from anywhere - I will include that in my tide time project. The ChiKareGo font was made by me from the ground up but it is a pretty exact copy of Apple’s 68k Mac Chicago font - its designer Susan Kare is, I believe, aware of me doing this as I also recreated the original Mac Finder font and found she had left Easter eggs in it - we had a little chat on Twitter about it: http://www.suppertime.co.uk/blogmywiki/2017/04/finderskeepers/

Anyway, there are other totally original bitmap fonts of mine I’d be happy for to use, and others in the public domain. The Bitfontmaker gallery is a good place to start looking. Bauhaus is one I designed myself from the ground up for my A-level computer science project (on a ZX Spectrum!): http://www.suppertime.co.uk/blogmywiki/2015/08/bauhaus2015-bitmap-font/

Anyway, bitmap fonts are cool!

Keep up the good work, ship mates!

1 Like

That’s a great looking font on the inky! I’m using BMmini all in caps because I wanted to display quite a lot of info while remaining legible, and in the end I used the same thing you did: put the font in ttf in the inky font folder, and modified the init file for it to be recognized.

I don’t know PIL yet so I didn’t really understand how it could import fonts, maybe something to add to the documentation?

1 Like

It’s quite easy. I just downloaded my Bauhaus TTF font and placed it in the same directory as my tide time program. I used the following command to load the font onto the Inky pHAT:
font = ImageFont.truetype("/home/pi/Pimoroni/inkyphat/tides/Bauhaus2015.ttf", 16)

1 Like

I had no idea you could simply put the whole path, that’s brilliant! Thanks!

I notice your screen has no tearing, how long have you been using it? I’ve been using for about a day and it’s unreadable already.

In fact you don’t even need the whole path, just the .ttf filename if it’s in the same folder as the script.

Sorry to hear about tearing - been using mine for about 3 days quite heavily, all ok so far. Send it back!

yes in the end that’s what I did, just locate where the other fonts where, looked up the config file and made it match.

About the tearing, you’re lucky! Seems like many of us have the issue, probably a bad batch or something :( Streaky inkyphat

If I may interject, what version of the Raspberry Pi are you using there?

Me? I’m on a Raspberry Pi 3. Used it reasonably heavily. All ok so far, touch timbers!

I’ve added a few lines to the getting started guide to clarify how to add additional fonts. :-)

If you want to add additional fonts, then you can drop them into both the /usr/lib/python2.7/dist-packages/inkyphat/fonts and /usr/lib/python3/dist-packages/inkyphat/fonts directories. They should be .ttf files, ideally. Or you can simply pass the path to your font into the font = ImageFont.truetype(“/path/to/font”, 22) line in your code.

2 Likes

If anyone’s interested I found 6500 free fonts at http://webpagepublicity.com/free-fonts.html - there’s a sample of what each one looks like too.

I found Eden Mills Bold looks very nice on the Inky pHat.

1 Like