Permalink
Browse files

Render checkmark/cross icon instead of fail/pass text

  • Loading branch information...
hanneskaeufler committed Feb 10, 2018
1 parent 454ad76 commit 59ac670b9f6dc21e1828dacf6b079b615ea49fe3
Showing with 9 additions and 7 deletions.
  1. +1 −0 .gitignore
  2. BIN FreeMonoBold.ttf
  3. BIN Lato-Regular.ttf
  4. +8 −7 dash.py
  5. BIN expected.png
@@ -2,3 +2,4 @@
actual.png
diff.png
/node_modules/
*.ttf
BIN -170 KB FreeMonoBold.ttf
Binary file not shown.
BIN -117 KB Lato-Regular.ttf
Binary file not shown.
15 dash.py
@@ -16,18 +16,19 @@ class Dash:
WHITE = 255

PADDING = 10
BADGE_WIDTH = 150
BADGE_WIDTH = 70

PASSED = 'passed'
FAILED = 'failed'
PASSED = u'\uf058'
FAILED = u'\uf057'

def __init__(self, projects, fonts_dir):
self.projects = projects
self.image = self.__clear_image()
self.draw = ImageDraw.Draw(self.image)
self.title_font = ImageFont.truetype(os.path.join(fonts_dir, 'FreeMonoBold.ttf'), 32)
self.font = ImageFont.truetype(os.path.join(fonts_dir, 'Lato-Regular.ttf'), 32)
self.badge_font = ImageFont.truetype(os.path.join(fonts_dir ,'Lato-Regular.ttf'), 24)
self.badge_font = ImageFont.truetype(os.path.join(fonts_dir, 'Lato-Regular.ttf'), 24)
self.icon_font = ImageFont.truetype(os.path.join(fonts_dir, 'fa-regular-400.ttf'), 24)

def render(self, date):
self.__render_header(date)
@@ -61,17 +62,17 @@ def __render_project_status(self, row):
self.draw.rectangle(self.__badge_position(index), outline = self.BLACK)
self.draw.text(self.__badge_text_position(index, self.PASSED),
self.PASSED,
font = self.badge_font,
font = self.icon_font,
fill = self.BLACK)
else:
self.draw.rectangle(self.__badge_position(index), fill = self.BLACK)
self.draw.text(self.__badge_text_position(index, self.FAILED),
self.FAILED,
font = self.badge_font,
font = self.icon_font,
fill = self.WHITE)

def __badge_text_position(self, index, text):
width, height = self.draw.textsize(text, font = self.badge_font)
width, height = self.draw.textsize(text, font = self.icon_font)
start_y = index * self.__row_height()
padding_x = (self.BADGE_WIDTH - width) / 2
padding_y = (self.__row_height() - height) / 2
BIN -75 Bytes (97%) expected.png
Binary file not shown.

0 comments on commit 59ac670

Please sign in to comment.