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())
|
ans = unicode(col.name())
|
||||||
return ans
|
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,
|
c = color_to_string(QApplication.palette().color(QPalette.Normal,
|
||||||
QPalette.WindowText))
|
QPalette.WindowText))
|
||||||
templ = u'''\
|
templ = u'''\
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<style type="text/css">
|
<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>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
%s
|
%s
|
||||||
@ -55,7 +64,7 @@ def render_html(mi, css, vertical, widget, all_fields=False): # {{{
|
|||||||
%%s
|
%%s
|
||||||
</body>
|
</body>
|
||||||
<html>
|
<html>
|
||||||
'''%(f, c, css)
|
'''%(f, fam, c, css)
|
||||||
fm = getattr(mi, 'field_metadata', field_metadata)
|
fm = getattr(mi, 'field_metadata', field_metadata)
|
||||||
fl = dict(get_field_list(fm))
|
fl = dict(get_field_list(fm))
|
||||||
show_comments = (all_fields or fl.get('comments', True))
|
show_comments = (all_fields or fl.get('comments', True))
|
||||||
|
@ -251,8 +251,12 @@ class EditorWidget(QWebView): # {{{
|
|||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setHtml(val)
|
self.setHtml(val)
|
||||||
f = QFontInfo(QApplication.font(self)).pixelSize()
|
fi = QFontInfo(QApplication.font(self))
|
||||||
style = 'font-size: %dpx;' % (f,)
|
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
|
# toList() is needed because PyQt on Debian is old/broken
|
||||||
for body in self.page().mainFrame().documentElement().findAll('body').toList():
|
for body in self.page().mainFrame().documentElement().findAll('body').toList():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user