If the DE (like windohz) already scales DPI, just use that scale for font size
parent
fc3c0741b8
commit
a0034e2948
|
@ -22,6 +22,7 @@ import math
|
||||||
|
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
from PyQt5 import QtCore, QtGui
|
from PyQt5 import QtCore, QtGui
|
||||||
|
from PyQt5.QtCore import Qt, QCoreApplication
|
||||||
from qdarkstyle import DarkPalette
|
from qdarkstyle import DarkPalette
|
||||||
|
|
||||||
from ..log import get_logger
|
from ..log import get_logger
|
||||||
|
@ -121,19 +122,29 @@ class DpiAwareFont:
|
||||||
dpi = mn_dpi
|
dpi = mn_dpi
|
||||||
|
|
||||||
mult = 1.0
|
mult = 1.0
|
||||||
# dpi is likely somewhat scaled down so use slightly larger font size
|
|
||||||
if scale >= 1.1 and self._font_size:
|
|
||||||
|
|
||||||
# no idea why
|
if (
|
||||||
if 1.2 <= scale:
|
hasattr(Qt, 'AA_EnableHighDpiScaling')
|
||||||
mult = 1.0375
|
and QCoreApplication.testAttribute(Qt.AA_EnableHighDpiScaling)
|
||||||
|
):
|
||||||
|
inches *= scale
|
||||||
|
|
||||||
if scale >= 1.5:
|
# No implicit DPI scaling was done by the DE so let's engage
|
||||||
mult = 1.375
|
# some hackery ad-hoc scaling shiat.
|
||||||
|
else:
|
||||||
|
# dpi is likely somewhat scaled down so use slightly larger font size
|
||||||
|
if scale >= 1.1 and self._font_size:
|
||||||
|
|
||||||
# TODO: this multiplier should probably be determined from
|
# no idea why
|
||||||
# relative aspect ratios or something?
|
if 1.2 <= scale:
|
||||||
inches *= mult
|
mult = 1.0375
|
||||||
|
|
||||||
|
if scale >= 1.5:
|
||||||
|
mult = 1.375
|
||||||
|
|
||||||
|
# TODO: this multiplier should probably be determined from
|
||||||
|
# relative aspect ratios or something?
|
||||||
|
inches *= mult
|
||||||
|
|
||||||
# TODO: we might want to fiddle with incrementing font size by
|
# TODO: we might want to fiddle with incrementing font size by
|
||||||
# +1 for the edge cases above. it seems doing it via scaling is
|
# +1 for the edge cases above. it seems doing it via scaling is
|
||||||
|
@ -142,7 +153,7 @@ class DpiAwareFont:
|
||||||
self._font_inches = inches
|
self._font_inches = inches
|
||||||
font_size = math.floor(inches * dpi)
|
font_size = math.floor(inches * dpi)
|
||||||
|
|
||||||
log.debug(
|
log.info(
|
||||||
f"screen:{screen.name()}\n"
|
f"screen:{screen.name()}\n"
|
||||||
f"pDPI: {pdpi}, lDPI: {ldpi}, scale: {scale}\n"
|
f"pDPI: {pdpi}, lDPI: {ldpi}, scale: {scale}\n"
|
||||||
f"\nOur best guess font size is {font_size}\n"
|
f"\nOur best guess font size is {font_size}\n"
|
||||||
|
|
Loading…
Reference in New Issue