@libraz/mejiro
v0.5.0
Published
Japanese vertical text layout engine for the web — line breaking, kinsoku shori, hanging punctuation, ruby, EPUB parsing/authoring, and pagination
Maintainers
Readme
@libraz/mejiro
Japanese vertical text layout engine for the web — line breaking, kinsoku shori, hanging punctuation, ruby, image exclusion, and EPUB parsing/authoring. The core has zero DOM dependencies. Pairs with @libraz/mejiro-react / @libraz/mejiro-vue for ready-to-use reader/editor components.
Install
npm install @libraz/mejiroQuick start
import { DEFAULT_HEADING_STYLES, MejiroBook } from '@libraz/mejiro/book';
import { parseEpub } from '@libraz/mejiro/epub';
const book = new MejiroBook({
fontFamily: '"Noto Serif JP"',
fontSize: 16,
lineSpacing: 1.8,
headingStyles: DEFAULT_HEADING_STYLES,
});
book.computePageSize(document.querySelector('.reader')!);
const epub = await parseEpub(epubBuffer);
const layout = await book.layoutChapter(epub.chapters[0]);
const spread = layout.getSpread(0);Subpath exports
| Import path | Description |
|---|---|
| @libraz/mejiro | Core: line breaking, kinsoku, hanging, ruby, image exclusion |
| @libraz/mejiro/browser | Font measurement + browser integration |
| @libraz/mejiro/epub | EPUB parsing, EditableEpub, EpubProject |
| @libraz/mejiro/render | Layout → render data + CSS |
| @libraz/mejiro/book | High-level MejiroBook / ChapterLayout API |
| @libraz/mejiro/image | Browser-side image decode / downscale helpers |
