Vertical Japanese
use MejiroEPUB\Text\WritingMode;
$book = new Document($info, writingMode: WritingMode::VERTICAL_RL);
That one argument does three things:
- the text runs top to bottom, lines right to left (
writing-mode: vertical-rl, with the-epub-and-webkit-forms older reading systems still need); - pages turn right to left (
page-progression-direction="rtl"), as a Japanese book does; - two-digit numbers stand upright in one cell (see below).
The default is horizontal, as in MejiroPDF.
Page order
ReadingDirection::AUTO (the default) follows the writing mode. Override it
only when the two should disagree — a horizontal manga commentary bound
right to left, say:
use MejiroEPUB\ReadingDirection;
new Document($info, direction: ReadingDirection::RIGHT_TO_LEFT);
Ruby and emphasis dots
Ruby is written as <ruby> with <rp> parentheses, so a reading system without
ruby support shows 吾輩(わがはい) rather than running the two together.
Emphasis dots are text-emphasis: filled sesame — the sesame dot of Japanese
books, on the right of the column in vertical text and above the line in
horizontal text. The italics a reader would normally give <em> are cancelled:
Japanese type has none.
Tate-chu-yoko
In vertical text, a run of exactly two half-width digits is set upright in
one character cell: 12時 reads as a number, not two stacked digits. One digit
already sits fine in a column; three or more squeezed into one cell become
unreadable, so they are left alone. This is the same rule as MejiroPDF.
Mark other runs explicitly — ^!?^ in mejiro(), ->tcy('!?') on a
Paragraph — or turn the automatic rule off:
use MejiroEPUB\Style\StyleOptions;
new Document($info, writingMode: WritingMode::VERTICAL_RL, style: new StyleOptions(autoTcy: false));
Latin letters in a vertical line
use MejiroEPUB\Style\LatinInVertical;
new StyleOptions(latinInVertical: LatinInVertical::UPRIGHT);
MIXED (default) | Latin words lie on their side and read top to bottom — the reading systems' own default, best for whole English words |
UPRIGHT | every letter stands upright, one per cell — MejiroPDF's default, so an EPUB matches a PDF made from the same text |
What the stylesheet leaves alone
E-book readers choose their own typeface, size and margins, and a stylesheet that fixed them would take those controls away. So the base stylesheet sets no font family, no font size for body text and no page margins, and adds no space between paragraphs and no indent (the writer typed the indent as a full-width space). Line breaking rules (kinsoku), hanging punctuation and spacing between Japanese and Latin text are the reading system's job.
The one thing you may set is the line height, if your readers expect a looser page than their reader's default:
new StyleOptions(lineHeight: 1.75); // 1.0 to 3.0; null (default) leaves it to the reader