E-book viewer: Fix auto hyphenation on macOS not rendering the hyphens correctly. Fixes #1954714 [Ebook viewer: Breaking long words at the ends of lines causing boxes to be rendered instead of hyphens on macOS](https://bugs.launchpad.net/calibre/+bug/1954714)

This commit is contained in:
Kovid Goyal 2022-01-07 10:57:25 +05:30
parent 141ff585c9
commit cc96900aee
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,7 @@
// is U+2010 but that does not render with the default Times font on macOS as of Monterey // 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 // 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 // by converting a plain text file with the --pdf-hyphenate option
// See also settings.pyj
if (HYPHEN_CHAR) { if (HYPHEN_CHAR) {
for (const elem of document.getElementsByTagName('*')) { for (const elem of document.getElementsByTagName('*')) {
if (elem.style) { if (elem.style) {

View File

@ -74,6 +74,13 @@ def apply_colors(is_content_popup):
ss = E.style(id=styles_id, type='text/css') ss = E.style(id=styles_id, type='text/css')
document.documentElement.appendChild(ss) document.documentElement.appendChild(ss)
text = '' text = ''
if runtime.is_standalone_viewer and 'macos' in window.navigator.userAgent:
# 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
# See also pdf-preprint.js
text += '\n* { -webkit-hyphenate-character: "-" !important }\n'
if opts.override_book_colors is not 'never': if opts.override_book_colors is not 'never':
text = 'body' text = 'body'
if opts.override_book_colors is 'dark': if opts.override_book_colors is 'dark':