mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py310 compat: QWebEngineSettings::setFontSize
Fixes #1954688 [--pdf-default-font-size is read as float](https://bugs.launchpad.net/calibre/+bug/1954688)
This commit is contained in:
parent
643de95a64
commit
842e99428e
@ -69,10 +69,10 @@ class PDFOutput(OutputFormatPlugin):
|
|||||||
'The font family used to render monospace fonts')),
|
'The font family used to render monospace fonts')),
|
||||||
OptionRecommendation(name='pdf_default_font_size',
|
OptionRecommendation(name='pdf_default_font_size',
|
||||||
recommended_value=20, help=_(
|
recommended_value=20, help=_(
|
||||||
'The default font size')),
|
'The default font size (in pixels)')),
|
||||||
OptionRecommendation(name='pdf_mono_font_size',
|
OptionRecommendation(name='pdf_mono_font_size',
|
||||||
recommended_value=16, help=_(
|
recommended_value=16, help=_(
|
||||||
'The default font size for monospaced text')),
|
'The default font size for monospaced text (in pixels)')),
|
||||||
OptionRecommendation(name='pdf_hyphenate', recommended_value=False,
|
OptionRecommendation(name='pdf_hyphenate', recommended_value=False,
|
||||||
help=_('Break long words at the end of lines. This can give the text at the right margin a more even appearance.'
|
help=_('Break long words at the end of lines. This can give the text at the right margin a more even appearance.'
|
||||||
' Note that depending on the fonts used this option can break the copying of text from the PDF file.')),
|
' Note that depending on the fonts used this option can break the copying of text from the PDF file.')),
|
||||||
|
@ -152,8 +152,8 @@ class Renderer(QWebEnginePage):
|
|||||||
self.wait_for_title = None
|
self.wait_for_title = None
|
||||||
s = self.settings()
|
s = self.settings()
|
||||||
s.setAttribute(s.JavascriptEnabled, True)
|
s.setAttribute(s.JavascriptEnabled, True)
|
||||||
s.setFontSize(s.DefaultFontSize, opts.pdf_default_font_size)
|
s.setFontSize(s.DefaultFontSize, int(opts.pdf_default_font_size))
|
||||||
s.setFontSize(s.DefaultFixedFontSize, opts.pdf_mono_font_size)
|
s.setFontSize(s.DefaultFixedFontSize, int(opts.pdf_mono_font_size))
|
||||||
s.setFontSize(s.MinimumLogicalFontSize, 8)
|
s.setFontSize(s.MinimumLogicalFontSize, 8)
|
||||||
s.setFontSize(s.MinimumFontSize, 8)
|
s.setFontSize(s.MinimumFontSize, 8)
|
||||||
std = {
|
std = {
|
||||||
|
@ -763,10 +763,10 @@ class Preview(QWidget):
|
|||||||
|
|
||||||
def apply_settings(self):
|
def apply_settings(self):
|
||||||
s = self.view.settings()
|
s = self.view.settings()
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.DefaultFontSize, tprefs['preview_base_font_size'])
|
s.setFontSize(QWebEngineSettings.FontSize.DefaultFontSize, int(tprefs['preview_base_font_size']))
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.DefaultFixedFontSize, tprefs['preview_mono_font_size'])
|
s.setFontSize(QWebEngineSettings.FontSize.DefaultFixedFontSize, int(tprefs['preview_mono_font_size']))
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.MinimumLogicalFontSize, tprefs['preview_minimum_font_size'])
|
s.setFontSize(QWebEngineSettings.FontSize.MinimumLogicalFontSize, int(tprefs['preview_minimum_font_size']))
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.MinimumFontSize, tprefs['preview_minimum_font_size'])
|
s.setFontSize(QWebEngineSettings.FontSize.MinimumFontSize, int(tprefs['preview_minimum_font_size']))
|
||||||
sf, ssf, mf = tprefs['engine_preview_serif_family'], tprefs['engine_preview_sans_family'], tprefs['engine_preview_mono_family']
|
sf, ssf, mf = tprefs['engine_preview_serif_family'], tprefs['engine_preview_sans_family'], tprefs['engine_preview_mono_family']
|
||||||
if sf:
|
if sf:
|
||||||
s.setFontFamily(QWebEngineSettings.FontFamily.SerifFont, sf)
|
s.setFontFamily(QWebEngineSettings.FontFamily.SerifFont, sf)
|
||||||
|
@ -322,10 +322,10 @@ def apply_font_settings(page_or_view):
|
|||||||
if mfs is None:
|
if mfs is None:
|
||||||
s.resetFontSize(QWebEngineSettings.FontSize.MinimumFontSize)
|
s.resetFontSize(QWebEngineSettings.FontSize.MinimumFontSize)
|
||||||
else:
|
else:
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.MinimumFontSize, mfs)
|
s.setFontSize(QWebEngineSettings.FontSize.MinimumFontSize, int(mfs))
|
||||||
bfs = sd.get('base_font_size')
|
bfs = sd.get('base_font_size')
|
||||||
if bfs is not None:
|
if bfs is not None:
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.DefaultFontSize, bfs)
|
s.setFontSize(QWebEngineSettings.FontSize.DefaultFontSize, int(bfs))
|
||||||
s.setFontSize(QWebEngineSettings.FontSize.DefaultFixedFontSize, int(bfs * 13 / 16))
|
s.setFontSize(QWebEngineSettings.FontSize.DefaultFixedFontSize, int(bfs * 13 / 16))
|
||||||
|
|
||||||
font_size_changed = (old_minimum, old_base, old_fixed_base) != (
|
font_size_changed = (old_minimum, old_base, old_fixed_base) != (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user