本文へスキップ
レシピ番号130

レシピ集 · 第2章 · 文字と本文

ローマ字で書く日本語:啄木の『ローマ字日記』

ja-Latnのタグを付けたローマ字の文章。かなには日本語の規則を、ラテン文字にはハイフネーションなしを適用し、ラテン文字書体の長音記号をPDFに収めます。

このページの内容
出力
Canvas · PDF
レベル
中級
Postext
Postext 1.65.0で検証済み
1.25.0以上が必要 · postext-pdf ≥ 1.25.0
ライセンス
2026年10月10日更新
コードMIT · 本文CC BY 4.0

1ページ(全4ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり148 × 210 mm
  • 1段
  • Source Serif 4 10.5/15
  • Noto Serif JP
  • Source Sans 3
  • 4ページ
  • レベル
  • Postext 1.65.0
  • 組版時間119 ms
  • コード131行

かんたんな説明

歌人の石川啄木が1909年に日本語をローマ字で書いた日記の最初の日付を組みます。各段落の下には、かなと漢字で書いた読みが入ります。

できあがり

石川啄木が1909年の春に東京でつけた日記『ローマ字日記』(Rōmaji nikki)の4ページです。妻に読まれないよう、啄木はこの日記をローマ字で書きました。組むのは手帳の表題の行と、最初の日付である4月7日の記述、「Kanasii koto da!」までです。日記はA5判の研究用の版として組みます。ローマ字はSource Serif 4で両端そろえにし、ハイフネーションは一切しません。各段落の下には、かなと漢字による読みをNoto Serif JPで、小さく、細く、字下げして入れます。啄木の綴りは日本式で(si、tu、hu)、長母音にはサーカムフレックスを付けます(Tôkyô)。編者の行は長音記号(マクロン)付きのヘボン式(Rōmaji)で、どちらもPDFまで届きます。

このレシピが答える質問

  • ローマ字で書いた日本語を組むには(言語タグ、ハイフネーション、PDFでの長音記号)?
  • 画面とPDFで、漢字を日本の字形で表示して日本語を組めるフォントは?

手短な答え

script.js · 35〜50行コード全体で見る
// ja-Latn is Japanese written in Latin script (BCP 47). Its language is ja, so the kana
// under each paragraph get the Japanese rules (kinsoku, 、。 spacing, the space after !)
// and the built-in strings are Japanese; and Japanese has no hyphenation patterns, so the
// rōmaji is never divided at a line end. English patterns would divide tatinobotta or
// Surigarasu by English syllables, not by the morae a Japanese reader hears.
const language = { locale: 'ja-Latn' }; // spread into the config
const bodyText = {
  fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  textAlign: 'justify', firstLineIndent: em(1.2), indentAfterHeading: false,
  optimalLineBreaking: true, maxWordSpacing: 1.8, // no hyphens: the spaces take the slack
};
// The reading in kana, under its paragraph: smaller, a shade lighter, indented.
const kana = { id: 'kana', fontFamily: MINCHO, fontSize: pt(8.6), lineHeight: pt(LEAD),
  color: col('kana'), textAlign: 'justify', indent: em(1.5), firstLineIndent: em(1),
  marginTop: pt(LEAD / 4), marginBottom: pt(LEAD * 0.75) };

材料

種類
Source Serif 4, Source Sans 3, Noto Serif JP (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · 文章にja-Latnのタグを付ける

コードは上の手短な答えにあります。ja-Latnは、ラテン文字で書いた日本語を表すBCP 47のタグです。言語はjaなので、各段落の下の読みには日本語の規則が適用されます。禁則処理、句読点(、。)のアキ、そして「ええ! ええ!」のように文中の!のあとにエンジンが加える全角スペースです。日本語にはハイフネーションのパターンがないので、ローマ字は分割されません。enにすると英語のパターンがtatinobottaやSurigarasuのような語を、日本語の読み手が聞く拍ではなく英語の音節で分割してしまいます。ハイフンがないぶん語間が余りを吸収するので、行長は約70字、maxWordSpacingは1.8にしています(ハイフネーション)。

2ページ。日付、所番地、ローマ字の最初の2段落と、小さく字下げして組んだそのかなの読み。

#2 · 長音記号をPDFに入れる

script.js · 201〜203行コード全体で見る
// Fontsource keeps ō ū ā in a latin-ext file. cjkPdfProvider serves Noto Serif JP from its
// slices, and adds that file after the latin one for a Latin face whose text needs it.
offerPdf(() => renderToPdf(doc, { fontProvider: cjkPdfProvider }), `${RECIPE}.pdf`);

Fontsourceは、ō ū āを専用のlatin-extファイルに分けています。画面はそれを読み込み(loadFontsがサンプルのōを見つけます)、キットのcjkPdfProviderもPDF用に同じことをします。このプロバイダーはNoto Serif JPを日本語用の分割ファイルから提供し、latin-extにしかない文字をラテン文字の書体が組むときは、latin、次にlatin-extの2つのファイルを返します。postext-pdfは、各グリフをそのグリフを含む最初のファイルから取ります。キットの素のfontsourceProviderはPDFにlatinファイルしか渡さないので、それを使うとPDFにōのグリフがなくなります。

#3 · 日記自身の行で始める

script.js · 54〜86行コード全体で見る
const onField = { color: col('paper'), align: 'center', overflow: 'wrap' };
const title = {
  id: 'title', numbered: false, toc: false, span: 'page', runningChapter: false,
  breakBefore: { enabled: true, parity: 'any' }, // its page is an opener: no running heads
  advancedDesign: { enabled: true, minHeight: mm(166), slot: { elements: [
    { kind: 'box', id: 'field', style: { backgroundColor: col('indigo') },
      placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { width: 'fill',
        height: 'fill' } } },
    { kind: 'text', id: 'lines', content: '{attr.lines}', ...onField, fontFamily: SERIF,
      fontWeight: 600, fontSize: pt(20), lineHeight: 1.9, letterSpacing: pt(5),
      placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(18) } } },
    { kind: 'rule', id: 'rule', thickness: pt(0.5), color: col('paper'),
      placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(122) },
        size: { width: mm(24) } } },
    { kind: 'text', id: 'note', content: '{attr.note}', inlineMarks: true, ...onField,
      fontFamily: SANS, fontSize: pt(8.5), lineHeight: 1.5, placement: { anchor: { to:
        'container', edge: 'top' }, offset: { y: mm(130) }, size: { width: mm(84) } } },
  ] } },
};
// The entry: its day as a heading, the address under it from an attribute.
const entry = {
  level: 2, fontFamily: SANS, fontWeight: 600, fontSize: pt(10), letterSpacing: pt(2.5),
  color: col('indigo'), marginTop: pt(LEAD), marginBottom: pt(LEAD), advancedDesign: {
    enabled: true, minHeight: pt(2 * LEAD), slot: { elements: [
      { kind: 'text', id: 'day', content: '{titleText}', fontFamily: SANS, fontWeight: 600,
        fontSize: pt(10), letterSpacing: pt(2.5), color: col('indigo'),
        placement: { anchor: { to: 'container', edge: 'top-left' } } },
      { kind: 'text', id: 'place', content: '{attr.place}', fontFamily: SANS, fontSize: pt(7.5),
        letterSpacing: pt(1), color: col('muted'), overflow: 'wrap', align: 'left',
        placement: { anchor: { to: 'container', edge: 'top-left' }, offset: { y: pt(LEAD) },
          size: { width: 'fill' } } },
    ] } },
};

手帳はNIKKI. I. MEIDI 42 NEN. 1909. APRIL. TOKYO.で始まり、1行に1項目です。表題の見出しはそれを属性から取り、\nごとに改行し、手帳の表紙の布を思わせる藍色の地に、字間を広げたキャピタルで組みます。このページは章扉なので、柱は付きません。

#4 · 奇偶で分ける柱

script.js · 90〜99行コード全体で見る
const head = (id, content, parity, edge) => ({ kind: 'text', id, content, parity,
  pages: 'body', fontFamily: SANS, fontSize: pt(7.5), letterSpacing: pt(1.5), color: col('muted'),
  placement: { anchor: { to: 'page', edge }, offset: { y: mm(13), // 'top' centres on the page
    x: mm(edge.endsWith('left') ? 16 : edge.endsWith('right') ? -16 : 0) } } });
const header = { elements: [
  head('folio-even', '{pageNumber}', 'even', 'top-left'),
  head('book', 'ROMAZI NIKKI · 1909', 'even', 'top'),
  head('place', 'TOKYO · APRIL', 'odd', 'top'),
  head('folio-odd', '{pageNumber}', 'odd', 'top-right'),
] };

偶数ページには日記の名前、奇数ページには場所と月が入り、ノンブルは小口側の隅に置きます。書体は7.5 ptのSource Sans 3です。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 130 · Japanese in Latin letters: Takuboku's Rōmaji Diary ════
// https://postext.dev/en/cookbook/romaji-nikki
// Code: MIT · Text: Ishikawa Takuboku, 1909 (public domain); transcription (CC BY 4.0)
// Fonts: Source Serif 4, Source Sans 3, Noto Serif JP (SIL OFL 1.1) · Needs postext ≥ 1.25.0
// A diary written in Japanese with Latin letters, and its reading in kana under each paragraph.
import { buildDocument, withLoadedFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the note; the diary is Japanese in both editions
const RECIPE = 'romaji-nikki';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: diary ink, a faded indigo, the cream of a notebook
const palette = {
  ink: '#22201d', // the rōmaji
  indigo: '#34497a', // the date and the title (8.4:1 on the paper)
  kana: '#5a554e', // the transcription, a step lighter than the text (7:1)
  rule: '#c9c1b2',
  muted: '#6f6a62', // running heads, folios, the note
  paper: '#fcfaf4',
};
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: 'indigo (defaults)', value: { hex: palette.indigo, model: 'hex' } },
];
// #endregion

const SERIF = 'Source Serif 4'; // the rōmaji: ô û â ê in latin, ō ū in latin-ext
const SANS = 'Source Sans 3'; // labels, running heads, folios, the note
const MINCHO = 'Noto Serif JP'; // the kana: Noto Serif JP's Latin is Source Serif's
const [BODY, LEAD] = [10.5, 15]; // pt

// #region answer: a Japanese text in Latin letters is tagged ja-Latn
// ja-Latn is Japanese written in Latin script (BCP 47). Its language is ja, so the kana
// under each paragraph get the Japanese rules (kinsoku, 、。 spacing, the space after !)
// and the built-in strings are Japanese; and Japanese has no hyphenation patterns, so the
// rōmaji is never divided at a line end. English patterns would divide tatinobotta or
// Surigarasu by English syllables, not by the morae a Japanese reader hears.
const language = { locale: 'ja-Latn' }; // spread into the config
const bodyText = {
  fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  textAlign: 'justify', firstLineIndent: em(1.2), indentAfterHeading: false,
  optimalLineBreaking: true, maxWordSpacing: 1.8, // no hyphens: the spaces take the slack
};
// The reading in kana, under its paragraph: smaller, a shade lighter, indented.
const kana = { id: 'kana', fontFamily: MINCHO, fontSize: pt(8.6), lineHeight: pt(LEAD),

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#ローマ字をヘボン式で書く

現代の版なら、日記をマクロン付きのヘボン式で綴り直すこともあります。TôkyôはTōkyōになります。PDFにはすでにōが入っているので、変わるのは本文だけです。綴りは編者によるものだと断る注記を残してください。

#拍の切れ目でハイフネーションする

狭い段でハイフンが必要なら、ローマ字の拍の切れ目にソフトハイフン(U+00AD)を入れます。コードではSu\u00adna-ho\u00adko\u00adriと書き、本文ではU+00ADを直接入力します。ja-Latnのタグを付けた文書が自分からハイフネーションすることはありませんが、語が収まらないときはソフトハイフンの位置で改行します。

よくあるつまずき

つまずき

日本語のテキストのタグは'ja'。zh-HansやLANGにしない

レシピの版はenとesですが、日本語のサンプルはどちらの版でも日本語です。`locale: LANG`では英語やスペイン語とタグ付けされ、中国語のタグでは中国語の規則で組まれます(開明式の約物、小書きの仮名が行頭に来てもよい、図の代わりに图、PDFでは中国の字形)。postext 1.30以降、このタグはテキストを組む言語(計測、描画、埋め込みに使う言語)でもあるので、'ja'以外のタグでは日本語の字形ではなく別の字形(中国語のタグでは中国の字形)になり、改行の位置も変わります。'ja'と書いてください。日本の地域(JLReqの改行と約物、ゴマの圏点、ルビの間隔、図と表の表示名)が選ばれ、ハイフネーションが切られます。リントは、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は中国語、日本語、韓国語のファミリーを、ウェイトごとに約100個のファイルとして配信し、各ファイルが文字の範囲を受け持ちます。loadFontsが取得するのはlatinファイルだけなので、画面では漢字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、漢字が空の四角で印字されます。キットのcjkブロックを挙げ、loadFontsのあとにloadCjkFonts(FONTS, markdown)を呼び(本で複数のCJK書体を使うときは、それぞれの書体で組むテキストを渡して書体ごとに1回)、renderToPdfにfontProvider: cjkPdfProviderを渡してください。どちらもテキストの文字を含むファイルを取得します。 中国語・日本語・韓国語のフォント →

  • Shippori Minchoにはōもūもありません。Noto Serif JPとSource Serif 4は、それをlatin-extのファイルに持っています。ヘボン式の文章に使う書体は、選ぶ前に確かめてください。
  • ラテン文字で書いた中国語はピンインで、すべての字にピンインを振った初級読本では漢字の上にルビとして組んでいます。啄木のローマ字はそれ自体が本文なので、注釈としてではなく、固有の語間で組むラテン文字の文章として組みます。

クレジット

レシピ
Ignacio Ferro
本文
  • Ishikawa Takuboku, ROMAZI NIKKI (the Rōmaji Diary), the entry of 7 April 1909 to “Kanasii koto da!”, in Latin letters as he wrote it, after the Iwanami Bunko edition (ed. Kuwabara Takeo, 1977) as transcribed on the blog 啄木の息 · Ishikawa Takuboku (1886–1912) · パブリックドメイン
  • The transcription into kana and kanji under each paragraph and the note on the text, written for this recipe · Postext Cookbook · CC BY 4.0
フォント
Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1) · Noto Serif JP (SIL OFL 1.1)
SandboxPDF