From d660376206977f5a578d66f1d5ac588c04f9b054 Mon Sep 17 00:00:00 2001 From: Ebisu Date: Mon, 19 Jun 2023 00:10:37 +0200 Subject: [PATCH] get font style from main config --- piker/ui/_style.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/piker/ui/_style.py b/piker/ui/_style.py index 67f14a93..8c683ad5 100644 --- a/piker/ui/_style.py +++ b/piker/ui/_style.py @@ -28,6 +28,8 @@ from qdarkstyle import DarkPalette from ..log import get_logger +from .. import config + log = get_logger(__name__) _magic_inches = 0.0666 * (1 + 6/16) @@ -49,11 +51,25 @@ class DpiAwareFont: def __init__( self, - # TODO: move to config name: str = 'Hack', font_size: str = 'default', ) -> None: + self._custom_ui = False + # Read preferred font size from main config file if it exists + conf, path = config.load('conf', touch_if_dne=True) + ui_section = conf.get('ui') + if ui_section: + self._custom_ui = True + + font_size = ui_section.get('font_size') + if not font_size: + font_size = 'default' + + name = ui_section.get('name') + if not name: + name = 'Hack' + self.name = name self._qfont = QtGui.QFont(name) self._font_size: str = font_size @@ -99,6 +115,10 @@ class DpiAwareFont: listed in the script in ``snippets/qt_screen_info.py``. ''' + if self._custom_ui: + self._set_qfont_px_size(self._font_size) + return + if screen is None: screen = self.screen