简单来说
1889年的日本宪法,用汉字和片假名写成,按官报原样从上到下竖排,条文用汉字数字编号。
成品一览
一份八页的明治宪法重印本,照1889年2月11日《官报》(官報)的原样排印:天皇的敕语、大臣副署,以及前两章共三十二条。正文是漢字カタカナ交じり文(汉字片假名混写文),即明治法令的书面语:汉字承载词义,片假名写词尾,没有浊点,没有小写假名,也完全没有标点。页面为A5,竖排,右侧装订,在一粗一细两道框线之内用每行40字、每页15行的网格。条文用汉字列表计数器编号,从第一條到第三十二條;御名御玺和副署都放在《官报》原来的位置。
这道食谱解答
- 怎样排汉字片假名混写、保留旧字形的明治文献,并把条文编为第一條?
- 怎样用汉字数字把章编号为第一章,或把列表项编为あいう和イロハ?
- 哪些字体能排日文,并在屏幕和PDF中让汉字采用日文字形?
简短回答
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 } };
用料
做法
#1 · 让列表计数器写出第十八條
代码见上文的简短回答。每一条都是Markdown有序列表的一项,orderedLists把序号写成《官报》的样子:numberFormat: 'japanese-informal'写作十八而不是一十八,prefix: '第'和separator: '條'包在两边,gap: em(1)留出原文的全角空格。numberWidth: 'item'让每条的文字紧接在自己的条号之后,只隔一个间距,所以第九條和第十一條后面都只有一个全角空格,与《官报》相同,两条文字的起点相差一个字。设置hangingIndent: false后,转行回到行首,而不是悬挂在正文下方,与《官报》一致。第二章的列表从18.开始,计数器因而跨章连续;各章本身由标题模板第{2:一}章编为第一章、第二章,用的是同一种计数风格(有序列表)。

#2 · 片假名照《官报》原样保留
locale: 'ja'启用日文规则,但没有哪条规则会改写文字。侵スヘカラス不补浊点(读作okasu bekarazu),行フ保留历史假名,奪ハルヽ保留片假名的叠字符。正文没有小写假名也没有标点,行可以在任意两个字之间断开;禁则仍然不让ヽ和々出现在行首。第2页上,编者凡例用夹带平假名的现代日文写成,与敕语并排,同一页里可以对照日文的两种写法。
#3 · 每页都画边框
// 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) } } },
] };
页眉槽位按纸面的毫米定位,不随竖排的文字流转向,所以边框就是两个方框,用确定版心位置的同一组数字来放:HEAD从上边量,SIDE从两侧量。页边距由网格算出,而不是交给网格去扩展,版心因此正好位于细线内侧6 mm。页码由pageNumbering.format: 'japanese-informal'写成汉字,放在边框下方。
#4 · 扉页沿中轴排
// 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) } } },
] } },
};
在竖排流中,x沿纸面向下,y向左横量,所以标题这一列按它到版心右缘的距离来定位。强调色的日期和《官报》的名称分列标题两侧,各距中轴18 mm。
#5 · 每种字体只加载它要排的文字
const notes = (markdown.match(/^- .*$/gm) ?? []).join('');
const gothicText = `${notes}凡例上諭一二三四五六七八九十${markdown.match(/latin="([^"]*)"/)[1]}`;
Shippori Mincho B1是带有國、條、權等旧字形的明朝体,加载正文和标题所需的文件;Noto Sans JP只加载编者凡例、页码和英文说明。字体拿到的文字少于它实际排的文字时,截图会失败(C12)。
完整食谱
// ═══ 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),
组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)
变化
#转行悬挂在正文下方
现代的法规汇编让条文的第二行对齐正文的第一个字,而不是对齐“第”。
- indent: em(0), hangingIndent: false, fontFamily: MINCHO, fontWeight: 800,
+ indent: em(0), hangingIndent: true, fontFamily: MINCHO, fontWeight: 800,#用大写数字编号
有些法律和财务文本写壱、弐、参:用记号壱或japanese-formal风格,得到第壱條、第弐條。
- numberFormat: 'japanese-informal', prefix: '第', separator: '條', gap: em(1),
+ numberFormat: 'japanese-formal', prefix: '第', separator: '條', gap: em(1),常见问题
易错点
日文文本标记为'ja',不要用zh-Hans或LANG
食谱的版本是en和es,但日文示例在两个版本里都是日文:`locale: LANG`会把它标记为英文或西班牙文,中文标记则会按中文规则排它(开明式标点、小假名可以出现在行首、图代替図、PDF中用中文字形)。postext 1.30起,这个标记也是文字成形所用的语言(测量、绘制和嵌入都按它进行),所以'ja'以外的标记给出的不是日文字形(中文标记给出中文字形),断行的位置也不同。写'ja':它选用日本地区(JLReq断行和标点、芝麻着重号、振假名的分布、図和表标签),并关闭断词。lint会让带假名却标记为zh或ko的文本失败。 日文禁则处理 →
易错点
日文要用日文字体排
Noto Serif SC和TC里有假名,但汉字是中文字形(直、骨、角都不同),假名也是中文字体的设计。正文用Noto Serif JP或Shippori Mincho B1,标题用Noto Sans JP,用loadCjkFonts加载。Fontsource的日文文件里没有变体假名等历史假名(U+1B000–1B16F):loadCjkFonts遇到它们会失败,PDF里印出空框,所以要写现代假名,或者把含有这些字的字体放进食谱的assets。Shippori Mincho也没有带长音符号的ō和ū:罗马字要用拉丁字体排。 假名、汉字与罗马字 →
易错点
中文字体通过cjk块分片加载
Fontsource把一个中文、日文或韩文字体家族按每个字重约一百个文件提供,每个文件覆盖一段字符范围。loadFonts只获取latin文件,所以屏幕上的汉字来自系统字体,测量不准;fontsourceProvider交给PDF的也是这个latin文件,汉字印出来是空框。列出kit中的cjk块,在loadFonts之后调用loadCjkFonts(FONTS, markdown)(书中用到几种CJK字体时,每种字体调用一次,并传入它所排的文字),并给renderToPdf传fontProvider: cjkPdfProvider:两者都会取用包含文中字符的那些文件。 中日韩字体 →
- 《官报》把词尾的片假名排得比汉字小,并把大臣的官衔均匀撑开到同一宽度(字取り)。Postext按正文字号排所有字符,它的均排
jidori只用于标题,所以这里的副署只在行末对齐。 - 日文和中文对这个计数器的理解不同:在
ja文档中,记号一和{2:一}表示japanese-informal(百一、十八);在中文文档中表示中文写法(一百零一、十八)。中文读本竖排中的日期与缩略词直立的第一條是手工输入的。
致谢
- 文本
- The Constitution of the Empire of Japan, 11 February 1889: the imperial preamble (上諭) with its countersignatures, chapters 1 and 2, as printed in the Kanpō (Official Gazette) extra of that day · Government of Japan; transcription by Japanese Wikisource editors · CC BY-SA 4.0
- The editor's notes (凡例), written in Japanese for this recipe · Postext Cookbook · CC BY 4.0
- 字体
- Shippori Mincho B1 (SIL OFL 1.1) · Noto Sans JP (SIL OFL 1.1)


