From 19e21b3506c51160b1437a6be908ca6aede65d04 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Thu, 16 May 2024 14:40:28 +0100 Subject: [PATCH] Add function to display right-aligned text --- font.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/font.py b/font.py index 0bcfd8e..eb6159f 100644 --- a/font.py +++ b/font.py @@ -300,7 +300,15 @@ class Font: if size == 1: w = 6 if size == 2: w = 11 if size == 3: w = 17 - gap = int((width - len(txt) * w)/2) + o + gap = (width - len(txt) * w)//2 + o Font.prnt_st(lcd,txt,gap,y,size,r,g,b) + @staticmethod + def rght_st(lcd,asci,xx,yy,sz,r,g,b): + if sz == 1: w = 6 + if sz == 2: w = 11 + if sz == 3: w = 17 + xo = xx - len(asci) * w + Font.prnt_st(lcd,asci,xo,yy,sz,r,g,b) + # =========== End of font support routines ===========