bump crengine: tables rendering improvements and others

bump crengine, which includes:
- Adds support for symbol fonts (local or embedded)
- Fix some issues when rendering text in constrained width
- Page splitting: fix possible missing blocks
- CSS: adds support for 'auto', ignore % for borders
- Fix right border drawing position
- Fix: adds missing properties in copystyle()
- Adds comments, erm_killed rendering method
- Adds getRenderedWidths(): get node min/max node content width
- Tables rendering: fixes and improvements
- getRenderedWidths: enable min_width to be a single CJK char
- Fix wrong text wrap avoid in some case
- epub.css: add style for 'blockquote'
- Fix rendering issue when line ends with an image

Adds a few style tweaks related to tables.

Enforce table width: 100% in Wikipedia EPUBs to keep
previous look, which feels better with the various kinds
of tables in Wikipedia pages.

Fix unit tests as juliet.epub (full of blockquotes), grew quite
a few pages with the epub.css update.
pull/4388/head
poire-z 6 years ago
parent ed8f87f9f4
commit ea946d52d6

@ -1 +1 @@
Subproject commit 1fa2b5715e2be7432e473940cc623d396aa9f5f7 Subproject commit 03267b1e195b811abeaf47a4a158d414a0e28d2b

@ -392,6 +392,7 @@ function ReaderHighlight:viewSelectionHTML(debug_view)
-- Each node on a line, with markers and numbers of skipped chars and siblings shown, -- Each node on a line, with markers and numbers of skipped chars and siblings shown,
-- with possibly invalid HTML (text nodes not escaped) -- with possibly invalid HTML (text nodes not escaped)
html_flags = 0x3353 html_flags = 0x3353
-- html_flags = 0x3753 -- use this to additionally see rendering methods
end end
local html, css_files = self.ui.document:getHTMLFromXPointers(self.selected_text.pos0, local html, css_files = self.ui.document:getHTMLFromXPointers(self.selected_text.pos0,
self.selected_text.pos1, html_flags, true) self.selected_text.pos1, html_flags, true)

