Only use the ascii hyphen on macOS since it is only needed there

This commit is contained in:
Kovid Goyal 2021-11-19 11:12:07 +05:30
parent 0e2c29d2e3
commit dec5cb9d20
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 5 deletions

View File

@ -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');
}
}
}
})();

View File

@ -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