From 8359015dc690a6f9b655c55b3f30eb4c7d9aa776 Mon Sep 17 00:00:00 2001 From: Vitali Samurov Date: Fri, 31 Jan 2020 02:23:06 +0200 Subject: [PATCH] Font sizes have been moved in to config file --- modules/inkycal_agenda.py | 3 +-- modules/inkycal_calendar.py | 3 +-- modules/inkycal_rss.py | 4 +--- settings/configuration.py | 21 ++++++++++++++------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/inkycal_agenda.py b/modules/inkycal_agenda.py index 747f88e..e362b3d 100644 --- a/modules/inkycal_agenda.py +++ b/modules/inkycal_agenda.py @@ -8,7 +8,6 @@ from __future__ import print_function from inkycal_icalendar import fetch_events from configuration import* -fontsize = 14 show_events = True print_events = False style = 'D MMM YY HH:mm' @@ -19,7 +18,7 @@ border_top = int(middle_section_height * 0.02) border_left = int(middle_section_width * 0.02) """Choose font optimised for the agenda section""" -font = ImageFont.truetype(NotoSans+'Medium.ttf', fontsize) +font = ImageFont.truetype(NotoSans+'Medium.ttf', agenda_font_size) line_height = int(font.getsize('hg')[1] * 1.2) + 1 line_width = int(middle_section_width - (border_left*2)) diff --git a/modules/inkycal_calendar.py b/modules/inkycal_calendar.py index 8f79da3..ce5284c 100644 --- a/modules/inkycal_calendar.py +++ b/modules/inkycal_calendar.py @@ -16,8 +16,7 @@ at_in_your_language = 'at' event_icon = 'square' # dot #square style = "DD MMM" -fontsize = 16 -font = ImageFont.truetype(NotoSans+'.ttf', fontsize) +font = ImageFont.truetype(NotoSans+'.ttf', calendar_font_size) space_between_lines = 0 if show_events == True: diff --git a/modules/inkycal_rss.py b/modules/inkycal_rss.py index c3ae165..8c4ce4b 100644 --- a/modules/inkycal_rss.py +++ b/modules/inkycal_rss.py @@ -9,14 +9,12 @@ import feedparser from random import shuffle from configuration import * -fontsize = 14 - """Add a border to increase readability""" border_top = int(bottom_section_height * 0.05) border_left = int(bottom_section_width * 0.02) """Choose font optimised for the weather section""" -font = ImageFont.truetype(NotoSans+'.ttf', fontsize) +font = ImageFont.truetype(NotoSans+'.ttf', rss_font_size) space_between_lines = 1 line_height = font.getsize('hg')[1] + space_between_lines line_width = bottom_section_width - (border_left*2) diff --git a/settings/configuration.py b/settings/configuration.py index 7eb5a11..8daa9a1 100644 --- a/settings/configuration.py +++ b/settings/configuration.py @@ -60,17 +60,24 @@ NotoSansCJK = fontpath+'NotoSansCJK/NotoSansCJKsc-' NotoSans = fontpath+'NotoSans/NotoSans-SemiCondensed' weatherfont = fontpath+'WeatherFont/weathericons-regular-webfont.ttf' +"""Fonts sizes""" +agenda_font_size = 14 +calendar_font_size = 16 +rss_font_size = 14 +locales_font_size = 18 +weather_font_size = 12 + """Automatically select correct fonts to support set language""" if language in ['ja','zh','zh_tw','ko']: - default = ImageFont.truetype(NotoSansCJK+'Regular.otf', 18) - semi = ImageFont.truetype(NotoSansCJK+'Medium.otf', 18) - bold = ImageFont.truetype(NotoSansCJK+'Bold.otf', 18) + default = ImageFont.truetype(NotoSansCJK+'Regular.otf', locales_font_size) + semi = ImageFont.truetype(NotoSansCJK+'Medium.otf', locales_font_size) + bold = ImageFont.truetype(NotoSansCJK+'Bold.otf', locales_font_size) else: - default = ImageFont.truetype(NotoSans+'.ttf', 18) - semi = ImageFont.truetype(NotoSans+'Medium.ttf', 18) - bold = ImageFont.truetype(NotoSans+'SemiBold.ttf', 18) + default = ImageFont.truetype(NotoSans+'.ttf', locales_font_size) + semi = ImageFont.truetype(NotoSans+'Medium.ttf', locales_font_size) + bold = ImageFont.truetype(NotoSans+'SemiBold.ttf', locales_font_size) -w_font = ImageFont.truetype(weatherfont, 10) +w_font = ImageFont.truetype(weatherfont, weather_font_size) """Create image with given parameters""" image = Image.new('RGB', (display_width, display_height), background_colour)