Skip to main content
Recipe number 128

Cookbook · Chapter 2 · Type & text

A Meiji proclamation in kanji and katakana

The 1889 Constitution set vertically in kanji and katakana: articles 第一條 from a japanese-informal list counter, a ruled frame, countersignatures at the foot.

On this page

p. 一 · 1 of 8

  • Trim 148 × 210 mm
  • 1 column
  • Shippori Mincho B1 10/18
  • Noto Sans JP
  • 8 pages
  • Level
  • Postext 1.65.0
  • Laid out in 62 ms
  • 163 lines of code

In short

The Japanese constitution of 1889, written in kanji and katakana, printed in top-to-bottom lines as the official gazette printed it, with its articles numbered in kanji.

What you'll build

An eight-page reprint of the Meiji Constitution as the Official Gazette (官報) printed it on 11 February 1889: the imperial edict, the ministers' countersignatures and the first two chapters, thirty-two articles. The text is 漢字カタカナ交じり文 (kanji-katakana majiri-bun), the written language of Meiji law: kanji carry the words, katakana carry the endings, and there are no voicing marks, no small kana and no punctuation at all. The pages are A5, vertical and bound on the right, with a 40 × 15 character grid inside a thick and a thin rule. The articles are numbered by a list counter in kanji, 第一條 to 第三十二條, and the seal and the countersignatures sit where the Gazette put them.

This recipe answers

  • How do I set a Meiji text in kanji and katakana, with its old forms, and number its articles 第一條?
  • How do I number chapters 第一章 in kanji numerals, or list items あ い う and イ ロ ハ?
  • Which fonts set Japanese, with kanji in their Japanese forms, on screen and in the PDF?

The short answer

script.js · lines 40–56in full code
const layout = { layoutType: 'single', writingMode: 'vertical-rl' }; // bound on the right
const cjk = { grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES } };
// Each article is an item of an ordered list: the counter is japanese-informal (十八, not
// 一十八), the prefix 第 and the separator 條 wrap it, and the turnover lines go back to
// the head of the line, as in the Gazette. numberWidth 'item' starts the text of each
// article one gap after its own label: one full-width space follows 第九條 and 第十一條
// alike, and their texts start a character apart. Chapter two starts its list at 18.
const orderedLists = {
  numberFormat: 'japanese-informal', prefix: '第', separator: '條', gap: em(1),
  numberWidth: 'item',
  indent: em(0), hangingIndent: false, fontFamily: MINCHO, fontWeight: 800,
  color: col('ink'), marginTop: pt(0), marginBottom: pt(0), itemSpacing: pt(0),
};
// The chapters: 第{2:一}章 counts them in the same style, two characters down (字下げ).
const chapter = { level: 2, numberingTemplate: '第{2:一}章', numberSeparator: ' ',
  fontSize: pt(BODY), fontWeight: 800, indent: em(2), lineSpan: 2, // 二行取り
  breakBefore: { enabled: false } };

Kanji with katakana, vertical, and articles numbered 第一條 in kanji

Ingredients

Type
Shippori Mincho B1, Noto Sans JP (SIL OFL 1.1)
Assets
None: every picture is drawn in code

Method

#1 · Let a list counter write 第十八條

The code is the short answer above. Each article is an item of a Markdown ordered list, and orderedLists turns its number into the Gazette's form: numberFormat: 'japanese-informal' writes 十八, not 一十八, prefix: '第' and separator: '條' wrap it, and gap: em(1) leaves the full-width space of the original. numberWidth: 'item' starts the text of each article one gap after its own label, so 第九條 and 第十一條 are each followed by one full-width space, as in the Gazette, and their texts start a character apart. With hangingIndent: false the turnover lines go back to the head of the line instead of hanging under the text, as in the Gazette. Chapter two starts its list at 18., so the counter runs on across the chapters, and the chapters themselves are numbered 第一章 and 第二章 by the heading template 第{2:一}章, the same counter style (ordered lists).

Page 5: 第一章 天皇 two characters down, articles 第一條 to 第八條 in bold, the second clause of article 8 one character down.

#2 · Leave the katakana as the Gazette wrote them

locale: 'ja' sets the Japanese rules, and none of them rewrites the text. 侵スヘカラス stays without its voicing marks (it reads okasu bekarazu), 行フ keeps its historical kana and 奪ハルヽ its katakana iteration mark. With no small kana and no punctuation in the text, the line breaks fall between any two characters; the kinsoku rules still keep ヽ and 々 off the head of a line. The editor's notes, in modern Japanese with hiragana, sit beside the edict on page 2, so the two ways of writing Japanese can be compared on one page.

