Edit book: Preview panel: Fix hyphenation at end of line being rendered as boxes on macOS. Fixes #1958730 [Ebook editor: Breaking long words at the ends of lines causing boxes to be rendered instead of hyphens on macOS](https://bugs.launchpad.net/calibre/+bug/1958730)

This commit is contained in:
Kovid Goyal 2022-01-23 11:44:37 +05:30
parent ad12732edc
commit 0172b61217
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 5 deletions

View File

@ -20,7 +20,8 @@ from threading import Thread
from calibre import prints
from calibre.constants import (
FAKE_HOST, FAKE_PROTOCOL, __version__, is_running_from_develop
FAKE_HOST, FAKE_PROTOCOL, __version__, is_running_from_develop, ismacos,
iswindows
)
from calibre.ebooks.oeb.base import OEB_DOCS, XHTML_MIME, serialize
from calibre.ebooks.oeb.polish.parsing import parse
@ -252,6 +253,7 @@ def get_editor_settings(tprefs):
'bg': get_color('preview_background', dark_color),
'fg': get_color('preview_foreground', dark_text_color),
'link': get_color('preview_link_color', dark_link_color),
'os': 'windows' if iswindows else ('macos' if ismacos else 'linux'),
}

View File

@ -208,11 +208,13 @@ def load_mathjax():
if document.body:
settings = JSON.parse(window.navigator.userAgent.split('|')[1])
css = '[data-in-split-mode="1"] [data-is-block="1"]:hover { cursor: pointer !important; border-top: solid 5px green !important }'
if settings.os is 'macos':
# See settings.pyj for reason for webkit-hyphenate-character
css += '\n* { -webkit-hyphenate-character: "-" !important }\n'
document.body.addEventListener('click', onclick, True)
document.documentElement.appendChild(E.style(
type='text/css',
'[data-in-split-mode="1"] [data-is-block="1"]:hover { cursor: pointer !important; border-top: solid 5px green !important }'
))
document.documentElement.appendChild(E.style(type='text/css', css))
fix_fullscreen_svg_images()
if check_for_maths():