diff --git a/resources/pdf-preprint.js b/resources/pdf-preprint.js index 7a2c72de56..4035fef675 100644 --- a/resources/pdf-preprint.js +++ b/resources/pdf-preprint.js @@ -35,9 +35,11 @@ // is U+2010 but that does not render with the default Times font on macOS as of Monterey // and Qt 15.5 See https://bugs.launchpad.net/bugs/1951467 and can be easily reproduced // by converting a plain text file with the --pdf-hyphenate option - for (const elem of document.getElementsByTagName('*')) { - if (elem.style) { - elem.style.setProperty('-webkit-hyphenate-character', '"-"', 'important'); + if (HYPHEN_CHAR) { + for (const elem of document.getElementsByTagName('*')) { + if (elem.style) { + elem.style.setProperty('-webkit-hyphenate-character', '"-"', 'important'); + } } } })(); diff --git a/src/calibre/ebooks/pdf/html_writer.py b/src/calibre/ebooks/pdf/html_writer.py index 2f82f75199..1ac5acfbae 100644 --- a/src/calibre/ebooks/pdf/html_writer.py +++ b/src/calibre/ebooks/pdf/html_writer.py @@ -22,7 +22,7 @@ from qt.webengine import ( ) from calibre import detect_ncpus, human_readable, prepare_string_for_xml -from calibre.constants import __version__, iswindows +from calibre.constants import __version__, iswindows, ismacos from calibre.ebooks.metadata.xmp import metadata_to_xmp_packet from calibre.ebooks.oeb.base import XHTML, XPath from calibre.ebooks.oeb.polish.container import Container as ContainerBase @@ -63,7 +63,7 @@ def data_as_pdf_doc(data): def preprint_js(): ans = getattr(preprint_js, 'ans', None) if ans is None: - ans = preprint_js.ans = P('pdf-preprint.js', data=True).decode('utf-8') + ans = preprint_js.ans = P('pdf-preprint.js', data=True).decode('utf-8').replace('HYPHEN_CHAR', 'true' if ismacos else 'false', 1) return ans