more fonts

This commit is contained in:
dadav 2020-04-02 19:06:28 +02:00
parent 54ffbbcb0b
commit 305f837486
18 changed files with 50 additions and 30 deletions

View File

@ -14,6 +14,7 @@ from pwnagotchi import plugins
from pwnagotchi import log
from pwnagotchi.identity import KeyPair
from pwnagotchi.agent import Agent
from pwnagotchi.ui import fonts
from pwnagotchi.ui.display import Display
from pwnagotchi import restart
from pwnagotchi import fs
@ -129,6 +130,7 @@ if __name__ == '__main__':
pwnagotchi.config = config
fs.setup_mounts(config)
log.setup_logging(args, config)
fonts.init(config)
pwnagotchi.set_name(config['main']['name'])

View File

@ -104,6 +104,7 @@
- python3-flask
- python3-flask-cors
- python3-flaskext.wtf
- fonts-ipaexfont-gothic
tasks:
- name: change hostname

View File

@ -148,6 +148,7 @@ personality.sad_num_epochs = 25
personality.bond_encounters_factor = 20000
ui.fps = 0.0
ui.font = "DejaVuSansMono" # for japanese: fonts-japanese-gothic
ui.faces.look_r = "( ⚆_⚆)"
ui.faces.look_l = "(☉_☉ )"

View File

@ -1,18 +1,34 @@
from PIL import ImageFont
PATH = '/usr/share/fonts/truetype/dejavu/DejaVuSansMono'
Bold = ImageFont.truetype("%s-Bold.ttf" % PATH, 10)
BoldSmall = ImageFont.truetype("%s-Bold.ttf" % PATH, 8)
BoldBig = ImageFont.truetype("%s-Bold.ttf" % PATH, 25)
Medium = ImageFont.truetype("%s.ttf" % PATH, 10)
Small = ImageFont.truetype("%s.ttf" % PATH, 9)
Huge = ImageFont.truetype("%s-Bold.ttf" % PATH, 25)
FONT_NAME = None
Bold = None
BoldSmall = None
BoldBig = None
Medium = None
Small = None
Huge = None
def setup(bold, bold_small, medium, huge):
global PATH, Bold, BoldSmall, Medium, Huge
Bold = ImageFont.truetype("%s-Bold.ttf" % PATH, bold)
BoldSmall = ImageFont.truetype("%s-Bold.ttf" % PATH, bold_small)
Medium = ImageFont.truetype("%s.ttf" % PATH, medium)
Huge = ImageFont.truetype("%s-Bold.ttf" % PATH, huge)
def init(config):
global FONT_NAME
FONT_NAME = config['ui']['font']
setup(10, 8, 10, 25, 25, 9)
def setup(bold, bold_small, medium, huge, bold_big, small):
global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME
Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small)
Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium)
try:
BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small)
Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold)
BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big)
Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge)
except OSError:
BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small)
Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold)
BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big)
Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge)

View File

@ -9,7 +9,7 @@ class DFRobot(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 250
self._layout['height'] = 122
self._layout['face'] = (0, 40)

View File

@ -10,7 +10,7 @@ class Inky(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 28)
fonts.setup(10, 8, 10, 28, 25, 9)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 37)

View File

@ -10,7 +10,7 @@ class LcdHat(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 240
self._layout['height'] = 240
self._layout['face'] = (0, 40)

View File

@ -10,7 +10,7 @@ class OledHat(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(8, 8, 8, 8)
fonts.setup(8, 8, 8, 8, 25, 9)
self._layout['width'] = 128
self._layout['height'] = 64
self._layout['face'] = (0, 32)

View File

@ -11,7 +11,7 @@ class Papirus(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 23)
fonts.setup(10, 8, 10, 23, 25, 9)
self._layout['width'] = 200
self._layout['height'] = 96
self._layout['face'] = (0, 24)

View File

@ -11,7 +11,7 @@ class Spotpear24inch(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(12, 10, 12, 70)
fonts.setup(12, 10, 12, 70, 25, 9)
self._layout['width'] = 320
self._layout['height'] = 240
self._layout['face'] = (35, 50)

View File

@ -11,7 +11,7 @@ class WaveshareV1(DisplayImpl):
def layout(self):
if self.config['color'] == 'black':
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 250
self._layout['height'] = 122
self._layout['face'] = (0, 40)
@ -31,7 +31,7 @@ class WaveshareV1(DisplayImpl):
'max': 20
}
else:
fonts.setup(10, 8, 10, 25)
fonts.setup(10, 8, 10, 25, 25, 9)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 26)

View File

@ -10,7 +10,7 @@ class Waveshare144lcd(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 18)
fonts.setup(10, 8, 10, 18, 25, 9)
self._layout['width'] = 128
self._layout['height'] = 128
self._layout['face'] = (0, 43)

View File

@ -10,7 +10,7 @@ class Waveshare154inch(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 200
self._layout['height'] = 200
self._layout['face'] = (0, 40)

View File

@ -11,7 +11,7 @@ class WaveshareV2(DisplayImpl):
def layout(self):
if self.config['color'] == 'black':
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 250
self._layout['height'] = 122
self._layout['face'] = (0, 40)
@ -31,7 +31,7 @@ class WaveshareV2(DisplayImpl):
'max': 20
}
else:
fonts.setup(10, 8, 10, 25)
fonts.setup(10, 8, 10, 25, 25, 9)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 26)

View File

@ -10,7 +10,7 @@ class Waveshare213bc(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 25)
fonts.setup(10, 8, 10, 25, 25, 9)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 26)

View File

@ -10,7 +10,7 @@ class Waveshare213d(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 8, 10, 25)
fonts.setup(10, 8, 10, 25, 25, 9)
self._layout['width'] = 212
self._layout['height'] = 104
self._layout['face'] = (0, 26)

View File

@ -10,7 +10,7 @@ class Waveshare27inch(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 264
self._layout['height'] = 176
self._layout['face'] = (66, 27)

View File

@ -10,7 +10,7 @@ class Waveshare29inch(DisplayImpl):
self._display = None
def layout(self):
fonts.setup(10, 9, 10, 35)
fonts.setup(10, 9, 10, 35, 25, 9)
self._layout['width'] = 296
self._layout['height'] = 128
self._layout['face'] = (0, 40)