#3 · Draw the frame on every page

script.js · lines 60–75in full code
// Header elements are placed on the sheet, not in the flow, so the frame is drawn in
// plain page millimetres: GAP outside the type area, then 1.4 mm to the thin rule.
const GAP = 6;
const rule = (id, out, thickness) => ({ kind: 'box', id, pages: 'all',
  style: { borderColor: col('ink'), borderWidth: pt(thickness) },
  placement: { anchor: { to: 'page', edge: 'top-left' },
    offset: { x: mm(SIDE - out), y: mm(HEAD - out) },
    size: { width: mm(AREA.across + 2 * out), height: mm(AREA.down + 2 * out) } } });
const header = { elements: [
  rule('outer', GAP + 1.4, 1.2), rule('inner', GAP, 0.4),
  // The folio in kanji, under the frame, in the middle of the page.
  { kind: 'text', id: 'folio', content: '{pageNumber}', pages: 'body', fontFamily: GOTHIC,
    fontSize: pt(8), color: col('muted'), align: 'center',
    placement: { anchor: { to: 'page', edge: 'top-left' },
      offset: { x: mm(0), y: mm(HEAD + AREA.down + GAP + 6) }, size: { width: mm(TRIM.w) } } },
] };

The header slot draws in plain page millimetres, not in the vertical flow, so the frame is two boxes placed by the same numbers that place the type area: HEAD from the top, SIDE from each edge. The margins are computed from the grid, not left to it, so the type area sits exactly 6 mm inside the thin rule. The folio, in kanji from pageNumbering.format: 'japanese-informal', sits under the frame.

#4 · Set the title page down the axis

script.js · lines 79–100in full code
// In the flow frame of a vertical page x runs down the column, y leftward across it.
const at = (down, across) => ({ anchor: { to: 'container', edge: 'top-left' },
  offset: { x: mm(down), y: mm(across) } });
const MID = AREA.across / 2; // mm: the axis of the page, from the right of the type area
const cover = {
  id: 'cover', numbered: false, toc: false, span: 'page', runningChapter: false,
  breakBefore: { enabled: true, parity: 'any' },
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'text', id: 'title', content: '{titleText}', fontFamily: MINCHO, fontWeight: 800,
      fontSize: pt(34), lineHeight: 1, letterSpacing: pt(10), color: col('ink'),
      placement: at((AREA.down - (7 * 34 + 6 * 10) * PT) / 2, MID - 34 * PT / 2) }, // centred
    { kind: 'text', id: 'date', content: '{attr.date}', fontFamily: MINCHO, fontSize: pt(11),
      lineHeight: 1, letterSpacing: pt(2), color: col('seal'), placement: at(30, MID + 18) },
    { kind: 'text', id: 'source', content: '{attr.source}', fontFamily: MINCHO,
      fontSize: pt(11), lineHeight: 1, letterSpacing: pt(4), color: col('ink'),
      placement: at(30, MID - 18 - 11 * PT) },
    // The edition's language, turned with the line, at the foot of the type area.
    { kind: 'text', id: 'latin', content: '{attr.latin}', fontFamily: GOTHIC, fontSize: pt(7.5),
      lineHeight: 1.5, color: col('muted'), overflow: 'wrap', align: 'right',
      placement: { ...at(0, AREA.across - 9), size: { width: mm(AREA.down), height: mm(9) } } },
  ] } },
};

In a vertical flow x runs down the sheet and y leftward across it, so the title's column is placed by its distance from the right edge of the type area. The date, in the accent, and the Gazette's name stand on either side of the title, 18 mm off the axis.

#5 · Load each face with the text it sets

script.js · lines 302–303in full code
const notes = (markdown.match(/^- .*$/gm) ?? []).join('');
const gothicText = `${notes}凡例上諭一二三四五六七八九十${markdown.match(/latin="([^"]*)"/)[1]}`;

