mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-17 05:15:17 +03:00
Monospaced font for digits
So timers etc. do not jump back and forth. Assumes that 4 is the widest digit.
This commit is contained in:
parent
7005946808
commit
019a1584d0
1 changed files with 9 additions and 2 deletions
|
@ -54,8 +54,15 @@ class FontBitmap:
|
|||
# default width for space
|
||||
width = 4
|
||||
if c != ' ':
|
||||
width = self.font.getmask(c).getbbox()[2]
|
||||
_, (offset_x, offset_y) = self.font.font.getsize(c)
|
||||
if "0123456789".find(c) >= 0 :
|
||||
width = self.font.getmask("4").getbbox()[2]
|
||||
_, (offset_x, offset_y) = self.font.font.getsize(c)
|
||||
_, (offset_x2, offset_y2) = self.font.font.getsize("4")
|
||||
offset_x = (offset_x + offset_x2) / 2
|
||||
else :
|
||||
width = self.font.getmask(c).getbbox()[2]
|
||||
_, (offset_x, offset_y) = self.font.font.getsize(c)
|
||||
|
||||
draw.text((x - offset_x, 0), c, fill=self.foreground, font=self.font)
|
||||
|
||||
return width
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue