I'm releasing
Plato 0.5.0 today.
Plato now has a built-in ePUB renderer, written from scratch, in addition to the renderer that
mupdf provides. Although a few things are still missing (tables, lists, floats, borders, rtl, etc.), it seems to already have enough features to properly render most of the HTML and CSS encountered in ePUBs. The renderer uses
absolute page numbers (one page for every 2048 bytes of markup). This allows me to only build the display list of the spine item that holds the current page number.
The
algorithm used to break paragraphs into lines is the Knuth-Plass algorithm (1981). More precisely, there are at most three passes: first we try without hyphenation ; if it fails we hyphenate using the
Knuth-Liang algorithm ; if it still fails, we try with a simpler algorithm, that has no limits on the stretching of glues. By introducing optional breaks within a word, we might break a ligature. And if we later unbreak this ligature, we might end up with a line length that doesn't match the length that was used by the algorithm. The way I deal with this problem is by redistributing the width difference into the line's glues. Knuth and Plass solved this problem by generalizing the penalty primitive into a
{Pre,No,Post}Break tuple. This is described in
Document Preparation Systems, 1982, pp. 221–242): I don't have access to this paper.
The CSS parser only supports simple selectors:
name#id.class1.class2.⋯.classn and the following combinators:
X > Y,
X + Y. If you're interested in typography and high quality fonts, you'll be happy to know that
font-feature-settings is supported. Finally, I thought it would be interesting to be able to achieve some of the constructions made possible by the box–glue–penalty primitives described in the original paper, and for this purpose, I've introduced the custom `-plato-insert-{before,after}` properties. The solution to the
MR Problem, for example, can be transposed as:
Code:
.flush-right {
-plato-insert-before: penalty 10000, glue 0 100em, penalty 50,
glue 1em, box, penalty 10000, glue 0 100em;
-plato-insert-after: penalty -10000;
}
Embedded fonts are ignored, A declaration of the form
font-family: A, …, Z, K is parsed as
font-family: K where
K is one of the following keywords:
serif,
sans-serif,
monospace,
cursive,
fantasy.
You can set the serif font family, font size, margin width, line height of a document. The default values are in the
reader section of the settings. The
font-path setting of the same section defines the location of the user fonts (the default is
/mnt/onboard/fonts).
The built-in ePUB engine is the default engine, the related setting, in the
reader section is
epub-engine, the possible values are
"built-in" and
"mupdf".
Because the type of the
refresh-every setting has changed, you'll need to remove it from your
Settings.toml before you upgrade.
Other changes:
- The automatic importer now retrieves metadata from ePUBs.
- The shelf's second column now displays the progress status by default. The corresponding setting, in the home section, is second-column, the possible values are "progress" and "year".
- The Clara HD was added to the list of devices.