From 36aaece8466e8b4f0adbbc18e786f2959ec2db72 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 18 Sep 2021 16:53:31 -0400 Subject: [PATCH] screen: Put font size setting into KlippyGtk --- ks_includes/KlippyGtk.py | 6 +++++- panels/base_panel.py | 2 +- screen.py | 12 +++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index efe2a731..883ab147 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -15,7 +15,7 @@ class KlippyGtk: width_ratio = 16 height_ratio = 9.375 - def __init__(self, screen, width, height, theme, cursor): + def __init__(self, screen, width, height, theme, cursor, fontsize_type): self.screen = screen self.width = width self.height = height @@ -24,6 +24,10 @@ class KlippyGtk: self.width / self.font_ratio[0], self.height / self.font_ratio[1] )) + if fontsize_type == "small": + self.font_size = round(self.font_size * 0.91) + elif (fontsize_type == "large"): + self.font_size = round(self.font_size * 1.09) self.header_size = int(round((self.width / self.width_ratio) / 1.33)) self.img_width = int(round(self.width / self.width_ratio)) self.img_height = int(round(self.height / self.height_ratio)) diff --git a/panels/base_panel.py b/panels/base_panel.py index 16f278e7..fbe8d2b2 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -17,7 +17,7 @@ class BasePanel(ScreenPanel): self.current_panel = None self.time_min = -1 self.time_format = self._config.get_main_config_option("24htime") - self.title_spacing = self._screen.font_size * 2 + self.title_spacing = self._gtk.font_size * 2 self.buttons_showing = { 'back': False if back else True, diff --git a/screen.py b/screen.py index 9348fbba..81950d45 100644 --- a/screen.py +++ b/screen.py @@ -123,7 +123,8 @@ class KlipperScreen(Gtk.Window): self.theme = self._config.get_main_config_option('theme') self.gtk = KlippyGtk(self, self.width, self.height, self.theme, - self._config.get_main_config().getboolean("show_cursor", fallback=False)) + self._config.get_main_config().getboolean("show_cursor", fallback=False), + self._config.get_main_config_option("font_size", "medium")) self.keyboard_height = self.gtk.get_keyboard_height() self.init_style() @@ -440,14 +441,7 @@ class KlipperScreen(Gtk.Window): css_data = css_base_data + css.read() css.close() - self.font_size = self.gtk.get_font_size() - fontsize_type = self._config.get_main_config_option("font_size", "medium") - if fontsize_type != "medium": - if fontsize_type == "small": - self.font_size = round(self.font_size * 0.91) - elif (fontsize_type == "large"): - self.font_size = round(self.font_size * 1.09) - css_data = css_data.replace("KS_FONT_SIZE", str(self.font_size)) + css_data = css_data.replace("KS_FONT_SIZE", str(self.gtk.get_font_size())) style_provider = Gtk.CssProvider() style_provider.load_from_data(css_data.encode())