update
This commit is contained in:
parent
5bac678771
commit
0dedd0974f
@ -1,42 +1,38 @@
|
||||
from PIL import ImageFont
|
||||
|
||||
FONT_NAME = None
|
||||
FONT_NAME_FACES = 'DejaVuSansMono'
|
||||
# should not be changed
|
||||
FONT_NAME = 'DejaVuSansMono'
|
||||
|
||||
# can be changed
|
||||
STATUS_FONT_NAME = None
|
||||
SIZE_OFFSET = 0
|
||||
|
||||
Bold = None
|
||||
BoldSmall = None
|
||||
BoldBig = None
|
||||
Medium = None
|
||||
Small = None
|
||||
Huge = None
|
||||
FaceHuge = None
|
||||
FaceBold = None
|
||||
|
||||
|
||||
def init(config):
|
||||
global FONT_NAME, SIZE_OFFSET
|
||||
FONT_NAME = config['ui']['font']['name']
|
||||
global STATUS_FONT_NAME, SIZE_OFFSET
|
||||
STATUS_FONT_NAME = config['ui']['font']['name']
|
||||
SIZE_OFFSET = config['ui']['font']['size_offset']
|
||||
setup(10, 8, 10, 25, 25, 9)
|
||||
|
||||
|
||||
def status_font(old_font):
|
||||
global STATUS_FONT_NAME, SIZE_OFFSET
|
||||
return old_font.font_variant(font=STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET)
|
||||
|
||||
|
||||
def setup(bold, bold_small, medium, huge, bold_big, small):
|
||||
global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FaceHuge, FaceBold, FONT_NAME, FONT_NAME_FACES, SIZE_OFFSET
|
||||
|
||||
Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small + SIZE_OFFSET)
|
||||
Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium + SIZE_OFFSET)
|
||||
FaceHuge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, huge)
|
||||
FaceBold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, bold)
|
||||
|
||||
try:
|
||||
BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small + SIZE_OFFSET)
|
||||
Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold + SIZE_OFFSET)
|
||||
BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big + SIZE_OFFSET)
|
||||
Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge + SIZE_OFFSET)
|
||||
except OSError:
|
||||
BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small + SIZE_OFFSET)
|
||||
Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold + SIZE_OFFSET)
|
||||
BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big + SIZE_OFFSET)
|
||||
Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge + SIZE_OFFSET)
|
||||
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)
|
||||
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)
|
||||
|
@ -22,7 +22,7 @@ class DisplayImpl(object):
|
||||
# status is special :D
|
||||
'status': {
|
||||
'pos': (0, 0),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium),
|
||||
'max': 20
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class DFRobot(DisplayImpl):
|
||||
self._layout['mode'] = (225, 109)
|
||||
self._layout['status'] = {
|
||||
'pos': (125, 20),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium),
|
||||
'max': 20
|
||||
}
|
||||
return self._layout
|
||||
@ -40,4 +40,4 @@ class DFRobot(DisplayImpl):
|
||||
self._display.display(buf)
|
||||
|
||||
def clear(self):
|
||||
self._display.Clear(0xFF)
|
||||
self._display.Clear(0xFF)
|
||||
|
@ -26,7 +26,7 @@ class Inky(DisplayImpl):
|
||||
self._layout['mode'] = (187, 93)
|
||||
self._layout['status'] = {
|
||||
'pos': (102, 18),
|
||||
'font': fonts.Small,
|
||||
'font': fonts.status_font(fonts.Small),
|
||||
'max': 20
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class LcdHat(DisplayImpl):
|
||||
self._layout['mode'] = (215, 109)
|
||||
self._layout['status'] = {
|
||||
'pos': (125, 20),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium),
|
||||
'max': 20
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class OledHat(DisplayImpl):
|
||||
self._layout['mode'] = (103, 10)
|
||||
self._layout['status'] = {
|
||||
'pos': (30, 18),
|
||||
'font': fonts.Small,
|
||||
'font': fonts.status_font(fonts.Small),
|
||||
'max': 18
|
||||
}
|
||||
return self._layout
|
||||
|
@ -27,7 +27,7 @@ class Papirus(DisplayImpl):
|
||||
self._layout['mode'] = (175, 86)
|
||||
self._layout['status'] = {
|
||||
'pos': (85, 14),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 16
|
||||
}
|
||||
return self._layout
|
||||
|
@ -27,7 +27,7 @@ class Spotpear24inch(DisplayImpl):
|
||||
self._layout['mode'] = (280, 220)
|
||||
self._layout['status'] = {
|
||||
'pos': (80, 160),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium),
|
||||
'max': 20
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class WaveshareV1(DisplayImpl):
|
||||
self._layout['mode'] = (225, 109)
|
||||
self._layout['status'] = {
|
||||
'pos': (125, 20),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 20
|
||||
}
|
||||
else:
|
||||
@ -47,7 +47,7 @@ class WaveshareV1(DisplayImpl):
|
||||
self._layout['mode'] = (187, 93)
|
||||
self._layout['status'] = {
|
||||
'pos': (91, 15),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 20
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class Waveshare144lcd(DisplayImpl):
|
||||
self._layout['mode'] = (0, 117)
|
||||
self._layout['status'] = {
|
||||
'pos': (65, 26),
|
||||
'font': fonts.Small,
|
||||
'font': fonts.status_font(fonts.Small),
|
||||
'max': 12
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class Waveshare154inch(DisplayImpl):
|
||||
self._layout['mode'] = (170, 187)
|
||||
self._layout['status'] = {
|
||||
'pos': (5, 90),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 20
|
||||
}
|
||||
return self._layout
|
||||
|
@ -27,7 +27,7 @@ class WaveshareV2(DisplayImpl):
|
||||
self._layout['mode'] = (225, 109)
|
||||
self._layout['status'] = {
|
||||
'pos': (125, 20),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 20
|
||||
}
|
||||
else:
|
||||
@ -48,7 +48,7 @@ class WaveshareV2(DisplayImpl):
|
||||
self._layout['mode'] = (187, 93)
|
||||
self._layout['status'] = {
|
||||
'pos': (125, 20),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 14
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class Waveshare213bc(DisplayImpl):
|
||||
self._layout['mode'] = (187, 93)
|
||||
self._layout['status'] = {
|
||||
'pos': (91, 15),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 20
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class Waveshare213d(DisplayImpl):
|
||||
self._layout['mode'] = (187, 93)
|
||||
self._layout['status'] = {
|
||||
'pos': (91, 15),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 20
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class Waveshare27inch(DisplayImpl):
|
||||
self._layout['mode'] = (239, 163)
|
||||
self._layout['status'] = {
|
||||
'pos': (38, 93),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 40
|
||||
}
|
||||
return self._layout
|
||||
|
@ -26,7 +26,7 @@ class Waveshare29inch(DisplayImpl):
|
||||
self._layout['mode'] = (268, 114)
|
||||
self._layout['status'] = {
|
||||
'pos': (130, 25),
|
||||
'font': fonts.Medium,
|
||||
'font': fonts.status_font(fonts.Medium)
|
||||
'max': 28
|
||||
}
|
||||
return self._layout
|
||||
|
@ -54,9 +54,9 @@ class View(object):
|
||||
'line1': Line(self._layout['line1'], color=BLACK),
|
||||
'line2': Line(self._layout['line2'], color=BLACK),
|
||||
|
||||
'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.FaceHuge),
|
||||
'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge),
|
||||
|
||||
'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.FaceBold, color=BLACK),
|
||||
'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.Bold, color=BLACK),
|
||||
'friend_name': Text(value=None, position=self._layout['friend_name'], font=fonts.BoldSmall,
|
||||
color=BLACK),
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user