remove lodpi hack, don't assume physical DPI is always 72
This commit is contained in:
parent
3840f012be
commit
33c5b5f9e7
@ -223,8 +223,6 @@ def parseArgs(argv):
|
||||
parser.add_option("-b", "--base", help="path to base folder")
|
||||
parser.add_option("-p", "--profile", help="profile name to load")
|
||||
parser.add_option("-l", "--lang", help="interface language (en, de, etc)")
|
||||
parser.add_option("--lodpi", action="store_true", dest="lodpi",
|
||||
help="disable Qt's high DPI support")
|
||||
return parser.parse_args(argv[1:])
|
||||
|
||||
def run():
|
||||
@ -261,8 +259,7 @@ def _run(argv=None, exec=True):
|
||||
ctypes.CDLL('libGL.so.1', ctypes.RTLD_GLOBAL)
|
||||
|
||||
# opt in to full hidpi support
|
||||
if not opts.lodpi:
|
||||
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
||||
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
||||
|
||||
# create the app
|
||||
app = AnkiApp(argv)
|
||||
|
@ -160,20 +160,33 @@ class AnkiWebView(QWebEngineView):
|
||||
from aqt import mw
|
||||
if isMac:
|
||||
return 1
|
||||
if isWin and mw.opts.lodpi:
|
||||
return 1
|
||||
screen = QApplication.desktop().screen()
|
||||
dpi = screen.logicalDpiX()
|
||||
factor = dpi / 96.0
|
||||
if isLin:
|
||||
factor = max(1, factor)
|
||||
return factor
|
||||
# compensate for qt's integer scaling
|
||||
# on windows
|
||||
qtIntScale = 72/screen.physicalDpiX()
|
||||
# compensate for qt's integer scaling on windows
|
||||
qtIntScale = self._getQtIntScale(screen)
|
||||
desiredScale = factor * qtIntScale
|
||||
newFactor = desiredScale / qtIntScale
|
||||
return newFactor
|
||||
return max(1, newFactor)
|
||||
|
||||
def _getQtIntScale(self, screen):
|
||||
# try to detect if Qt has scaled the screen
|
||||
# - qt will round the scale factor to a whole number, so a dpi of 125% = 1x,
|
||||
# and a dpi of 150% = 2x
|
||||
# - a screen with a normal physical dpi of 72 will have a dpi of 32
|
||||
# if the scale factor has been rounded to 2x
|
||||
# - different screens have different physical DPIs (eg 72, 93, 102)
|
||||
# - until a better solution presents itself, assume a physical DPI at
|
||||
# or above 70 is unscaled
|
||||
if screen.physicalDpiX() > 70:
|
||||
return 1
|
||||
elif screen.physicalDpiX() > 35:
|
||||
return 2
|
||||
else:
|
||||
return 3
|
||||
|
||||
def stdHtml(self, body, css=[], js=["jquery.js"], head=""):
|
||||
if isWin:
|
||||
|
Loading…
Reference in New Issue
Block a user