mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure font family used in comment viewer/editor is the same as for the rest of the application
This commit is contained in:
parent
9cf35e275f
commit
b9927abdae
@ -38,14 +38,23 @@ def render_html(mi, css, vertical, widget, all_fields=False): # {{{
|
||||
ans = unicode(col.name())
|
||||
return ans
|
||||
|
||||
f = QFontInfo(QApplication.font(widget)).pixelSize()
|
||||
fi = QFontInfo(QApplication.font(widget))
|
||||
f = fi.pixelSize()+1
|
||||
fam = unicode(fi.family()).strip()
|
||||
if not fam:
|
||||
fam = 'sans-serif'
|
||||
c = color_to_string(QApplication.palette().color(QPalette.Normal,
|
||||
QPalette.WindowText))
|
||||
templ = u'''\
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body, td {background-color: transparent; font-size: %dpx; color: %s }
|
||||
body, td {
|
||||
background-color: transparent;
|
||||
font-size: %dpx;
|
||||
font-family: "%s",sans-serif;
|
||||
color: %s
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
%s
|
||||
@ -55,7 +64,7 @@ def render_html(mi, css, vertical, widget, all_fields=False): # {{{
|
||||
%%s
|
||||
</body>
|
||||
<html>
|
||||
'''%(f, c, css)
|
||||
'''%(f, fam, c, css)
|
||||
fm = getattr(mi, 'field_metadata', field_metadata)
|
||||
fl = dict(get_field_list(fm))
|
||||
show_comments = (all_fields or fl.get('comments', True))
|
||||
|
@ -251,8 +251,12 @@ class EditorWidget(QWebView): # {{{
|
||||
|
||||
def fset(self, val):
|
||||
self.setHtml(val)
|
||||
f = QFontInfo(QApplication.font(self)).pixelSize()
|
||||
style = 'font-size: %dpx;' % (f,)
|
||||
fi = QFontInfo(QApplication.font(self))
|
||||
f = fi.pixelSize()+1
|
||||
fam = unicode(fi.family()).strip()
|
||||
if not fam:
|
||||
fam = 'sans-serif'
|
||||
style = 'font-size: %fpx; font-family:"%s",sans-serif;' % (f, fam)
|
||||
|
||||
# toList() is needed because PyQt on Debian is old/broken
|
||||
for body in self.page().mainFrame().documentElement().findAll('body').toList():
|
||||
|
Loading…
x
Reference in New Issue
Block a user