stratosb
Posts: 13
Joined: Mon Dec 15, 2014 8:21 am

Sense Hat and greek fonts

Fri Sep 29, 2017 10:32 am

Hello,
I own a sense hat and it is not possible to display a text in greek with the command: sense.show_message("<greek text>").
Does the sense hat support the greek fonts?
Thank you.

Stratos

scotty101
Posts: 2389
Joined: Fri Jun 08, 2012 6:03 pm

Re: Sense Hat and greek fonts

Fri Sep 29, 2017 12:07 pm

Short Answer: No.

The sense hat code has a .png image which contains the characters that it supports. This only seems to contain basic 'English' characters and symbols.

To draw your own text you'd need to either modify the sense hat code (and png image) or draw the symbol yourself.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
Davespice
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1634
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website Twitter

Re: Sense Hat and greek fonts

Mon Oct 02, 2017 8:06 am

So the Sense HAT library is provided with the Latin-1 character set built in, but it does give the user the option to provide their own text assets. If you look here you'll see the files named sense_hat_text.txt and sense_hat_text.png. The text file is used to index the order in which the characters appear in the png. Also the png is rotated 90 degrees to that every character is made up of continuous pixels.

If you were to re-create both of these files, and change their names to say sense_hat_greek.txt and sense_hat_greek.png and put them into /usr/lib/pythonXXX/dist-packages/sense_hat on your system, you would be able to load them like this:

Code: Select all

from sense_hat import SenseHat
sense = SenseHat(text_assets = "sense_hat_greek")
sense.show_message("hello")
However, because of how python deals with looping over strings you may run into issues with this part of the library where it expects one text character to equate to one png character. I believe a lot of Unicode characters are two bytes long, whereas everything in Latin-1 is one byte long.

timrowledge
Posts: 1082
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Sense Hat and greek fonts

Mon Oct 02, 2017 7:58 pm

There are some quite complicated character glyphs in Greek - will they actually display well enough to be useful on an 8x8 coarse grid display?
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

User avatar
Davespice
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1634
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website Twitter

Re: Sense Hat and greek fonts

Tue Oct 03, 2017 10:45 am

The characters are 5x7 so it's even worse! I imagine they would be able to get something which looks better than Latin-1 but whether it would be easily readable is another question. Also one of the reasons we only went with Latin-1 in the first place.

Return to “Astro Pi”

Who is online

Users browsing this forum: No registered users and 2 guests