From 1f8f2eb8b3f565bcba03a4e40730b40ada7b8b65 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 4 Dec 2020 13:07:03 -0500 Subject: [PATCH] Font size tweaks for low dpi --- piker/ui/_style.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/piker/ui/_style.py b/piker/ui/_style.py index 23a3ac09..3764750a 100644 --- a/piker/ui/_style.py +++ b/piker/ui/_style.py @@ -18,6 +18,7 @@ Qt UI styling. """ from typing import Optional +import math import pyqtgraph as pg from PyQt5 import QtCore, QtGui @@ -27,10 +28,9 @@ from ..log import get_logger log = get_logger(__name__) -# chart-wide font -# font size 6px / 53 dpi (3x scaled down on 4k hidpi) -_default_font_inches_we_like = 6 / 53 # px / (px / inch) = inch -_down_2_font_inches_we_like = 4 / 53 +# chart-wide fonts specified in inches +_default_font_inches_we_like = 0.0666 +_down_2_font_inches_we_like = 6 / 96 class DpiAwareFont: @@ -66,8 +66,12 @@ class DpiAwareFont: listed in the script in ``snippets/qt_screen_info.py``. """ - dpi = screen.physicalDotsPerInch() - font_size = round(self._iwl * dpi) + # take the max since scaling can make things ugly in some cases + pdpi = screen.physicalDotsPerInch() + ldpi = screen.logicalDotsPerInch() + dpi = max(pdpi, ldpi) + + font_size = math.floor(self._iwl * dpi) log.info( f"\nscreen:{screen.name()} with DPI: {dpi}" f"\nbest font size is {font_size}\n"