diff --git a/src/calibre/ebooks/conversion/plugins/pdf_output.py b/src/calibre/ebooks/conversion/plugins/pdf_output.py index 4ff6480a1b..9f35284f28 100644 --- a/src/calibre/ebooks/conversion/plugins/pdf_output.py +++ b/src/calibre/ebooks/conversion/plugins/pdf_output.py @@ -56,14 +56,14 @@ class PDFOutput(OutputFormatPlugin): ' of stretching it to fill the full first page of the' ' generated pdf.')), OptionRecommendation(name='pdf_serif_family', - recommended_value='Liberation Serif', help=_( - 'The font family used to render serif fonts')), + recommended_value='Times', help=_( + 'The font family used to render serif fonts. Will work only if the font is available system-wide.')), OptionRecommendation(name='pdf_sans_family', - recommended_value='Liberation Sans', help=_( - 'The font family used to render sans-serif fonts')), + recommended_value='Helvetica', help=_( + 'The font family used to render sans-serif fonts. Will work only if the font is available system-wide.')), OptionRecommendation(name='pdf_mono_family', - recommended_value='Liberation Mono', help=_( - 'The font family used to render monospace fonts')), + recommended_value='Courier', help=_( + 'The font family used to render monospace fonts. Will work only if the font is available system-wide.')), OptionRecommendation(name='pdf_standard_font', choices=ui_data['font_types'], recommended_value='serif', help=_( 'The font family used to render monospace fonts')), @@ -134,14 +134,13 @@ class PDFOutput(OutputFormatPlugin): # that hopefully no Qt application has been constructed as yet from PyQt5.QtWebEngineCore import QWebEngineUrlScheme from PyQt5.QtWebEngineWidgets import QWebEnginePage # noqa - from calibre.gui2 import must_use_qt, load_builtin_fonts + from calibre.gui2 import must_use_qt from calibre.constants import FAKE_PROTOCOL scheme = QWebEngineUrlScheme(FAKE_PROTOCOL.encode('ascii')) scheme.setSyntax(QWebEngineUrlScheme.Syntax.Host) scheme.setFlags(QWebEngineUrlScheme.SecureScheme) QWebEngineUrlScheme.registerScheme(scheme) must_use_qt() - load_builtin_fonts() self.input_fmt = input_fmt if opts.pdf_use_document_margins: diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 47127936eb..726e711107 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -747,22 +747,22 @@ class Translator(QTranslator): gui_thread = None - qt_app = None -builtin_fonts_loaded = False + +def calibre_font_files(): + return glob.glob(P('fonts/liberation/*.?tf')) + [P('fonts/calibreSymbols.otf')] + \ + glob.glob(os.path.join(config_dir, 'fonts', '*.?tf')) def load_builtin_fonts(): global _rating_font, builtin_fonts_loaded # Load the builtin fonts and any fonts added to calibre by the user to # Qt - if builtin_fonts_loaded: + if hasattr(load_builtin_fonts, 'done'): return - builtin_fonts_loaded = True - for ff in glob.glob(P('fonts/liberation/*.?tf')) + \ - [P('fonts/calibreSymbols.otf')] + \ - glob.glob(os.path.join(config_dir, 'fonts', '*.?tf')): + load_builtin_fonts.done = True + for ff in calibre_font_files(): if ff.rpartition('.')[-1].lower() in {'ttf', 'otf'}: with open(ff, 'rb') as s: # Windows requires font files to be executable for them to be