From 3bcf55d57135651b713f785d1c7a171e89a13272 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Jan 2020 10:45:37 +0530 Subject: [PATCH] macOS: Fix viewer controls not using system UI font --- resources/content-server/reset.css | 20 ++++++++++++++------ src/calibre/gui2/viewer/web_view.py | 5 ++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/resources/content-server/reset.css b/resources/content-server/reset.css index 3ce8df8084..57ace129ee 100644 --- a/resources/content-server/reset.css +++ b/resources/content-server/reset.css @@ -1,8 +1,17 @@ -/* +/* * Reset CSS to suppress cross-browser differences */ -html, body, div, span, object, iframe, +html, body { + margin:0; + padding:0; + border:0; + outline:0; + vertical-align:baseline; + background:transparent; +} + +div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, @@ -11,7 +20,7 @@ b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, figcaption, figure, +article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video { margin:0; @@ -25,11 +34,10 @@ time, mark, audio, video { body { line-height:1.2; - font-family:sans-serif; } article,aside,details,figcaption,figure, -footer,header,hgroup,menu,nav,section { +footer,header,hgroup,menu,nav,section { display:block; } @@ -69,7 +77,7 @@ table { hr { display:block; height:1px; - border:0; + border:0; border-top:1px solid currentColor; margin:1em 0; padding:0; diff --git a/src/calibre/gui2/viewer/web_view.py b/src/calibre/gui2/viewer/web_view.py index 66ec449a6c..eb1868cccf 100644 --- a/src/calibre/gui2/viewer/web_view.py +++ b/src/calibre/gui2/viewer/web_view.py @@ -535,9 +535,12 @@ class WebView(RestartingWebEngineView): def on_bridge_ready(self): f = QApplication.instance().font() fi = QFontInfo(f) + family = f.family() + if family in ('.AppleSystemUIFont', 'MS Shell Dlg 2'): + family = 'system-ui' ui_data = { 'all_font_families': QFontDatabase().families(), - 'ui_font_family': f.family(), + 'ui_font_family': family, 'ui_font_sz': '{}px'.format(fi.pixelSize()), 'show_home_page_on_ready': self.show_home_page_on_ready, 'system_colors': system_colors(),