Added font family option and set specific boldness in some cases

This commit is contained in:
Maximilian Giller 2019-03-10 15:54:46 +01:00
parent fe838f5964
commit e4f77aff7c
3 changed files with 10 additions and 6 deletions

View file

@ -3,7 +3,7 @@ from TextDesign import TextDesign
from settings import week_starts_on, owm_paid_subscription
from DesignEntity import DesignEntity
from datetime import datetime
from Assets import weathericons, wpath
from Assets import weathericons, wpath, fonts
from SingelDayEventListDesign import SingelDayEventListDesign
daynumber_y_size = (1, 0.65)
@ -20,6 +20,7 @@ eventlist_y_fontsize = 0.2
general_text_color = "black"
highlight_text_color = "red"
background_color = "white"
font = fonts["regular"]
class DayRowDesign (DesignEntity):
"""Detailed view of a given date."""
@ -80,7 +81,7 @@ class DayRowDesign (DesignEntity):
color = self.__get_day_color__()
week_day_name = self.date.strftime("%a")
week_day = TextDesign(size, text=week_day_name, background_color=background_color, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="top")
week_day = TextDesign(size, text=week_day_name, font=font, background_color=background_color, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="top")
week_day.pos = pos
self.draw_design(week_day)
@ -92,7 +93,7 @@ class DayRowDesign (DesignEntity):
day_text = self.__get_day_text__()
color = self.__get_day_color__()
number = TextDesign(size, text=day_text, background_color=background_color, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="bottom")
number = TextDesign(size, text=day_text, font=font, background_color=background_color, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="bottom")
number.pos = pos
self.draw_design(number)

View file

@ -4,7 +4,7 @@ from TableTextDesign import TableTextDesign
class EventListDesign (DesignEntity):
"""Creates a TableTextDesign filled with event
begin date and title"""
def __init__ (self, size, calendar, text_size = 16, filter_date=None, line_spacing=2, col_spacing=10, event_prefix_func=None):
def __init__ (self, size, calendar, text_size = 16, filter_date=None, line_spacing=2, col_spacing=10, event_prefix_func=None, font_family=None):
super(EventListDesign, self).__init__(size)
self.calendar = calendar
self.__event_matrix__ = []
@ -12,6 +12,7 @@ class EventListDesign (DesignEntity):
self.filter_date = filter_date
self.line_spacing = line_spacing
self.col_spacing = col_spacing
self.font_family = font_family
self.event_prefix_func = event_prefix_func
if self.event_prefix_func is None:
self.event_prefix_func = lambda x : self.__remove_leading_zero__(x.begin_datetime.strftime('%d %b'))
@ -21,7 +22,7 @@ class EventListDesign (DesignEntity):
col_hori_alignment = ['right', 'left']
table_design = TableTextDesign(self.size, line_spacing=self.line_spacing, col_spacing=self.col_spacing, text_matrix=self.__event_matrix__, fontsize = self.text_size, column_horizontal_alignments=col_hori_alignment, mask=False, truncate_cols=False)
table_design = TableTextDesign(self.size, font=self.font_family, line_spacing=self.line_spacing, col_spacing=self.col_spacing, text_matrix=self.__event_matrix__, fontsize = self.text_size, column_horizontal_alignments=col_hori_alignment, mask=False, truncate_cols=False)
self.draw_design(table_design)
def __get_formatted_event__ (self, event):

View file

@ -1,13 +1,15 @@
from EventListDesign import EventListDesign
from settings import hours
from Assets import fonts
eventlist_allday_char = ""
font = fonts["regular"]
class SingelDayEventListDesign (EventListDesign):
"""Specialized event list for day list design."""
def __init__ (self, size, calendar, date, font_size = 16, line_spacing=2, col_spacing=5):
prefix_func = lambda x : self.__get_event_prefix__(x)
super().__init__(size, calendar, filter_date=date, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_func=prefix_func)
super().__init__(size, calendar, filter_date=date, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_func=prefix_func, font_family=font)
def __get_event_prefix__ (self, event):
if event.allday: