Skip to main content
Recipe number 122

Cookbook · Chapter 2 · Type & text

Kanbun with its reading marks, and the Japanese reading

Three Analects sayings and a Tang quatrain as a Japanese reader sets them: return marks and okurigana in vermilion, and the reading in kana under each passage.

On this page
Output
Canvas · PDF
Postext
Tested with Postext 1.65.0
Needs ≥ 1.25.0 · postext-pdf ≥ 1.25.0
Licence
Updated 10 Oct 2026
Code MIT · Text CC BY 4.0

p. 一 · 1 of 3

  • Trim 148 × 210 mm
  • 1 column
  • Klee One 10.5/21
  • Noto Sans JP
  • Zen Old Mincho
  • 3 pages
  • Level
  • Postext 1.65.0
  • Laid out in 52 ms
  • 131 lines of code

In short

Classical Chinese as Japanese readers learn it: small red marks beside the characters tell the reader in which order to read them and which Japanese endings to add, and the full Japanese reading follows each passage.

What you'll build

Three pages of a Japanese school reader of 漢文 (kanbun), classical Chinese read as Japanese, on an A5 page bound on the right: three sayings of the Analects and Meng Haoran's quatrain Spring Dawn. Each passage is set in Zen Old Mincho at 15 pt in the Chinese order, with its 訓点 (kunten) beside the characters in vermilion, half their size: the return marks (返り点) at the lower left of a character tell the reader to read on and come back to it, and the okurigana (送り仮名) at its right add the Japanese endings. Under each passage its 書き下し文 (yomikudashi), the same text written out as Japanese, runs in Klee One, a school-book hand, with furigana where a reading is hard. Chinese classics with their own reading aids are Nº 080.

This recipe answers

  • How do I print kanbun with its return marks and okurigana?
  • How do I add furigana over kanji, one reading per character or one for the whole word?

The short answer

script.js · lines 32–52in full code
// :kunten[習]{kaeri="レ" okuri="フ"} sets the return mark small at the character's lower
// left and the okurigana at its lower right, down the line; the text keeps its Chinese
// order, which the reader follows by the marks. cjk.kunten sizes and colours them: half
// the character, in vermilion. The Japanese reading under each passage is plain kana and
// kanji with furigana: {君子|くん|し} gives each character its reading (jukugo ruby).
const cjk = {
  grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES },
  kunten: { fontSize: em(0.5), color: col('vermilion'), placement: 'inline' },
};
const paragraphStyles = [
  // The text: 15 pt on a pitch of two grid lines, room for the okurigana beside it. A
  // quatrain takes two lines, a couplet to the line with a space between its verses.
  { id: 'kanbun', fontFamily: MINCHO, fontSize: pt(KANBUN), lineHeight: pt(2 * LEAD),
    firstLineIndent: em(0), textAlign: 'justify' },
  { id: 'shi', fontFamily: MINCHO, fontSize: pt(KANBUN), lineHeight: pt(2 * LEAD),
    indent: em(2), firstLineIndent: em(0), marginTop: pt(0), marginBottom: pt(0) },
  // The reading (書き下し文), two characters down in a school-book hand.
  { id: 'kudashi', indent: em(2), firstLineIndent: em(0), marginTop: pt(LEAD) },
  { id: 'kudashi-shi', indent: em(4), firstLineIndent: em(0), marginTop: pt(0),
    marginBottom: pt(0) },
];

Kanbun with 返り点 and 送り仮名, its yomikudashi beside it in furigana

Ingredients

Type
Zen Old Mincho, Klee One, Noto Sans JP (SIL OFL 1.1)
Assets
None: every picture is drawn in code

Method

#1 · Mark each character with :kunten

The code is the short answer above. :kunten[習]{kaeri="レ" okuri="フ"} gives 習 the return mark レ and the okurigana フ; the text keeps the character, so search, copy and the PDF read the passage as written, and the marks take no character of it (Marks, ruby and warichu). Read 学ビテ而時ニ習フレ之ヲ: レ on 習 sends the reader to 之 first and back, 之を習ふ; 而 has no mark and is not read. In vertical text the return mark sits at the lower left of its character and takes half a character of the line, and the okurigana sit at the right, starting halfway down the character, as JIS X 4051 sets them. cjk.kunten sets their size, half the text's, and their colour, the vermilion a reader writes them in; a passage is 15 pt on two lines of the grid, which leaves 27 pt beside each line for the okurigana.

#2 · Jump with 一 二 and with 一レ

The numbers carry the reader further back. In 不二亦タ説バシカラ一乎 the reader skips 不, which has 二, reads 亦た説ばしから, and at 一 goes back up to 不: 亦た説ばしからずや. In 為政 the combined mark 一レ on 為 does both: 可二以テ為一レ師ト矣 reads 以て, 師と (レ), 為る, then back to 可 (一 to 二), 以て師と為るべし. The kanbun code points ㆑ ㆒ ㆓ are read as the characters they stand for, so a text copied from elsewhere keeps its marks.

#3 · Let long okurigana push the next character on

An okurigana longer than its character does not run beside the next one: in 花落ツルコト知ル多少 the four kana of ツルコト take two characters' length, and 知 moves down to start after them, as JIS X 4051 sets them (§5.6.4). The line grows; its next break moves with it.

#4 · Give each passage a label two lines tall

script.js · lines 56–70in full code
const at = (down, across) => ({ anchor: { to: 'container', edge: 'top-left' },
  offset: { x: pt(down), y: pt(across) } });
const TITLE = 26; // pt
const part = { level: 1, breakBefore: { enabled: true, parity: 'any' },
  advancedDesign: { enabled: true, minHeight: pt(5 * LEAD), slot: { elements: [
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: MINCHO, fontWeight: 700,
      fontSize: pt(TITLE), lineHeight: 1, letterSpacing: pt(TITLE / 2), color: col('ink'),
      placement: at(2 * BODY, 2 * LEAD - TITLE / 2) },
    { kind: 'text', id: 'kicker', content: '{attr.kicker}', fontFamily: GOTHIC, fontSize: pt(8.5),
      letterSpacing: pt(2), color: col('vermilion'), placement: at(2 * BODY + 3 * TITLE + 18,
        2 * LEAD - 8.5 / 2) },
  ] } } };
// 2行取り, the passage's book and number in gothic, two characters down.
const passage = { level: 2, fontFamily: GOTHIC, fontWeight: 700, fontSize: pt(9.5),
  color: col('muted'), lineSpan: 2, indent: em(2) };

Each book of the reader opens a page with its title, 論語 or 唐詩, the first with a small vermilion note on what it holds; each passage takes a label in gothic two body lines wide (2行取り), 学而第一 or 春暁 孟浩然, so the passages under it stay on the grid. The reading is a :::paragraphs{style="kudashi"} fence two characters down, in the body's face and size, with jukugo furigana: {君子|くん|し} gives each character its own reading, so a line could break between them.

#5 · Load each voice with its characters

script.js · lines 173–186in full code
const FENCE = /:::paragraphs\{style="([\w-]+)"\}\n([\s\S]*?)\n:::/g;
const fence = (style) => [...markdown.matchAll(FENCE)].filter((m) => m[1] === style)
  .map((m) => m[2]).join('');
const kanbun = `${fence('kanbun')}${fence('shi')}`; // the text and its marks' kana
const reading = `${fence('kudashi')}${fence('kudashi-shi')}`;
const heads = markdown.match(/^#+ [^{\n]*/gm).join('');
const colophon = markdown.match(/colophon="([^"]*)"/)[1];
await loadFonts(FONTS, markdown); // the Latin files: the colophon
await loadCjkFonts({ [MINCHO]: ['400'] }, kanbun, { vertical: true });
await loadCjkFonts({ [MINCHO]: ['700'] }, heads);
await loadCjkFonts({ [KYOKASHO]: ['400'] }, reading, { vertical: true });
await loadCjkFonts({ [GOTHIC]: ['400', '700'] },
  `${heads}${colophon}${markdown.match(/kicker="([^"]*)"/)[1]}漢文訓読一二三四五六七八九十`,
  { vertical: true });

The classical text and the reading are set in different faces, so each loads the files for its own characters: Zen Old Mincho for the passages and their marks, whose kana sit inside the :kunten attributes, Klee One for the readings and their furigana, Noto Sans JP for the labels. The quatrain is set two verses to the line with an ideographic space between them, a common way to print one, so the poem and its reading fit the page under the title.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 122 · Kanbun with its reading marks, and the Japanese reading ═══
// https://postext.dev/en/cookbook/kanbun-kundoku
// Code: MIT · Text: 論語, 孟浩然「春暁」 (public domain); kunten and readings CC BY 4.0
// Fonts: Zen Old Mincho, Klee One, Noto Sans JP (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the colophon; the page is Japanese in both
const RECIPE = 'kanbun-kundoku';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink, the vermilion of hand-written kunten, a school-book paper
const palette = {
  ink: '#1e1c1a', // the text
  vermilion: '#c0392b', // 朱: the reading marks, as a reader adds them by hand
  muted: '#6a635c', // the headings' labels, the folios
  paper: '#fcfbf7',
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
  ...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
  { id: 'main-color', name: 'defaults', value: { hex: palette.vermilion, model: 'hex' } },
];
// #endregion
const [MINCHO, KYOKASHO, GOTHIC] = ['Zen Old Mincho', 'Klee One', 'Noto Sans JP'];
const [BODY, LEAD, CHARS, LINES] = [10.5, 21, 36, 16]; // pt, pt: 36字 × 16行, a 2 em pitch
const KANBUN = 15; // pt: the classical text, set larger on two lines of the grid

