-
Notifications
You must be signed in to change notification settings - Fork 20
Injection and Pagination
This page discusses how to inject and paginate EPUB contents.
Depending on the platform and version you’re developing for, contents must be injected into:
- a web view;
- a chrome view;
- an iframe.
Indeed, we must provide authors with a reliable context in which their styles and scripts are scoped.
Since we must take viewport units into account, especially vh
(viewport height), at least the top and bottom margins must be set on this container, and not inside it.
You may also want to set left and right margins on this container so that all margins are equal in the two-column view.
Finally, on larger screens, you’ll have to set dimensions on this container so that it doesn’t become too large.
Please note you must deal with the background-color
outside this container, especially as the user can set reading modes (night, sepia, etc.). In other words, it must be synced with this user setting so that the entire screen is the same background-color
.
Contents are paginated using CSS multicolumns, for several reasons:
- it’s been cross-platform for a long time;
- it’s responsive;
- it’s tried and tested;
- it brings some kind of interoperability since it has been used by a lot of Reading Systems and authors have been designing against them.
Pagination is responsive by default, which means it is using relative values in order to adapt layout to the viewport and the current font size.
We’ve chosen this approach since it appears setting everything in pixels is more likely to create rounding errors and rendering issues (e.g. cut-off text) than letting the rendering engine deal with relative units on its own.
The responsive design provide other benefits. For instance, if the reader is using an iPad in landscape mode and sets a bigger font size, the two-column view will automatically switch to a single-page view if needed.
You can also limit line-length by setting a max-width
for body
.
Please note a user setting for the number of columns has been designed so that users can set the layout as they wish.
Since we must inject contents and columns are implemented at the :root
level (i.e. html
), the Reading System owns the entire styling for this selector.
Font size is an important metric since the responsive design relies entirely on rem
(root em) so this style must be enforced by any means necessary.
For body
, we own:
-
overflow
; - sizing:
(min-|max-) width
,(min-|max-) height
,box-sizing
; - spacing:
margin
andpadding
.
You can control horizontal margins in several ways:
- using
column-gap
andpadding
for:root
; - using
column-gap
andmargin
for the web view/chrome view/iframe; - using
padding
for:root
and/orbody
.
Please note that when using padding
, you must take it into account when sizing :root
and/or body
. Their widths contains the padding set for the element.
We’ve designed two extras for pagination:
- a patch for HTML5 Suggested Rendering, which takes care of paged media;
- safeguards, which make sure some elements will be managed as expected by authors in columns.
The HTML5 patch deals with:
- fragmentation (
widows
,orphans
andpage-break
); - hyphenation;
- open type features;
- horizontal margins (pixels have been converted to %);
- normalization of
abbr
andwbr
.
You can use it with or without pagination, it should not make any difference.
Safeguards deal with:
- media sizing (e.g.
img
,svg
,audio
,video
); - word wrap for long strings (headings and links);
- large table’s overflow.
Once again, you can use it with or without pagination, it should not make any difference.