かんたんな説明
ベッケルの伝説を2編収めた小さな並製本と、印刷所に渡す表紙の用紙です。表4、背、表1、折り込む2枚の袖がひと続きになっています。背の幅はページの厚みそのものなので、本から計算します。
できあがり
ベッケルの伝説2編、『The Spirits’ Mountain』と『The Emerald Eyes』(原題『El monte de las ánimas』『Los ojos verdes』)を、120 × 190 mm、袖60 mmの並製本にします。表紙を刷る用紙も一緒に作ります。Postextはまず37ページを組みます。半扉、扉、権利表記、目次、伝説ごとの扉、そしてCrimson Pro 11/15.2の本文です。次にbuildCoverがそのページを受け取り、用紙を組み立てます。後ろ袖、紹介文とバーコードの入った表4、背、モンカヨ山のふもとの廃墟の礼拝堂を描いた表1、前袖です。書名、副題、著者名は本のメタデータから、袖の文字は別のMarkdownファイルから取ります。
このレシピが答える質問
- 袖付き並製本の表紙用紙を、ページ数から背幅を求めて作るには?
手短な答え
// The book's own binding profile: PUR perfect binding in 16-page signatures, flaps of
// 60 mm whatever the trim. The spine is written nowhere: buildCover works it out from the
// laid-out pages, rounded up to whole signatures, on the paper of `folio.paper`.
const production = {
bindings: [{ id: 'pur-flaps', name: 'PUR perfect binding, 60 mm flaps', style: 'perfect',
signature: 16, measures: { flapWidth: 60, bleed: 3, spineAllowance: 0.5 } }],
versions: [{ id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' }],
};
// 100 g/m² bulky cream wove at a bulk of 2.4: each leaf is 100 × 2.4 = 240 µm thick.
const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
// The design: a night ground over the whole sheet and the painting on the front, into the
// bleed at head and foot and up to the flap's fold. The texts come from the cover Markdown,
// the title, subtitle and author from the book's metadata.
const cover = {
background: col('night'),
elements: [{ id: 'art', kind: 'image', zone: 'front', x: 0, y: -3, width: 118, height: 196,
resourceId: 'moncayo', fit: 'cover' }],
verticalAlign: { back: 'middle' },
};
材料
- 機能
- 表紙の用紙印刷版、ISBN、背幅表紙、扉、奥付見出しスタイルデザインした章扉ページデザインのテキスト・罫・ボックス文書のメタデータ段落スタイル目次柱とノンブルリソースとしての図と表セマンティックカラーパレットPDFの書き出しキャンバス上のページ
- 種類
- Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1)
- 素材
moncayo-1100.jpg- The front cover: a ruined chapel under the Moncayo on All Souls’ Night, in oils (Generated With Diffusion Models, オリジナル)
作り方
#1 · 袖は製本が、背は紙が決める
コードは上の手短な答えにあります。製本プロファイルには製本所の仕事の仕方を書きます。16ページ折のPUR無線綴じ、袖60 mm、裁ち落とし3 mm、糊の分として背に0.5 mm足す、という具合です。版にはISBNと5桁のアドオンを入れます。このISBNは見本の番号で、どの本にも割り当てられていません。背幅はどこにも書きません。37ページは3折、つまり48ページ・24枚に切り上げられ、100 g/m²で嵩高2.4の紙は1枚240 µmなので、24 × 0.24 + 0.5で背幅は6.3 mmになります。標準では6 mm未満の背には文字を入れません(spineText.minSpine)。この本が嵩高の紙を使うのはそのためです。
#2 · まず本文を組む
const [W, H, TOP, FOOT, INNER, OUTER, LEAD] = [120, 190, 20, 22, 18, 15.5, 15.2]; // mm, pt
const at = (to, edge, x, y, size) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
...(size && { size }) });
const text = (id, content, look, place) => ({ kind: 'text', id, content, align: 'center',
overflow: 'wrap', placement: place, ...look });
const face = (fontFamily, size, color, extra) => ({ fontFamily, fontSize: pt(size), color,
...extra });
const label = (size, color = col('muted')) => face('Josefin Sans', size, color, caps(size / 5));
const none = { header: { elements: [] }, footer: { elements: [] }, numbered: false, toc: false };
const design = (minHeight, elements) => ({ enabled: true, minHeight: mm(minHeight),
slot: { elements } });
const page = (parity) => ({ breakBefore: { enabled: true, parity } });
const rule = (id, y, to = 'page') => ({ kind: 'rule', id, direction: 'horizontal',
thickness: pt(0.6), color: col('accent'), placement: at(to, 'top', 0, y, { width: mm(10) }) });
const folioAt = (y, pages) => ({ elements: [text('f', '{pageNumber}',
{ ...face('Crimson Pro', 9, col('ink')), pages }, at('page', 'bottom', 0, y))] });
const serif = (size, extra) => face('Cormorant Garamond', size, col('ink'), extra);
const headingStyles = [
{ ...none, id: 'half-title', advancedDesign: design(60, [
text('t', '{title}', serif(17, { fontWeight: 500 }), at('page', 'top', 0, 62))]) },
{ ...none, ...page('odd'), id: 'title-page', advancedDesign: design(H - TOP - FOOT, [
text('t', '{title}', serif(27, { fontWeight: 600 }), at('page', 'top', 0, 46)),
text('s', '{subtitle}', serif(13, { italic: true }), at('page', 'top', 0, 58)),
rule('r', 67),
text('a', '{author}', label(8, col('accent')), at('page', 'top', 0, 72)),
text('tr', '{attr.translators}', face('Crimson Pro', 9.5, col('muted'), { italic: true }),
at('page', 'top', 0, 118, { width: mm(70) })),
text('i', '{attr.imprint}', label(7), at('page', 'bottom', 0, -26)),
]) },
// The rights at the foot of the verso, under a short rule.
{ ...none, ...page('even'), id: 'rights',
advancedDesign: design(92, [rule('r', 86, 'container')]) },
{ ...none, ...page('odd'), id: 'contents', advancedDesign: design(34, [
text('t', '{titleText}', label(8, col('accent')), at('container', 'top', 0, 14)),
rule('r', 21, 'container')]) },
// Each legend has a title leaf of its own (the contents point to it), then opens on the
// next recto, sunk 40 mm.
{ ...none, ...page('odd'), id: 'tale-title', toc: true, advancedDesign: design(90, [
text('k', '{attr.kicker}', serif(15, { fontWeight: 600, color: col('accent') }),
at('page', 'top', 0, 58)),
text('t', '{titleText}', serif(23, { fontWeight: 500 }), at('page', 'top', 0, 67)),
text('p', '{attr.place}', face('Crimson Pro', 10.5, col('muted'), { italic: true }),
at('page', 'top', 0, 79)),
rule('r', 88)]) },
{ ...page('odd'), id: 'tale', toc: false, advancedDesign: design(40, [
text('t', '{titleText}', serif(15, { fontWeight: 500, italic: true }),
at('container', 'top', 0, 16)),
rule('r', 25, 'container')]) },
{ ...none, ...page('any'), id: 'colophon', advancedDesign: design(70, [
rule('r', 60, 'container')]) },
];
const head = (id, content, parity) => text(id, content, { ...label(6.8), parity, pages: 'body' },
at('page', 'top', 0, 11));
本文はふつうのPostext文書で、そのページがすべて背幅に効きます。前付けは見出しスタイルを使い、そのデザインで書名、罫線、版元名をページ上の決まった高さに置きます。伝説ごとに専用の扉があり(目次が指すのはこの扉)、本文は次の奇数ページから40 mm下げて始まります。文字の大きさや余白を変えればページ数が変わり、次に組むとき背幅もそれについてきます。
#3 · 表紙のスタイルは本のスタイルと一緒に置く
const style = (id, fontFamily, size, lead, color, extra) => ({ id, fontFamily, fontSize: pt(size),
lineHeight: pt(lead), color, italicColor: color, firstLineIndent: mm(0), textAlign: 'left',
hyphenation: false, ...extra });
const caps = (tracking) => ({ fontWeight: 600, textTransform: 'uppercase',
letterSpacing: pt(tracking) });
const coverStyles = [
style('cover-title', 'Cormorant Garamond', 40, 40, col('bone'), { fontWeight: 600,
textAlign: 'center', marginTop: mm(12) }),
style('cover-subtitle', 'Cormorant Garamond', 15, 19, col('bone'), { italic: true,
textAlign: 'center' }),
style('cover-author', 'Josefin Sans', 8.5, 11, col('gold'), { ...caps(1.8),
textAlign: 'center', marginTop: pt(16) }),
style('cover-spine', 'Josefin Sans', 7.5, 9, col('bone'), { ...caps(1.2), textAlign: 'center' }),
style('cover-blurb', 'Crimson Pro', 10.5, 14.5, col('bone'), { marginBottom: pt(7) }),
style('cover-note', 'Crimson Pro', 10.5, 14.5, col('gold'), { italic: true }),
style('flap-head', 'Josefin Sans', 7.5, 10, col('gold'), caps(1.4)),
style('flap-text', 'Crimson Pro', 9.6, 13.2, col('bone'), { marginTop: pt(5) }),
];
用紙は本の設定で組むので、表紙の段落スタイルは権利表記や奥付のスタイルと同じリストに入ります。cover-title、cover-subtitle、cover-author、cover-spineは、buildCoverが配置するメタデータに付ける名前です。cover-blurb、cover-note、flap-head、flap-textは表紙のMarkdownが指定します。夜の地色の上では、文字は左揃えでハイフネーションなし、パレットの象牙色と金色で組みます。
#4 · 組んだページから用紙を作る
const built = buildCover({ config, version: 'paperback', pages: book.pages, markdown: coverText,
metadata: book.metadata, resources });
if (!('config' in built)) throw new Error(built.issues.map((i) => i.kind).join(', '));
// The barcode is the cover's own picture. Its digits name OCR-B, which no font server
// has: they are set in the label face, which the PDF embeds like the rest.
for (const [id, bytes] of Object.entries(built.files)) {
await loadSvg(id, new TextDecoder().decode(bytes)
.replace(/font-family="[^"]*"/g, 'font-family="Josefin Sans"'));
}
const sheet = await buildDocumentWithFonts(built.content, built.config, kitFonts(FONTS));
buildCoverはページ、メタデータ、表紙のMarkdownを受け取ります。Markdownには表4用の:::frameと、袖ごとに1つずつの:::frameがあります。返ってくるのはbuildDocumentWithFontsでほかの文書と同じように組める文書と、SVGファイルのバーコードです。バーコードの数字はOCR-Bを指定していますが、どのフォント配信サーバーにもないので、この例ではPDFがすでに埋め込むJosefin Sansに置き換えています。PDFには37ページのあとに用紙がそれ自身の大きさで続きます。印刷所が求めるのはこの形のファイルです。
レシピの全体
// ═══ Postext Cookbook · Nº 196 · A paperback cover with flaps, spine from the pages ═══
// https://postext.dev/en/cookbook/paperback-cover-with-flaps
// Code: MIT · Text: Bécquer, tr. C. F. & K. L. Bates (public domain) · Art: diffusion models
// Fonts: Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1) · Needs postext ≥ 1.92.0
//
// Two of Bécquer's legends as a 120 × 190 mm paperback with 60 mm flaps. Postext lays the
// pages out first; buildCover then makes the cover sheet from them, its spine as thick as
// the pages on their paper.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
import { buildCover } from 'https://esm.sh/postext/production';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'paperback-cover-with-flaps';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#25221e', accent: '#86472a', muted: '#6b645a', paper: '#fbf7ee',
night: '#16242a', gold: '#c99b4e', bone: '#eee5d1' }; // the last three: the cover's
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: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #region answer: the paperback: a printer's binding with 60 mm flaps, its ISBN, its paper
// The book's own binding profile: PUR perfect binding in 16-page signatures, flaps of
// 60 mm whatever the trim. The spine is written nowhere: buildCover works it out from the
// laid-out pages, rounded up to whole signatures, on the paper of `folio.paper`.
const production = {
bindings: [{ id: 'pur-flaps', name: 'PUR perfect binding, 60 mm flaps', style: 'perfect',
signature: 16, measures: { flapWidth: 60, bleed: 3, spineAllowance: 0.5 } }],
versions: [{ id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' }],
};
// 100 g/m² bulky cream wove at a bulk of 2.4: each leaf is 100 × 2.4 = 240 µm thick.
const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
// The design: a night ground over the whole sheet and the painting on the front, into the
// bleed at head and foot and up to the flap's fold. The texts come from the cover Markdown,
// the title, subtitle and author from the book's metadata.
const cover = {
background: col('night'),
elements: [{ id: 'art', kind: 'image', zone: 'front', x: 0, y: -3, width: 118, height: 196,
resourceId: 'moncayo', fit: 'cover' }],
verticalAlign: { back: 'middle' },
};
// #endregion
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#背の文字を上から下へ
英米の本は背を上から下へ読みます。標準の下から上へは、スペインやヨーロッパ大陸の習慣です。
versions: [{ id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
- flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' }],
+ flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000',
+ spineText: { direction: 'topToBottom' } }],#薄い紙に刷る
80 g/m²で嵩高2.2なら1枚176 µmで、背幅は4.7 mmに減り、6 mm必要な背の文字が消えます。
-const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
+const folio = { paper: { type: 'bookWove', grammage: 80, bulk: 2.2, shade: '#f7f1e3' } };よくあるつまずき
- キャプチャしたページの一覧では用紙が本のページのあとに来るので、その番号は本のページ数に1を足したものです。本が1ページ増えれば番号も変わります。
- バーコードの数字がPDFの見つけられないフォントを指定していると、書き出しに失敗します。SVGを読み込むとき、
font-familyをこの例が読み込み済みのフォントにしてください。
クレジット
- 本文
- The Spirits’ Mountain and The Emerald Eyes, translated by Cornelia Frances Bates and Katharine Lee Bates, from Romantic Legends of Spain (1909), Project Gutenberg eBook #50044 · Gustavo Adolfo Bécquer · パブリックドメイン
- El monte de las ánimas and Los ojos verdes, from the Obras (Madrid, Fernando Fe, 1885) as transcribed on Wikisource, accents modernised · Gustavo Adolfo Bécquer · パブリックドメイン
- 画像
- The front cover: a ruined chapel under the Moncayo on All Souls’ Night, in oils · Generated With Diffusion Models · オリジナル
- フォント
- Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)


