From 74acb8cfda9335fb28a0d3fd32f86a6f2e266021 Mon Sep 17 00:00:00 2001 From: August Fortnight Date: Fri, 19 Jan 2018 07:20:34 -0800 Subject: [PATCH] add Latin-1 range and Unicode support This adds the full ASCII and Latin-1 ranges of Unicode to the character repertoire. It also changes the font to be more space-efficient as well as more readable while scrolling past on a small screen. --- sense_hat/sense_hat.py | 5 +++-- sense_hat/sense_hat_text.png | Bin 908 -> 1838 bytes sense_hat/sense_hat_text.txt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sense_hat/sense_hat.py b/sense_hat/sense_hat.py index 30597b9..3beda77 100644 --- a/sense_hat/sense_hat.py +++ b/sense_hat/sense_hat.py @@ -11,6 +11,7 @@ import pwd import array import fcntl +import codecs from PIL import Image # pillow from copy import deepcopy @@ -97,7 +98,7 @@ def __init__( # Text asset files are rotated right through 90 degrees to allow blocks of # 40 contiguous pixels to represent one 5 x 8 character. These are stored - # in a 8 x 640 pixel png image with characters arranged adjacently + # in a 8 pixel-wide png image with characters arranged adjacently # Consequently we must rotate the pixel map left through 90 degrees to # compensate when drawing text @@ -108,7 +109,7 @@ def _load_text_assets(self, text_image_file, text_file): """ text_pixels = self.load_image(text_image_file, False) - with open(text_file, 'r') as f: + with codecs.open(text_file, 'r', 'UTF-8') as f: loaded_text = f.read() self._text_dict = {} for index, s in enumerate(loaded_text): diff --git a/sense_hat/sense_hat_text.png b/sense_hat/sense_hat_text.png index b4841dbe341edd66e9c97db2a9b9c3c940bc278d..0f102d24a2ebd5b769ffe0bea7b082ff36510ab5 100644 GIT binary patch delta 1810 zcmV+t2krQb2d)l~77GOc2m$~A0QClh7Lg$yf8qfW0V4sJM2k%T0013nR9JLFZ*6U5 zZgc_CX>@2HM@dakWG-a~000K0NklBm(r0_91FjAV6O2OnIyUS_v`6n zf2r@Idud9gUw?OR@;uL+bAQJ2s@Prl%1@VS*q$-NYo<-VQR)x%dl_=ZB73Rvd}Oc@ zFr8}PRz|jam7tv&iD3+^<(4h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2SZE-#IGUg)3G5#{Nf3{+*RE)P z|EBk^L_Vf7ATk&t0(9>8UkS%C#$eBgWm^-;EWX<@k6+RtNw1~r)0u<`r*;O|?&>(0 zpKI?qsaOeRIENgkU&U}Wwb>FGLMP^Fe`U>}N)@fG+8ZA{t-c)1*!BFB{bR3YU~zPj zd_Qv50nc;?NzBj^9oev|=!-R6MpkS7GQy}!_*Z3Rwe?)AMR%=T#6hCGzu;}POFB~#E#aYebvV=4yyvlXm|k}XoTx%e^tKQ z9%vWIp+O^McAL1}ZrhH#J%jU)8v|d!LNfpn2RYnw_o;|H;^(k*B^(|)GUgKPT~NV zD9H55yaR(R`NnE(ufziN72=@Lf2pyVmb|%-I0_?nmH>+{)4AV>#^EE9z>8+uA!@u!Y;ZF(x#)KMj250|ypnDyxf`WpAf`WpAf`WpAf`WpAf`1A>;|8Nlc)e@*00000NkvXXu0mjfsau!R diff --git a/sense_hat/sense_hat_text.txt b/sense_hat/sense_hat_text.txt index a6fc7b6..406fb5d 100644 --- a/sense_hat/sense_hat_text.txt +++ b/sense_hat/sense_hat_text.txt @@ -1 +1 @@ - +-*/!"#$><0123456789.=)(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?,;:|@%[&_']\~ + +-*/!"#$><0123456789.=)(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?,;:|@%[&_']\~{}`^¡¿£¥©ªº«»®°±²³µ·¹¼½¾×÷¢¤¦§¨¬¯´¶ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