// #region answer: kanbun with 返り点 and 送り仮名, its yomikudashi beside it in furigana
// :kunten[習]{kaeri="レ" okuri="フ"} sets the return mark small at the character's lower
// left and the okurigana at its lower right, down the line; the text keeps its Chinese
// order, which the reader follows by the marks. cjk.kunten sizes and colours them: half
// the character, in vermilion. The Japanese reading under each passage is plain kana and
// kanji with furigana: {君子|くん|し} gives each character its reading (jukugo ruby).
const cjk = {
  grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES },
  kunten: { fontSize: em(0.5), color: col('vermilion'), placement: 'inline' },
};
const paragraphStyles = [
  // The text: 15 pt on a pitch of two grid lines, room for the okurigana beside it. A
  // quatrain takes two lines, a couplet to the line with a space between its verses.
  { id: 'kanbun', fontFamily: MINCHO, fontSize: pt(KANBUN), lineHeight: pt(2 * LEAD),
    firstLineIndent: em(0), textAlign: 'justify' },
  { id: 'shi', fontFamily: MINCHO, fontSize: pt(KANBUN), lineHeight: pt(2 * LEAD),
    indent: em(2), firstLineIndent: em(0), marginTop: pt(0), marginBottom: pt(0) },
  // The reading (書き下し文), two characters down in a school-book hand.

The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)

Variations

A printed reader sets the kunten in the text's ink; leave out the colour.

-  kunten: { fontSize: em(0.5), color: col('vermilion'), placement: 'inline' },
+  kunten: { fontSize: em(0.5), placement: 'inline' },

#Set the marks between the lines

placement: 'interlinear' takes the return marks out of the line, into the gap beside the character's lower half, so the passage keeps the spacing of the bare text (白文). JIS sets them inline, the default.

-  kunten: { fontSize: em(0.5), color: col('vermilion'), placement: 'inline' },
+  kunten: { fontSize: em(0.5), color: col('vermilion'), placement: 'interlinear' },

Pitfalls

Pitfall

Tag a Japanese text 'ja', never zh-Hans or LANG

A recipe's editions are en and es, but a Japanese sample is Japanese in both: `locale: LANG` would tag it English or Spanish, and a Chinese tag would set it by the Chinese rules (Kaiming punctuation, small kana free to start a line, 图 for 図, Chinese glyph forms in the PDF). From postext 1.30 the tag is also the language the text is shaped in (measured, painted and embedded), so any tag but 'ja' gives other glyph forms than the Japanese ones (the Chinese ones under a Chinese tag) and other line breaks. Write 'ja': it picks the Japan region (JLReq line breaking and punctuation, sesame emphasis marks, furigana spacing, 図 and 表 labels) and turns hyphenation off. The lint fails a text with kana under a zh or ko tag. Japanese line breaking (kinsoku) →

Pitfall

Chinese faces load by slices, through the cjk block

Fontsource serves a Chinese, Japanese or Korean family as about a hundred files per weight, each covering a range of characters. loadFonts fetches only the latin file, so on screen the Han characters come from a system face and measure wrong, and fontsourceProvider hands the PDF that latin file, which prints them as empty boxes. List the cjk kit block, call loadCjkFonts(FONTS, markdown) after loadFonts (once per voice, with the text it sets, when the book uses several CJK faces) and give renderToPdf fontProvider: cjkPdfProvider: both take the files that hold the text's characters. Chinese, Japanese and Korean fonts →

Pitfall

A right-bound book shows its spreads with showBook

In a book bound on the right (Arabic, Hebrew or Persian text, vertical Chinese, or page.binding 'right') page 1 is still the recto, but it lies on the left of the spine, and the pairs read [3 | 2]. showPages lays every book out left-bound; showBook from the book block (the cjk block carries the same function) reads doc.binding and mirrors the pairs. capture.hero still names a spread in reading order, [verso, recto]: [2, 3]. Books bound on the right →

Credits

Text
  • 論語 (the Analects of Confucius), 學而 1 and 3, 爲政 11, and 孟浩然「春曉」 (Spring Dawn), in shinjitai; the kunten (返り点, 送り仮名) and the yomikudashi follow the usual Japanese school reading and were set for this recipe (CC BY 4.0) · Confucius and his disciples; Meng Haoran; Ignacio Ferro (kunten and reading) · public domain
Fonts
Zen Old Mincho (SIL OFL 1.1) · Klee One (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)
SandboxPDF