From 0e2c29d2e3a3bbc9c3ed47a3cea09bda8f211b08 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Nov 2021 11:05:29 +0530 Subject: [PATCH] PDF Output: Fix the option to break long words at the ends of lines causing boxes to be rendered at the end fo the line on macOS with some fonts. Fixes #1951467 [Private bug](https://bugs.launchpad.net/calibre/+bug/1951467) --- resources/pdf-preprint.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/pdf-preprint.js b/resources/pdf-preprint.js index a78aec270c..7a2c72de56 100644 --- a/resources/pdf-preprint.js +++ b/resources/pdf-preprint.js @@ -31,7 +31,15 @@ if (is_block) avoid_page_breaks_inside(img); else if (img.parentNode && img.parentNode.childElementCount === 1) avoid_page_breaks_inside(img.parentNode); } - + // Change the hyphenate character to a plain ASCII minus (U+002d) the default + // 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'); + } + } })();