mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 18:43:35 +02:00
Set UI font size for viewer in pixels
Seems to match the actual font size in the main UI better on Linux with both hidpi on and off.
This commit is contained in:
parent
c60dbbda8f
commit
c2e1e00f09
2 changed files with 6 additions and 5 deletions
|
|
@ -9,8 +9,8 @@
|
|||
from itertools import count
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QApplication, QBuffer, QByteArray, QFontDatabase, QHBoxLayout, QSize, Qt, QTimer,
|
||||
QUrl, QWidget, pyqtSignal
|
||||
QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QHBoxLayout, QSize,
|
||||
Qt, QTimer, QUrl, QWidget, pyqtSignal
|
||||
)
|
||||
from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler
|
||||
from PyQt5.QtWebEngineWidgets import (
|
||||
|
|
@ -427,9 +427,10 @@ def bridge(self):
|
|||
|
||||
def on_bridge_ready(self):
|
||||
f = QApplication.instance().font()
|
||||
fi = QFontInfo(f)
|
||||
self.bridge.create_view(
|
||||
vprefs['session_data'], QFontDatabase().families(), field_metadata.all_metadata(),
|
||||
f.family(), f.pointSize())
|
||||
f.family(), '{}px'.format(fi.pixelSize()))
|
||||
for func, args in iteritems(self.pending_bridge_ready_actions):
|
||||
getattr(self.bridge, func)(*args)
|
||||
|
||||
|
|
|
|||
|
|
@ -188,12 +188,12 @@ def create_session_data(prefs):
|
|||
|
||||
|
||||
@from_python
|
||||
def create_view(prefs, all_font_families, field_metadata, ui_font_family, ui_font_sz_in_pts):
|
||||
def create_view(prefs, all_font_families, field_metadata, ui_font_family, ui_font_sz):
|
||||
nonlocal view
|
||||
runtime.all_font_families = all_font_families
|
||||
library_data.field_metadata = field_metadata
|
||||
document.documentElement.style.fontFamily = f'"{ui_font_family}", sans-serif'
|
||||
document.documentElement.style.fontSize = f'{ui_font_sz_in_pts}pt'
|
||||
document.documentElement.style.fontSize = ui_font_sz
|
||||
if view is None:
|
||||
create_session_data(prefs)
|
||||
view = View(document.getElementById('view'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue