Scroll PHat - Cyrillic font?


Hello everyone,

I’m currently working on making Pi Zero parse news titles and show them on this awesome Scroll PHat screen.
Everything works almost perfectly now; my only concern is that library works with English only, but I’d like to support some other languages, cyrillic for example.

Is there any general guideline on how to make it work? My guess is that I need to create new font.png (any tool for this?) and then use - is this what I should do? I’ll appreciate any advice.



Here’s an example of how it could be done on another device, this is quite different since these characters are actually embedded in the device:

The crux of this is that you need a map between every Unicode character you want to support and the pixels you want to light to draw it.

You could use a dict to implement this map, where each key is the Unicode character code, and each value is the relevant information to render the character.

At the moment the and only support ASCII ranges 0 to 127, so they would be totally useless for supporting Unicocode.

Support would require some re-writing the write_string method, plus manual creation of the mapping table ( built on top of ):

Fortunately the first 128 characters in ASCII and Unicode have identical meanings and character codes, so expanding the library and to support it would have no drawbacks- well except the sheer labour intensiveness of producing all the characters!

It’s very possible, if you’re willing to give it a try then go for it, otherwise it would be a good idea to add a GitHub issue asking for Unicode support and we can get it done when there’s some time to spare!


Thanks a lot for your reply!

And I’m really sorry for being silent - had to focus on some other things, unfortunately…
So I spent a bit more time on this and found one interesting pixel font, which should fit into 5x5 cells, and this is exactly what we need, right?
I’m totally ok with manually adding about 70 more codings into for Cyrillic - should take some time, but totally possible.
Not sure though I follow on the needed changes to write_string method you suggested, can you please explain in a bit more details?

And thanks again - I really appreciate your support!


Right, let’s learn things!

I’m quite rusty in this respect myself, so bear with me. I’m going to go back to THE BASICS!

Note: after writing all this it doesn’t look like we need to make a change to write_string after all.

A character encoding is basically just an established standard for representing, in numbers, a particular character.

Say you and I agree that 1 = ‘A’, 2 = ‘Y’ and 3 = ‘R’. Both of us have computers that understand this encoding. In fact, let’s say its circa 1980 and they have built-in chips that do nothing but convert a number into the right character for display on screen ( for example: ).

If I send your computer the string: 0x02 0x01 0x03 0x03 then it will decode these numbers by looking them up in the ‘Character ROM’ and display YARR on your screen by drawing the pixels it finds.

Luckily hardware ROM chips have been replaced with software that’s a zillion times more complicated but still basically understands that 0x02 means “Look up how to draw a Y and display it on the screen.”

We’re going to use the Python’s unicode handling which, luckily, matches quite handily to ASCII for the first 127 codepoints and defines a bunch of useful European and mathematical symbols in the next 128 codepoints. It looks something like this (ignoring the few unprintable characters mixed in):

†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ                               <--- font.png ends here


So ideally, these are the characters we want to define in the font and be able to display on Scroll pHAT.

Perhaps the best way to do this is to update font.png in tools: and then update “” to read in and store the additional characters.

font.png runs in 3 columns of 32 characters, giving a total of 96 from codepoints 0x20 to 0x7f (or 32 to 127). These represent the visible (printable) characters of ASCII.

Using a mix of your pixel font, and some hand tweaking, we should be able to expand this font.png to include 4 new columns- another 128 codepoints- and update “” to read in these extra columns.

I think if the font is updated, and you pass text strings into write_string like so:

write_string(u'Café 99º - ½ off coffee today! ¤±¤')

Then everything should be golden :D


These were very useful pointers, thanks Phil!

I decided though to choose some other way of implementing Cyrillic support because of the following reasons:

  • Codepoints 128-256 unfortunately do not contain cyrillic characters
  • At the end of the day it turned out to be much easier to edit directly rather than create additional png and do all this importing stuff. This also gives you flexibility when you decide to modify some characters to look better on scroll Phat.

Here’s the link to modified
And this is code to test how this works I had to add a couple lines for coding conversion to work properly.

I’d be happy if you decide to implement these changes to major version, so that this might be useful for others. Otherwise, one can always use my code.

Thanks for your help and awesome products your team creates!