EPUB: more support for RTL documents (#5436)

bump crengine: enhanced RTL block rendering.
Includes:
- Re-enable: Use the same FT load flags in HB as in FT
- Avoid redundant calls to getStyle()
- CSS: parse and store "direction:"
- Enhanced block rendering: handle RTL direction
- Enhanced block rendering: handle RTL tables
- Pagesplitting: account for lines' text direction
- CSS: add support for more pseudo-classes
- epub.css: a few updates for RTL documents
- Fix LVDocView::getBookmark() which could be slow or wrong

Add a few style tweaks useful to RTL readers.

Wikipedia Save as EPUB: build proper RTL documents from
persian, arabic, hebrew (and others) Wikipedia articles.
This commit is contained in:
poire-z
2019-09-29 23:02:54 +02:00
committed by GitHub
parent f7861bc1eb
commit 3e3b00429f
3 changed files with 93 additions and 10 deletions

View File

@@ -161,7 +161,48 @@ h1 + h6, h2 + h6, h3 + h6, h4 + h6, h5 + h6 { page-break-before: avoid !importan
id = "headings_align_center",
title = _("Center headings"),
css = [[h1, h2, h3, h4, h5, h6 { text-align: center !important; }]],
priority = 3, -- so it overrides the ones above
priority = 4, -- so it overrides the ones above
},
},
{
title = _("Text direction"),
{
title = _("About text direction"),
info_text = _([[
Languages like Arabic or Hebrew use right-to-left writing systems (Right-To-Left or RTL). This doesn't only affect text layout, but also list item bullets and numbers, which have to be put on the right side of the page, as well as tables, where the cells are laid out from right to left.
Usually, the publisher will have set the appropriate tags to enable RTL rendering. But if these are missing, or if you're reading plain text documents, you may want to manually enable RTL with these tweaks.
Note that in the absence of such specifications, KOReader will try to detect the language of each paragraph to set the appropriate rendering per paragraph.
You may also want to enable, in the top menu → Gear → Navigation →, Invert page turn taps and swipes.]]),
separator = true,
},
{
id = "body_direction_rtl",
title = _("Document direction RTL"),
css = [[body { direction: rtl !important; }]],
priority = 2, -- so it overrides the LTR one below
},
{
id = "text_align_most_right",
title = _("Right align most text"),
description = _("Enforce right alignment of text in common text elements."),
-- Includes H1..H6 as this is probably most useful for RTL readers
css = [[body, p, li, h1, h2, h3, h4, h5, h6 { text-align: right !important; }]],
priority = 3, -- so it overrides the ones from Text alignment
},
{
id = "text_align_all_right",
title = _("Right align all elements"),
description = _("Enforce right alignment of text in all elements."),
css = [[* { text-align: right !important; }]],
priority = 3, -- so it overrides the ones from Text alignment
separator = true,
},
{
id = "body_direction_ltr",
title = _("Document direction LTR"),
css = [[body { direction: ltr !important; }]],
},
},
{
@@ -280,7 +321,7 @@ This might be needed with some documents that expect this style as the default,
priority = -1,
css = [[
p {
text-align: left;
text-align: start;
text-indent: 0;
margin-top: 1em;
margin-bottom: 1em;