かんたんな説明
鋳造所の見本帳のように、同じ条文をロシア語からモンゴル語まで、キリル文字で書く十二の言語で組みます。語はその言語の規則で分かれ、ブルガリア語、セルビア語、マケドニア語は形の違う文字を見せます。
できあがり
205 × 260 mm、4ページの書体見本です。表紙は十二枚のタイルの壁で、一枚ごとに、ある字母に特有の文字が入ります。見開きには十二の項目が並び、左がスラヴ系の六言語、右がカザフ語、キルギス語、タタール語、バシキール語、タジク語、モンゴル語です。各項目に、言語名、朱の特殊文字、両端揃えの狭い段で組んだ世界人権宣言第1条、その言語の作家の一行、字母表が入ります。最後のページは地域字形を大きく示し、「図書館」を十二の言語で分綴します。
このレシピが答える質問
- 一つの文書に複数のキリル文字の言語を、それぞれの分綴と字形で組むには?
- スペイン語・フランス語・ドイツ語のテキストで、きれいな両端そろえとハイフネーションを得るには?
手短な答え
// The document is Russian, so that is what divides and shapes anything left unnamed. A
// passage names its language on its container:
// :::paragraphs{style="article" lang=bg}
// Its words are divided by Bulgarian patterns and kept together by Bulgarian rules; it is
// measured, painted and embedded with the Bulgarian forms (locl) the font holds, and tagged
// as Bulgarian in the HTML and the PDF. A run inside a line takes :ltr[…]{lang=bg}.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
textAlign: 'justify', firstLineIndent: pt(0),
// 54 mm hold about 32 letters: words are divided at two letters, the spaces give from
// 0.75 to 1.8 of the face's own, and a line takes up to 20 ‰ of tracking.
hyphenation: { leftMin: 2, rightMin: 2 }, minWordSpacing: 0.75, maxWordSpacing: 1.8,
maxJustifyTracking: 20, shapingLanguage: 'document', // the default: locale, then lang
};
const passages = [ // config().paragraphStyles
{ id: 'article', firstLineIndent: pt(0), marginBottom: pt(LEAD / 2) },
{ id: 'line', fontSize: pt(11.2), lineHeight: pt(LEAD), textAlign: 'left',
italicColor: col('red'), hyphenation: { enabled: false }, marginBottom: pt(LEAD / 2) },
{ id: 'abc', ...face(SANS, 8.4, 400, 'muted'), lineHeight: pt(11.4), textAlign: 'left',
hyphenation: { enabled: false } },
];
材料
- 機能
- 文書の言語としてのキリル文字の諸言語ハイフネーションと文書の言語逆方向の文字列行末で分けない語本文の書体段落スタイル文字スタイルタブストップとリーダーデザインした章扉見出しスタイル見出しの属性ページデザインのテキスト・罫・ボックス裁ち落としの帯とツメ表紙、扉、奥付見開きの余白用紙の色セマンティックカラーパレットPDFの書き出しPDFに埋め込むフォント
- 併用する機能
- 囲みの中や本文中の段組み段間罫節ごとの柱
- 種類
- Source Serif 4, Source Sans 3 (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 各文の言語を二度名指す
コードは上の手短な答えです。:::paragraphsのlangは本文の言語を示します。語を分けるパターンを選び、文字は書体がその言語用に持つ形で計測、描画、埋め込みされ、PDFとHTMLにその言語と標識されます。行の中の一部分には分離:ltr[…]{lang=bg}を使います。段は54 mmなので、二文字から分綴でき、一行に最大20 ‰の字間が入ります。
#2 · 見出し一つに四つの情報
// ## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}
const entry = { level: 2, fontFamily: SERIF, fontSize: pt(21), lineHeight: pt(26), fontWeight: 900,
marginTop: pt(0), marginBottom: pt(LEAD / 4),
advancedDesign: { enabled: true, minHeight: mm(25.4), slot: { elements: [
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(2.5), color: col('ink'),
placement: { ...at('container', 'top-left'), size: { width: 'fill' } } },
text('code', '{attr.code}', face(SANS, 8, 700, 'red', { textTransform: 'uppercase',
letterSpacing: pt(1.2) }), at('container', 'top-left', 0, 2.6)),
text('count', '{attr.letters}', face(SANS, 8, 400, 'muted', { align: 'right' }),
at('container', 'top-right', 0, 2.6)),
text('name', '{titleText}', face(SERIF, 22, 900, 'ink', { lineHeight: 1.1 }),
at('container', 'top-left', 0, 6.6)),
text('special', '{attr.special}', face(SERIF, 17, 700, 'red', { lineHeight: 1.2 }),
at('container', 'top-left', 0, 18)),
] } } };
言語コード、文字数、ロシア語にない文字は見出しに入ります:## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}。デザインが太い罫の下に刷り、minHeightがすべての項目の頭をそろえるので、同じ列の本文は同じ行から始まります。
#3 · 文字の壁
const [TILE_W, TILE_H] = [TRIM_W / 3, 52]; // mm
const INKS = ['red', 'ink', 'ochre', 'pine', 'cream', 'red', 'ink', 'ochre', 'pine', 'red', 'ink',
'cream']; // ink of each tile, row by row
const tile = (ink, i) => {
const place = { ...at('page', 'top-left', (i % 3) * TILE_W, Math.floor(i / 3) * TILE_H),
size: { width: mm(TILE_W), height: mm(TILE_H) } };
const letter = ink === 'cream' ? 'red' : ink === 'ochre' ? 'ink' : 'cream';
return [{ kind: 'box', id: `tile-${i}`, style: { backgroundColor: col(ink) }, placement: place },
text(`letter-${i}`, `{attr.l${i + 1}}`, face(SERIF, 108, 900, letter, { align: 'center',
verticalAlign: 'center', lineHeight: 1 }), place)];
};
const cover = { id: 'cover', breakBefore: { enabled: true, parity: 'any' },
header: { elements: [] }, footer: { elements: [] },
advancedDesign: { enabled: true, minHeight: mm(200), slot: { elements: [
...INKS.flatMap(tile),
text('title', '{titleText}', face(SERIF, 40, 900, 'ink', { lineHeight: 1.05, align: 'left' }),
{ ...at('page', 'top-left', SIDE, 4 * TILE_H + 10), size: { width: mm(TRIM_W - 2 * SIDE) } }),
text('subtitle', '{subtitle}', face(SANS, 13, 400, 'muted', { lineHeight: 1.3, align: 'left' }),
{ ...at('#title', 'below', 0, 2), size: { width: 'fill' } }),
] } } };
表紙の十二文字は見出しの属性l1からl12で、デザインは色の一覧から各文字の箱とテキストを作ります。文字の差し替えはMarkdownの変更だけです。タイルはページの角から並び、仕上がり線まで届きます。
#4 · 地域字形を一行ずつ
const tabs = (...at) => at.map((x) => ({ position: mm(x), align: 'start' }));
const formsStyles = [ // config().paragraphStyles
{ id: 'forms', fontSize: pt(29), lineHeight: pt(3 * LEAD), textAlign: 'left',
tabStops: tabs(26, 78), hyphenation: { enabled: false } },
{ id: 'weights', fontSize: pt(15.5), lineHeight: pt(2 * LEAD), textAlign: 'left',
hyphenation: { enabled: false } },
{ id: 'cuts', fontSize: pt(12), lineHeight: pt(1.5 * LEAD), textAlign: 'left', tabStops: tabs(22),
hyphenation: { enabled: false } },
{ id: 'colophon', ...face(SANS, 7.8, 400, 'muted'), lineHeight: pt(11), textAlign: 'left',
marginTop: pt(3 * LEAD), hyphenation: { locale: LANG, enabled: false } },
];
同じ文字列を、ロシア語、ブルガリア語の順で書体に通します。斜体はロシア語、セルビア語、マケドニア語です。Source Serif 4は三組とも持っています。タブ位置で行をそろえ、各行はその言語の分離です。変わる文字は強調と地域字形を見てください。
レシピの全体
// ═══ Postext Cookbook · Nº 209 · Twelve Cyrillic languages in one type specimen ═══════
// https://postext.dev/en/cookbook/cyrillic-specimen-twelve-languages
// Code: MIT · Text: UDHR, article 1 (UN, PD) and lines by twelve authors (PD) · Pictures: none
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.100.0
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the colophon ('en' | 'es' | 'ru')
const RECIPE = 'cyrillic-specimen-twelve-languages';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// The sheet of a type foundry between the wars: black, vermilion and two dull inks on cream.
const palette = {
ink: '#1d1b1a', // text, heavy rules, the dark tiles
red: '#b8321e', // the letters Russian lacks, the plates' titles, red tiles
pine: '#1f4b4a', // green tiles
ochre: '#d59b3a', // ochre tiles
cream: '#f6efdf', // the paper and the letters on the tiles
muted: '#655d51', // alphabets, author names, the colophon
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.red })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [SERIF, SANS] = ['Source Serif 4', 'Source Sans 3']; // both draw local forms by language
const [BODY, LEAD] = [10.5, 14]; // pt
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
...look, placement });
const face = (fontFamily, size, fontWeight, color, extra = {}) => ({ fontFamily,
fontSize: pt(size), fontWeight, color: col(color), ...extra });
// #region page: 84 × 108/16, 205 × 260 mm trimmed, three columns to a plate
const [TRIM_W, SIDE] = [205, 15]; // mm
const page = { sizePreset: '84x108/16', dpi: 150, backgroundColor: col('cream'),
margins: { top: mm(18), bottom: mm(17), left: mm(SIDE), right: mm(SIDE), mirror: true } };
const COLUMN_GAP = 6; // mm
// #endregion
// #region answer: each passage named in its own language, for its breaks and its letters
// The document is Russian, so that is what divides and shapes anything left unnamed. A
// passage names its language on its container:
// :::paragraphs{style="article" lang=bg}
// Its words are divided by Bulgarian patterns and kept together by Bulgarian rules; it is
// measured, painted and embedded with the Bulgarian forms (locl) the font holds, and tagged
// as Bulgarian in the HTML and the PDF. A run inside a line takes :ltr[…]{lang=bg}.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
よくあるつまずき
- 書体に字形が要ります。PT Serifにはこれらの言語用の形がなく、VollkornとLoraにはブルガリアとセルビアの形があります。なければ、分綴と標識は働きますが、文字はロシア語の形のままです。
- 文字そのものも要ります。Ә、Ғ、Ң、Ҙ、Ҷ、Ӯは書体の
cyrillic-extファイルにあり、kitCyrillicFontsが読み込みます。LiterataとSpectralには欠けるものがあります。
クレジット
- 本文
- Article 1 of the Universal Declaration of Human Rights in eleven languages, from the plain texts of the UDHR in XML project, with four misprints of the Kazakh, Kyrgyz and Tatar files corrected · United Nations · パブリックドメイン
- Article 1 in Bashkir · United Nations · パブリックドメイン
- Opening lines and sayings of Pushkin, Shevchenko, Kupala, Vazov, Vuk Karadžić, Racin, Abai, Toktogul, Tukay, Akmulla, Rudaki and Natsagdorj · The authors named · パブリックドメイン
- The titles, the alphabets and the colophon · Postext Cookbook · オリジナル
- フォント
- Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)


