| @@ -99,12 +99,12 @@ def auto_fontsize(font, max_height): | |||||||
|           A PIL font object with modified height. |           A PIL font object with modified height. | ||||||
|       """ |       """ | ||||||
|     text_bbox = font.getbbox("hg") |     text_bbox = font.getbbox("hg") | ||||||
|     text_height = text_bbox[3] - text_bbox[1] |     text_height = text_bbox[3] | ||||||
|     fontsize = text_height |     fontsize = text_height | ||||||
|     while text_height <= (max_height * 0.80): |     while text_height <= (max_height * 0.80): | ||||||
|         fontsize += 1 |         fontsize += 1 | ||||||
|         font = ImageFont.truetype(font.path, fontsize) |         font = ImageFont.truetype(font.path, fontsize) | ||||||
|         text_height = text_bbox[3] - text_bbox[1] |         text_height = text_bbox[3] | ||||||
|     return font |     return font | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,3 @@ | |||||||
| #!python3 |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| Inkycal Agenda Module | Inkycal Agenda Module | ||||||
| Copyright by aceinnolab | Copyright by aceinnolab | ||||||
| @@ -100,7 +98,7 @@ class Agenda(inkycal_module): | |||||||
|         line_spacing = 1 |         line_spacing = 1 | ||||||
|  |  | ||||||
|         text_bbox_height = self.font.getbbox("hg") |         text_bbox_height = self.font.getbbox("hg") | ||||||
|         line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing |         line_height = text_bbox_height[3] + line_spacing | ||||||
|         line_width = im_width |         line_width = im_width | ||||||
|         max_lines = im_height // line_height |         max_lines = im_height // line_height | ||||||
|         logger.debug(f'max lines: {max_lines}') |         logger.debug(f'max lines: {max_lines}') | ||||||
| @@ -111,9 +109,11 @@ class Agenda(inkycal_module): | |||||||
|  |  | ||||||
|         # Create a list of dates for the next days |         # Create a list of dates for the next days | ||||||
|         agenda_events = [ |         agenda_events = [ | ||||||
|             {'begin': today.shift(days=+_), |             { | ||||||
|  |                 'begin': today.shift(days=+_), | ||||||
|                 'title': today.shift(days=+_).format( |                 'title': today.shift(days=+_).format( | ||||||
|                  self.date_format, locale=self.language)} |                     self.date_format, locale=self.language) | ||||||
|  |             } | ||||||
|             for _ in range(max_lines)] |             for _ in range(max_lines)] | ||||||
|  |  | ||||||
|         # Load icalendar from config |         # Load icalendar from config | ||||||
| @@ -227,7 +227,3 @@ class Agenda(inkycal_module): | |||||||
|  |  | ||||||
|         # return the images ready for the display |         # return the images ready for the display | ||||||
|         return im_black, im_colour |         return im_black, im_colour | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|     print(f'running {__name__} in standalone mode') |  | ||||||
|   | |||||||
| @@ -1,5 +1,3 @@ | |||||||
| #!python3 |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| Inkycal Calendar Module | Inkycal Calendar Module | ||||||
| Copyright by aceinnolab | Copyright by aceinnolab | ||||||
| @@ -267,7 +265,7 @@ class Calendar(inkycal_module): | |||||||
|             # find out how many lines can fit at max in the event section |             # find out how many lines can fit at max in the event section | ||||||
|             line_spacing = 2 |             line_spacing = 2 | ||||||
|             text_bbox_height = self.font.getbbox("hg") |             text_bbox_height = self.font.getbbox("hg") | ||||||
|             line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing |             line_height = text_bbox_height[3] + line_spacing | ||||||
|             max_event_lines = events_height // (line_height + line_spacing) |             max_event_lines = events_height // (line_height + line_spacing) | ||||||
|  |  | ||||||
|             # generate list of coordinates for each line |             # generate list of coordinates for each line | ||||||
| @@ -356,7 +354,7 @@ class Calendar(inkycal_module): | |||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
|                 text_bbox_height = self.font.getbbox("hg") |                 text_bbox_height = self.font.getbbox("hg") | ||||||
|                 line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing |                 line_height = text_bbox_height[3] + line_spacing | ||||||
|  |  | ||||||
|                 event_width_s = im_width - date_width - time_width |                 event_width_s = im_width - date_width - time_width | ||||||
|                 event_width_l = im_width - date_width |                 event_width_l = im_width - date_width | ||||||
| @@ -433,7 +431,3 @@ class Calendar(inkycal_module): | |||||||
|  |  | ||||||
|         # return the images ready for the display |         # return the images ready for the display | ||||||
|         return im_black, im_colour |         return im_black, im_colour | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|     print(f'running {__name__} in standalone mode') |  | ||||||
|   | |||||||
| @@ -1,5 +1,3 @@ | |||||||
| #!python3 |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| Feeds module for InkyCal Project | Feeds module for InkyCal Project | ||||||
| Copyright by aceinnolab | Copyright by aceinnolab | ||||||
| @@ -94,7 +92,7 @@ class Feeds(inkycal_module): | |||||||
|  |  | ||||||
|         line_width = im_width |         line_width = im_width | ||||||
|         text_bbox_height = self.font.getbbox("hg") |         text_bbox_height = self.font.getbbox("hg") | ||||||
|         line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing |         line_height = text_bbox_height[3] + line_spacing | ||||||
|         max_lines = (im_height // (line_height + line_spacing)) |         max_lines = (im_height // (line_height + line_spacing)) | ||||||
|  |  | ||||||
|         # Calculate padding from top so the lines look centralised |         # Calculate padding from top so the lines look centralised | ||||||
| @@ -151,7 +149,3 @@ class Feeds(inkycal_module): | |||||||
|  |  | ||||||
|         # return images |         # return images | ||||||
|         return im_black, im_colour |         return im_black, im_colour | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|     print(f'running {__name__} in standalone/debug mode') |  | ||||||
|   | |||||||
| @@ -1,5 +1,3 @@ | |||||||
| #!python3 |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| iCanHazDadJoke module for InkyCal Project | iCanHazDadJoke module for InkyCal Project | ||||||
| Special thanks to Erik Fredericks (@efredericks) for the template! | Special thanks to Erik Fredericks (@efredericks) for the template! | ||||||
| @@ -56,7 +54,7 @@ class Jokes(inkycal_module): | |||||||
|         # Set some parameters for formatting feeds |         # Set some parameters for formatting feeds | ||||||
|         line_spacing = 5 |         line_spacing = 5 | ||||||
|         text_bbox = self.font.getbbox("hg") |         text_bbox = self.font.getbbox("hg") | ||||||
|         line_height = text_bbox[3] - text_bbox[1] + line_spacing |         line_height = text_bbox[3] + line_spacing | ||||||
|         line_width = im_width |         line_width = im_width | ||||||
|         max_lines = (im_height // (line_height + line_spacing)) |         max_lines = (im_height // (line_height + line_spacing)) | ||||||
|  |  | ||||||
| @@ -98,7 +96,3 @@ class Jokes(inkycal_module): | |||||||
|  |  | ||||||
|         # Return images for black and colour channels |         # Return images for black and colour channels | ||||||
|         return im_black, im_colour |         return im_black, im_colour | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|     print(f'running {__name__} in standalone/debug mode') |  | ||||||
|   | |||||||
| @@ -1,4 +1,3 @@ | |||||||
| #!python3 |  | ||||||
| """ | """ | ||||||
| Textfile module for InkyCal Project | Textfile module for InkyCal Project | ||||||
|  |  | ||||||
| @@ -68,7 +67,7 @@ class TextToDisplay(inkycal_module): | |||||||
|         # Set some parameters for formatting feeds |         # Set some parameters for formatting feeds | ||||||
|         line_spacing = 4 |         line_spacing = 4 | ||||||
|         text_bbox_height = self.font.getbbox("hg") |         text_bbox_height = self.font.getbbox("hg") | ||||||
|         line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing |         line_height = text_bbox_height[3] + line_spacing | ||||||
|         line_width = im_width |         line_width = im_width | ||||||
|         max_lines = im_height // line_height |         max_lines = im_height // line_height | ||||||
|  |  | ||||||
| @@ -110,7 +109,3 @@ class TextToDisplay(inkycal_module): | |||||||
|  |  | ||||||
|         # return images |         # return images | ||||||
|         return im_black, im_colour |         return im_black, im_colour | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|     print(f'running {__name__} in standalone/debug mode') |  | ||||||
|   | |||||||
| @@ -1,5 +1,3 @@ | |||||||
| #!python3 |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| Inkycal Todoist Module | Inkycal Todoist Module | ||||||
| Copyright by aceinnolab | Copyright by aceinnolab | ||||||
| @@ -87,7 +85,7 @@ class Todoist(inkycal_module): | |||||||
|         # Set some parameters for formatting todos |         # Set some parameters for formatting todos | ||||||
|         line_spacing = 1 |         line_spacing = 1 | ||||||
|         text_bbox_height = self.font.getbbox("hg") |         text_bbox_height = self.font.getbbox("hg") | ||||||
|         line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing |         line_height = text_bbox_height[3] + line_spacing | ||||||
|         line_width = im_width |         line_width = im_width | ||||||
|         max_lines = im_height // line_height |         max_lines = im_height // line_height | ||||||
|  |  | ||||||
| @@ -198,7 +196,3 @@ class Todoist(inkycal_module): | |||||||
|  |  | ||||||
|         # return the images ready for the display |         # return the images ready for the display | ||||||
|         return im_black, im_colour |         return im_black, im_colour | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|     print(f'running {__name__} in standalone/debug mode') |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user