Shippori Mincho B1, a Mincho with the old forms 國, 條 and 權, loads the files for the text and the headings; Noto Sans JP loads only the editor's notes, the folios and the English line. A face given less than it sets fails the capture (C12).

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 128 · A Meiji proclamation in kanji and katakana ═════════
// https://postext.dev/en/cookbook/katakana-majiri-proclamation
// Code: MIT · Text: Kanpō 1889, ja.wikisource (CC BY-SA 4.0); notes (CC BY 4.0)
// Fonts: Shippori Mincho B1, Noto Sans JP (SIL OFL 1.1) · Needs postext ≥ 1.28.0
// The Meiji Constitution as the Official Gazette printed it: kanji and katakana, vertical.
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 frame; the text is Japanese in both editions
const RECIPE = 'katakana-majiri-proclamation';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: gazette black, one vermilion for the seal, toned paper
const palette = {
  ink: '#211d1a', // the text and the frame
  seal: '#a8321f', // 御名御璽 and the cover's date: the one accent (5.5:1 on the paper)
  muted: '#6b6259', // the editor's notes, the folio, the colophon
  paper: '#fbf8f0',
};
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: 'seal (defaults)', value: { hex: palette.seal, model: 'hex' } },
];
// #endregion

const MINCHO = 'Shippori Mincho B1'; // 明朝 with Meiji type in its bones, old forms 國 條 權
const GOTHIC = 'Noto Sans JP'; // the editor's voice: notes, folios, colophon
const [BODY, LEAD] = [10, 18]; // pt: line pitch 1.8 em
const [CHARS, LINES] = [40, 15]; // the type area: 40 characters down, 15 lines across
const PT = 25.4 / 72; // mm in a point
const TRIM = { w: 148, h: 210 }; // mm, A5
const AREA = { down: CHARS * BODY * PT, across: LINES * LEAD * PT }; // 141.1 × 95.3 mm
const HEAD = 37; // mm from the top edge to the head of the type area: 天 deeper than 地
const SIDE = (TRIM.w - AREA.across) / 2; // the same margin on both sides of the frame

// #region answer: kanji with katakana, vertical, and articles numbered 第一條 in kanji
const layout = { layoutType: 'single', writingMode: 'vertical-rl' }; // bound on the right
const cjk = { grid: { enabled: true, charsPerLine: CHARS, linesPerPage: LINES } };
// Each article is an item of an ordered list: the counter is japanese-informal (十八, not
// 一十八), the prefix 第 and the separator 條 wrap it, and the turnover lines go back to
// the head of the line, as in the Gazette. numberWidth 'item' starts the text of each
// article one gap after its own label: one full-width space follows 第九條 and 第十一條
// alike, and their texts start a character apart. Chapter two starts its list at 18.
const orderedLists = {
  numberFormat: 'japanese-informal', prefix: '第', separator: '條', gap: em(1),

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

#Hang the turnover lines under the text

Modern law books set the second line of an article under its first character of text, not under 第.

-  indent: em(0), hangingIndent: false, fontFamily: MINCHO, fontWeight: 800,
+  indent: em(0), hangingIndent: true, fontFamily: MINCHO, fontWeight: 800,

#Number the articles in daiji

Some legal and financial texts write 壱, 弐, 参: the token 壱 or the style japanese-formal gives 第壱條, 第弐條.

-  numberFormat: 'japanese-informal', prefix: '第', separator: '條', gap: em(1),
+  numberFormat: 'japanese-formal', prefix: '第', separator: '條', gap: em(1),

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

Set Japanese in a Japanese face

Noto Serif SC and TC have kana, but they draw the kanji in Chinese forms (直, 骨 and 角 differ) and the kana in a Chinese design. Set the text in Noto Serif JP or Shippori Mincho B1 and the heads in Noto Sans JP, loaded with loadCjkFonts. Fontsource's Japanese files hold no hentaigana or other historic kana (U+1B000–1B16F): loadCjkFonts fails on them and the PDF prints boxes, so write the modern kana or ship a face that has them in the recipe's assets. Shippori Mincho also lacks the macron vowels ō and ū: set rōmaji in a Latin face. Kana, kanji and rōmaji →

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 →

  • The Gazette sets the katakana of the endings smaller than the kanji, and spaces the ministers' titles evenly to one width (字取り). Postext sets every character at the body size, and its even spacing, jidori, applies to headings only, so the countersignatures here are only aligned at the foot of the line.
  • Japanese and Chinese differ on this counter: in a ja document the token 一 and {2:一} mean japanese-informal (百一, 十八), in a Chinese one they mean the Chinese style (一百零一, 十八). The Chinese reader Dates and acronyms upright in vertical text types its 第一條 by hand.

Credits

Text
Fonts
Shippori Mincho B1 (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)
SandboxPDF