@ -191,40 +191,72 @@ h1, h2, h3, h4, h5, h6 { hyphens: none !important; }
{ {
title = _("Miscellaneous"), title = _("Miscellaneous"),
{ {
id = "table_row_odd_even"; title = _("Tables"),
title = _("Alternate background color of table rows"), {
css = [[ id = "table_full_width";
title = _("Full-width tables"),
description = _("Make table expand to the full width of the page. (Tables with small content now use only the width needed to display that content. This restores the previous behavior.)"),
css = [[table { width: 100% !important; }]],
},
{
id = "table_td_width_auto";
title = _("Ignore publisher table and cell widths"),
description = _("Ignore table and cells widths specified by the publisher, and let the engine decide the most appropriate widths."),
css = [[table, td, th { width: auto !important; }]],
},
{
id = "table_margin_left_right_auto";
title = _("Center small tables"),
description = _("Horizontally center tables that do not use the full page width."),
css = [[table { margin-left: auto !important; margin-right: auto !important; }]],
separator = true,
},
{
id = "td_vertical_align_none";
title = _("Ignore publisher vertical alignment in tables"),
-- Using "vertical-align: top" would vertical-align children text nodes to top.
-- "vertical-align: baseline" has no meaning in table rendering, and is as fine
css = [[td { vertical-align: baseline !important; }]],
},
{
id = "table_row_odd_even";
title = _("Alternate background color of table rows"),
css = [[
tr:nth-child(odd) { background-color: #EEE !important; } tr:nth-child(odd) { background-color: #EEE !important; }
tr:nth-child(even) { background-color: #CCC !important; } tr:nth-child(even) { background-color: #CCC !important; }
]], ]],
}, },
{ {
id = "table_force_border"; id = "table_force_border";
title = _("Show borders on all tables"), title = _("Show borders on all tables"),
css = [[ css = [[
table, tcaption, tr, th, td { border: black solid 1px; border-collapse: collapse; } table, tcaption, tr, th, td { border: black solid 1px; border-collapse: collapse; }
]], ]],
separator = true, separator = true,
},
}, },
{ {
id = "image_full_width"; title = _("Images"),
title = _("Make images full width"), {
description = _("Useful for books containing only images, when they are smaller than your screen. May stretch images in some cases."), id = "image_full_width";
-- This helped me once with a book. Will mess with aspect ratio title = _("Full-width images"),
-- when images have a style="width: NNpx; heigh: NNpx" description = _("Useful for books containing only images, when they are smaller than your screen. May stretch images in some cases."),
css = [[ -- This helped me once with a book. Will mess with aspect ratio
-- when images have a style="width: NNpx; heigh: NNpx"
css = [[
img { img {
text-align: center !important; text-align: center !important;
text-indent: 0px !important; text-indent: 0px !important;
display: block !important; display: block !important;
width: 100% !important; width: 100% !important;
} }
]], ]],
}, },
{ {
id = "image_valign_middle"; id = "image_valign_middle";
title = _("Vertically center-align images relative to text"), title = _("Vertically center-align images relative to text"),
css = [[img { vertical-align: middle; }]], css = [[img { vertical-align: middle; }]],
},
}, },
}, },
-- No current need for workarounds -- No current need for workarounds

@ -992,6 +992,13 @@ li.gallerybox div.gallerytext p {
.citation { .citation {
font-style: italic; font-style: italic;
} }
/* make tables full-width - Wikipedia tables are often set as float
* elements and have a fixed width, often in em (22em), which would
* make them quite small with blank space on their right, as we don't
* support float */
table {
width: 100% !important;
}
/* hide some view/edit/discuss short links displayed as "v m d" */ /* hide some view/edit/discuss short links displayed as "v m d" */
.nv-view, .nv-edit, .nv-talk { .nv-view, .nv-edit, .nv-talk {
display: none; display: none;

@ -146,7 +146,7 @@ describe("Readerfooter module", function()
local timeinfo = footer.textGeneratorMap.time() local timeinfo = footer.textGeneratorMap.time()
local page_count = readerui.document:getPageCount() local page_count = readerui.document:getPageCount()
-- stats has not been initialized here, so we get na TB and TC -- stats has not been initialized here, so we get na TB and TC
assert.are.same('1 / '..page_count..' | '..timeinfo..' | => 0 | B:0% | R:1% | TB: na | TC: na', assert.are.same('1 / '..page_count..' | '..timeinfo..' | => 1 | B:0% | R:0% | TB: na | TC: na',
footer.footer_text.text) footer.footer_text.text)
end) end)
@ -295,8 +295,8 @@ describe("Readerfooter module", function()
assert.are.same(365, footer.text_width) assert.are.same(365, footer.text_width)
footer:onPageUpdate(100) footer:onPageUpdate(100)
assert.are.same(191, footer.progress_bar.width) assert.are.same(183, footer.progress_bar.width)
assert.are.same(389, footer.text_width) assert.are.same(397, footer.text_width)
end) end)
it("should support chapter markers", function() it("should support chapter markers", function()
@ -545,7 +545,7 @@ describe("Readerfooter module", function()
assert.is.same(0, footer.text_width) assert.is.same(0, footer.text_width)
tapFooterMenu(fake_menu, "Progress percentage") tapFooterMenu(fake_menu, "Progress percentage")
assert.are.same('R:1%', footer.footer_text.text) assert.are.same('R:0%', footer.footer_text.text)
assert.is.same(false, footer.has_no_mode) assert.is.same(false, footer.has_no_mode)
assert.is.same(footer.footer_text:getSize().w + footer.text_left_margin, assert.is.same(footer.footer_text:getSize().w + footer.text_left_margin,
footer.text_width) footer.text_width)

@ -85,22 +85,22 @@ describe("Readerhighlight module", function()
readerui.highlight:clear() readerui.highlight:clear()
end) end)
it("should highlight single word", function() it("should highlight single word", function()
highlight_single_word(readerui, Geom:new{ x = 260, y = 80 }) highlight_single_word(readerui, Geom:new{ x = 400, y = 110 })
Screen:shot("screenshots/reader_highlight_single_word_epub.png") Screen:shot("screenshots/reader_highlight_single_word_epub.png")
assert.truthy(readerui.view.highlight.saved[page]) assert.truthy(readerui.view.highlight.saved[page])
end) end)
it("should highlight text", function() it("should highlight text", function()
highlight_text(readerui, highlight_text(readerui,
Geom:new{ x = 260, y = 60 }, Geom:new{ x = 400, y = 110 },
Geom:new{ x = 260, y = 90 }) Geom:new{ x = 400, y = 170 })
Screen:shot("screenshots/reader_highlight_text_epub.png") Screen:shot("screenshots/reader_highlight_text_epub.png")
assert.truthy(readerui.view.highlight.saved[page]) assert.truthy(readerui.view.highlight.saved[page])
end) end)
it("should response on tap gesture", function() it("should response on tap gesture", function()
tap_highlight_text(readerui, tap_highlight_text(readerui,
Geom:new{ x = 151, y = 120 }, Geom:new{ x = 151, y = 115 },
Geom:new{ x = 290, y = 301 }, Geom:new{ x = 300, y = 285 },
Geom:new{ x = 200, y = 268 }) Geom:new{ x = 120, y = 240 })
Screen:shot("screenshots/reader_tap_highlight_text_epub.png") Screen:shot("screenshots/reader_tap_highlight_text_epub.png")
end) end)
end) end)

@ -186,13 +186,13 @@ describe("Readerrolling module", function()
it("should show pages for different word gap", function() it("should show pages for different word gap", function()
readerui.document:setSpaceCondensing(100) readerui.document:setSpaceCondensing(100)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
assert.are.same(191, readerui.document:getPageCount()) assert.are.same(267, readerui.document:getPageCount())
readerui.document:setSpaceCondensing(75) readerui.document:setSpaceCondensing(75)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
assert.are.same(189, readerui.document:getPageCount()) assert.are.same(262, readerui.document:getPageCount())
readerui.document:setSpaceCondensing(50) readerui.document:setSpaceCondensing(50)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
assert.are.same(189, readerui.document:getPageCount()) assert.are.same(248, readerui.document:getPageCount())
end) end)
end) end)

@ -67,7 +67,7 @@ describe("Readersearch module", function()
it("should find the last occurrence", function() it("should find the last occurrence", function()
-- local logger = require("logger") -- local logger = require("logger")
-- logger.info("nb of pages", doc:getPageCount()) -- logger.info("nb of pages", doc:getPageCount())
-- 20180723: currently 189 pages -- 20181206: currently 267 pages
for i = 100, 180, 10 do for i = 100, 180, 10 do
rolling:onGotoPage(i) rolling:onGotoPage(i)
local words = search:searchFromEnd("Verona") local words = search:searchFromEnd("Verona")
@ -76,7 +76,7 @@ describe("Readersearch module", function()
-- logger.info("last match on page", pageno) -- logger.info("last match on page", pageno)
assert.truthy(pageno > 185) assert.truthy(pageno > 185)
end end
for i = 230, 235, 1 do for i = 290, 335, 1 do
rolling:onGotoPage(i) rolling:onGotoPage(i)
local words = search:searchFromEnd("Verona") local words = search:searchFromEnd("Verona")
assert(words == nil) assert(words == nil)

@ -22,10 +22,10 @@ describe("Readertoc module", function()
assert.are.same(2, toc_max_depth) assert.are.same(2, toc_max_depth)
end) end)
it("should get toc title from page", function() it("should get toc title from page", function()
title = toc:getTocTitleByPage(49) title = toc:getTocTitleByPage(60)
DEBUG("toc", toc.toc) DEBUG("toc", toc.toc)
assert(title == "SCENE V. A hall in Capulet's house.") assert(title == "SCENE V. A hall in Capulet's house.")
title = toc:getTocTitleByPage(143) title = toc:getTocTitleByPage(195)
assert(title == "SCENE I. Friar Laurence's cell.") assert(title == "SCENE I. Friar Laurence's cell.")
end) end)
describe("getTocTicks API", function() describe("getTocTicks API", function()
@ -59,7 +59,7 @@ describe("Readertoc module", function()
it("should get page of next chapter", function() it("should get page of next chapter", function()
assert.truthy(toc:getNextChapter(10, 0) > 10) assert.truthy(toc:getNextChapter(10, 0) > 10)
assert.truthy(toc:getNextChapter(100, 0) > 100) assert.truthy(toc:getNextChapter(100, 0) > 100)
assert.are.same(nil, toc:getNextChapter(200, 0)) assert.are.same(nil, toc:getNextChapter(290, 0))
end) end)
it("should get page of previous chapter", function() it("should get page of previous chapter", function()
assert.truthy(toc:getPreviousChapter(10, 0) < 10) assert.truthy(toc:getPreviousChapter(10, 0) < 10)
@ -68,13 +68,13 @@ describe("Readertoc module", function()
end) end)
it("should get page left of chapter", function() it("should get page left of chapter", function()
assert.truthy(toc:getChapterPagesLeft(10, 0) > 10) assert.truthy(toc:getChapterPagesLeft(10, 0) > 10)
assert.truthy(toc:getChapterPagesLeft(92, 0) > 10) assert.truthy(toc:getChapterPagesLeft(102, 0) > 10)
assert.are.same(nil, toc:getChapterPagesLeft(200, 0)) assert.are.same(nil, toc:getChapterPagesLeft(290, 0))
end) end)
it("should get page done of chapter", function() it("should get page done of chapter", function()
assert.truthy(toc:getChapterPagesDone(12, 0) < 5) assert.truthy(toc:getChapterPagesDone(12, 0) < 5)
assert.truthy(toc:getChapterPagesDone(95, 0) < 5) assert.truthy(toc:getChapterPagesDone(95, 0) < 5)
assert.truthy(toc:getChapterPagesDone(204, 0) > 10) assert.truthy(toc:getChapterPagesDone(290, 0) > 10)
end) end)
describe("collasible TOC", function() describe("collasible TOC", function()
it("should collapse the secondary toc nodes by default", function() it("should collapse the secondary toc nodes by default", function()

Loading…
Cancel
Save