Merge pull request #56 from aceisace/Dynamic-font-size
Dynamic font size
This commit is contained in:
		| @@ -10,7 +10,7 @@ from configuration import* | |||||||
| from settings import * | from settings import * | ||||||
| import arrow | import arrow | ||||||
|  |  | ||||||
| fontsize = 12 | fontsize = 14 | ||||||
| show_events = True | show_events = True | ||||||
| print_events = False | print_events = False | ||||||
| style = 'D MMM YY HH:mm' | style = 'D MMM YY HH:mm' | ||||||
|   | |||||||
| @@ -13,9 +13,12 @@ from PIL import Image, ImageDraw | |||||||
|  |  | ||||||
| print_events = False | print_events = False | ||||||
| show_events = True | show_events = True | ||||||
| max_event_lines = 4 | fontsize = 16 | ||||||
| style = "DD MMM" |  | ||||||
| event_icon = 'square' # dot #square | event_icon = 'square' # dot #square | ||||||
|  | style = "DD MMM" | ||||||
|  |  | ||||||
|  | font = ImageFont.truetype(NotoSans+'.ttf', fontsize) | ||||||
|  | space_between_lines = 1 | ||||||
|  |  | ||||||
| if show_events == True: | if show_events == True: | ||||||
|   from inkycal_icalendar import fetch_events |   from inkycal_icalendar import fetch_events | ||||||
| @@ -27,6 +30,9 @@ border_left = int(middle_section_width * 0.02) | |||||||
| main_area_height = middle_section_height-border_top*2 | main_area_height = middle_section_height-border_top*2 | ||||||
| main_area_width = middle_section_width-border_left*2 | main_area_width = middle_section_width-border_left*2 | ||||||
|  |  | ||||||
|  | line_height = font.getsize('hg')[1] + space_between_lines | ||||||
|  | line_width = middle_section_width - (border_left*2) | ||||||
|  |  | ||||||
| """Calculate height for each sub-section""" | """Calculate height for each sub-section""" | ||||||
| month_name_height = int(main_area_height*0.1) | month_name_height = int(main_area_height*0.1) | ||||||
| weekdays_height = int(main_area_height*0.05) | weekdays_height = int(main_area_height*0.05) | ||||||
| @@ -53,9 +59,11 @@ grid = [(grid_start_x + icon_width*x, grid_start_y + icon_height*y) | |||||||
| weekday_pos = [(grid_start_x + icon_width*_, middle_section_offset + | weekday_pos = [(grid_start_x + icon_width*_, middle_section_offset + | ||||||
|                 month_name_height) for _ in range(calendar_coloumns)] |                 month_name_height) for _ in range(calendar_coloumns)] | ||||||
|  |  | ||||||
|  | max_event_lines = (events_height - border_top) // (font.getsize('hg')[1] | ||||||
|  |   + space_between_lines) | ||||||
|  |  | ||||||
| event_lines = [(border_left,(bottom_section_offset - events_height)+ | event_lines = [(border_left,(bottom_section_offset - events_height)+ | ||||||
|                 int(events_height/max_event_lines*_)) for _ in |   int(events_height/max_event_lines*_)) for _ in range(max_event_lines)] | ||||||
|                range(max_event_lines)] |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|   try: |   try: | ||||||
| @@ -156,7 +164,7 @@ def main(): | |||||||
|         'HH:mm' if hours == 24 else 'hh:mm'), event.name) |         'HH:mm' if hours == 24 else 'hh:mm'), event.name) | ||||||
|         for event in calendar_events if event.begin.day == now.replace(days=+1).day] |         for event in calendar_events if event.begin.day == now.replace(days=+1).day] | ||||||
|  |  | ||||||
|       del event_list[4:] |       del event_list[max_lines:] | ||||||
|  |  | ||||||
|     if event_list: |     if event_list: | ||||||
|       for lines in event_list: |       for lines in event_list: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user