https://bugs.kde.org/show_bug.cgi?id=527169
Bug ID: 527169
Summary: EPUB pages have no top or bottom margin: text runs to
the page edges
Classification: Applications
Product: okular
Version First 23.08.5
Reported In:
Platform: Ubuntu
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: EPub backend
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 197166
--> https://bugs.kde.org/attachment.cgi?id=197166&action=edit
A screenshot which shows the same page break before and after the fix.
In EPUB documents, text on every page starts and ends about 4 px from the
page's top and bottom edges. Where a paragraph continues onto the next page,
the line before the page break sits against the bottom edge and the next line
against the top edge of the following page. This makes long books tiring to
read, especially in continuous view.
No CSS in the book can change this. I tried, with the same result each time:
margins and padding on body and html, an @page rule, and margins on wrapper
elements. Block margins only apply where a block starts or ends, not at each
page break.
Steps to reproduce:
1. Open any EPUB with chapters longer than one page.
2. Go to a page in the middle of a chapter.
Observed: the first and last lines of text touch the top and bottom of the page
(about 4 px).
Expected: a margin at the top and bottom of every page, as at the sides.
Cause:
EpubDocument (generators/epub/epubdocument.cpp) sets a fixed page size of 600 x
800 and never sets a document margin, so QTextDocument's default documentMargin
of 4 px is used on every page. EpubDocument already has a padding member (20)
that it uses for maxContentHeight() and maxContentWidth(), but not for the
layout.
Proposed fix: use that padding as the document margin, so the page layout
matches the content limits that are already computed from it.
--- a/generators/epub/epubdocument.cpp
+++ b/generators/epub/epubdocument.cpp
@@ -25,6 +25,8 @@
#endif
setPageSize(QSizeF(600, 800));
+ // Give every page a margin; Qt's default is 4 px, so text runs to the
page edges.
+ setDocumentMargin(padding);
}
bool EpubDocument::isValid()
I have not built Okular with this change. I did test it with a small Qt program
that loads EPUB chapters the same way as the backend (setHtml for the first
file, insertHtml for the rest, 600 x 800 pages). With the change, each page
break gets a 20 px band below the last line and above the first. It also adds
16 px to the existing side margin (20 px instead of 4 px).
--
You are receiving this mail because:
You are watching all bug changes.