Перейти к основному содержанию
Рецепт номер 198

Рецепты · Глава 10 · Вывод и интеграция

Том серии с её каталогом на форзацах

Том XI серии из двенадцати книг в твёрдом переплёте: два ISBN у штрихкода, общий дизайн крышки и форзацы, на которых показана вся серия.

с. 1 · 27 из 29

  • Образец на английском: русского издания пока нет
  • Обрезной формат 120 × 185 мм
  • 1 колонка
  • Crimson Pro 11/15,2
  • Cormorant Garamond
  • Josefin Sans
  • 29 страниц
  • Уровень
  • Postext 1.93.0
  • Свёрстано за 114 мс
  • Строк кода: 238

Коротко

Книга в твёрдом переплёте из серии в двенадцать томов и её листы для типографии: крышка в цветах серии с номером тома и два форзаца, где показаны обложки и названия всех двенадцати книг.

Что получится

The Deceitful Marriage («Обманная свадьба»), одиннадцатая из двенадцати «Назидательных новелл» Сервантеса, как том XI серии, где каждая новелла выходит отдельной книгой в твёрдом переплёте. 26 страниц набраны Crimson Pro 11/15,2 на полосе 120 × 185 мм. Из них buildCover делает три листа для переплётчика: печатную крышку в бордовом цвете серии, с золотой рамкой вокруг иллюстрации и номером в золотом кольце, и передний и задний форзацы, которые делят серию между собой: тома I–VI открывают книгу, VII–XII закрывают, и каждая половина дана иллюстрациями на приклеенной стороне и нумерованным списком на свободной. Рядом со штрихкодом, который несёт ISBN тома, крышка печатает ISBN всего издания.

Рецепт отвечает на вопросы

  • Как напечатать том собрания с ISBN собрания и другими его книгами на форзацах?

Короткий ответ

script.js · строки 30–58в полном коде
// The collection is data of the book, beside its versions. The volume's barcode carries its
// own ISBN, and the collection's `isbn` prints as a line above the bars. `catalogue` lists
// the twelve titles with their cover pictures, and `volume` names the one this book is: the
// endpapers set the list and the pictures from it (section 4), this volume marked in both.
const collection = {
  name: t({ en: 'Exemplary Novels', es: 'Novelas ejemplares' }),
  isbn: '978-84-0000-200-8',
  catalogue: [
    work('The Little Gipsy Girl', 'La gitanilla', 'gitanilla'),
    work('The Generous Lover', 'El amante liberal', 'amante'),
    work('Rinconete and Cortadillo', 'Rinconete y Cortadillo', 'rinconete'),
    work('The Spanish-English Lady', 'La española inglesa', 'espanola'),
    work('The Licentiate Vidriera', 'El licenciado Vidriera', 'vidriera'),
    work('The Force of Blood', 'La fuerza de la sangre', 'fuerza'),
    work('The Jealous Estremaduran', 'El celoso extremeño', 'celoso'),
    work('The Illustrious Scullery-Maid', 'La ilustre fregona', 'fregona'),
    work('The Two Damsels', 'Las dos doncellas', 'doncellas'),
    work('The Lady Cornelia', 'La señora Cornelia', 'cornelia'),
    work('The Deceitful Marriage', 'El casamiento engañoso', 'casamiento'),
    work('The Dialogue of the Dogs', 'El coloquio de los perros', 'coloquio'),
  ],
};
collection.volume = collection.catalogue[VOLUME - 1].id;
const production = {
  collection,
  // A printed case with a flat spine: the case sheet and two endpapers, no jacket.
  versions: [{ id: 'hardcover', name: t({ en: 'Hardcover', es: 'Tapa dura' }),
    binding: 'case-flat', isbn: '978-84-0000-198-8', isbnAddOn: '90000' }],
};

Ингредиенты

Шрифты
Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1)
Материалы
  • amante-320.jpg
  • casamiento-1000.jpg
  • casamiento-320.jpg
  • celoso-320.jpg
  • coloquio-320.jpg
  • cornelia-320.jpg
  • doncellas-320.jpg
  • espanola-320.jpg
  • fregona-320.jpg
  • fuerza-320.jpg
  • gitanilla-320.jpg
  • rinconete-320.jpg
  • vidriera-320.jpg
  • The front cover: a pale ensign leaning on his sword at the gate of the hospital of Valladolid, in oils (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 1, The Little Gipsy Girl, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 2, The Generous Lover, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 3, Rinconete and Cortadillo, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 4, The Spanish-English Lady, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 5, The Licentiate Vidriera, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 6, The Force of Blood, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 7, The Jealous Estremaduran, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 8, The Illustrious Scullery-Maid, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 9, The Two Damsels, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 10, The Lady Cornelia, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 11, The Deceitful Marriage, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)
  • The cover painting of volume 12, The Dialogue of the Dogs, on the endpapers, painted to match the front cover (Generated With Diffusion Models, оригинал)

Порядок работы

#1 · Серия — это данные книги

Код — в разделе «Короткий ответ» выше. В production.collection лежит серия: её название, её ISBN, catalogue с идентификатором, названием и картинкой для каждого тома и volume, идентификатор записи, которая и есть эта книга. isbn серии Postext печатает рядом со штрихкодом: строка чёрным 6,5 пт над штрихами, «ISBN of the complete work», на языке книги. Версия, которая называет собственный workIsbn, печатает его. Оба ISBN — образцы из блока 978-84-0000, не присвоенные ни одной книге. Проверки конфигурации сообщают о volume, которого нет в каталоге, и об ISBN серии с неверной контрольной цифрой.

#2 · Одно оформление для всех томов

script.js · строки 63–80в полном коде
// Every position is in mm from the top-left corner of its zone (the case's front is
// 116 × 191 mm: the 120 × 185 trim, set back 7 mm at the joint, 3 mm square round it).
const box = (id, zone, x, y, width, height, color, extra) => ({ id, kind: 'box', zone, x, y,
  width, height, color: col(color), ...extra });
const picture = (id, zone, x, y, width, height, resourceId, extra) => ({ id, kind: 'image', zone,
  x, y, width, height, resourceId, fit: 'cover', ...extra });
// `basis`: the spine drawn on; a thicker book stretches the bands and keeps the badge centred.
const spine = { basis: { width: 10, height: 191 } };
const livery = [
  box('frame', 'front', 11.2, 59.2, 93.6, 105.6, 'gold'),
  picture('art', 'front', 12, 60, 92, 104, 'cover-art'),
  picture('badge', 'front', 51.5, 169, 13, 13, 'badge', { fit: 'contain' }),
  box('head-band', 'spine', 0, 13, 10, 0.8, 'gold', spine),
  box('foot-band', 'spine', 0, 160, 10, 0.8, 'gold', spine),
  picture('spine-badge', 'spine', 1, 167, 8, 8, 'badge', { fit: 'contain', ...spine }),
  // A paper label for the barcode, whose caption is set in black.
  box('label', 'back', 53, 147, 61, 40, 'bone'),
];

Дизайн крышки — один и тот же объект в каждом томе серии; меняются только VOLUME, иллюстрация и тексты. Каждый элемент размещается по зоне, в которой стоит, поэтому, если в другом томе больше страниц и толще корешок, передняя сторонка сдвигается вместе со своей панелью. На корешке basis записывает 10 мм, на которых чертились полосы: корешок в 8,3 или 14 мм растягивает их на свою ширину и держит кольцо с номером по оси. Подпись над штрихкодом печатается чёрным, поэтому штрихкод стоит на светлой этикетке.

#3 · У каждого форзаца свой дизайн

script.js · строки 84–99в полном коде
// The case takes the livery; each endpaper names a design in `sheets`. At the front the
// pastedown is the left page, at the back the right one: volumes I–VI open the book,
// VII–XII close it, the pictures always on the pastedown, in the case's colour. A catalogue
// element grids the titles' pictures in its box; `stroke` outlines this volume's.
const shelf = (first, last) => ({ id: `shelf-${first}`, kind: 'catalogue', zone: 'pastedown',
  x: 26.5, y: 18, width: 67, height: 149, columns: 2, gap: 7, first, last,
  stroke: { color: col('gold'), width: 0.8 } });
const endpaper = (first, last) => ({ background: col('endpaper'),
  zones: { pastedown: col('case') }, elements: [shelf(first, last)],
  verticalAlign: { flyleaf: 'middle' } });
const cover = {
  background: col('case'),
  elements: livery,
  verticalAlign: { back: 'top' },
  sheets: { endpaperFront: endpaper(1, 6), endpaperBack: endpaper(7, 12) },
};

cover.sheets даёт листу дизайн вместо дизайна обложки: здесь это endpaperFront и endpaperBack, у каждого свой фон, приклеенная сторона в цвете крышки и элемент catalogue. Это прямоугольник в зоне, который движок заполняет картинками названий от first до last, по columns в ряд с промежутком gap мм, причём каждая картинка закрывает свою ячейку. Название с идентификатором collection.volume обведено линией stroke элемента; на этих форзацах это золотая рамка вокруг тома XI. На форзацы оформление крышки не переходит: каждый лист рисует только свой дизайн. Если открыть книгу спереди, приклеенная сторона слева, а сзади справа, поэтому картинки всегда лежат на крышке.

Названия приходят из Markdown обложки, который обслуживает все листы. Фрейм, который называет свои листы, попадает только на них:

:::frame{slot="flyleaf" sheet="endpaperBack"}
:::paragraphs{style="ad-head"}
Exemplary Novels
:::
 
::catalogue{numbers="I" first=7 last=12}
:::

::catalogue заменяет названия каталога, по абзацу на каждое: место в виде счёта, который называет numbers, пробел в en и название. Строки берут стиль абзаца cover-catalogue, а строка этого тома — cover-catalogue-current; пен переопределяет оба, по центру шрифтом Crimson Pro, текущий тёмно-красным. Фрейм задней сторонки называет case jacket, поэтому на форзацы он не попадает.

#4 · Три листа из одной книги

script.js · строки 421–432в полном коде
const sheet = async (kind) => {
  const built = buildCover({ config, version: 'hardcover', pages: book.pages,
    markdown: coverText, metadata: book.metadata, resources, sheet: kind });
  if (!('config' in built)) throw new Error(built.issues.map((i) => i.kind).join(', '));
  // The barcode's digits name OCR-B, which no font server has: the label face sets them.
  for (const [id, bytes] of Object.entries(built.files)) {
    await loadSvg(id, new TextDecoder().decode(bytes)
      .replace(/font-family="[^"]*"/g, 'font-family="Josefin Sans"'));
  }
  return { built, doc: await buildDocumentWithFonts(built.content, built.config, kitFonts(FONTS)) };
};
const sheets = [await sheet('cover'), await sheet('endpaperFront'), await sheet('endpaperBack')];

Один и тот же вызов с sheet: 'cover', 'endpaperFront' и 'endpaperBack' делает крышку и два форзаца, каждый документом в одну страницу своего размера. 26 страниц округляются до двух тетрадей по 16 страниц, 16 листов по 240 мкм; с припуском 0,5 мм блок выходит толщиной 4,3 мм, а корешок крышки 8,3 мм, с двумя картонами по 2 мм. Надпись проверяется по корешку крышки, который шире минимума в 6 мм. PDF содержит 26 страниц, затем крышку и форзацы.

Рецепт целиком

Sandbox
// ═══ Postext Cookbook · Nº 198 · A volume of a collection, its endpapers the series ═══
// https://postext.dev/en/cookbook/collection-volume-endpapers
// Code: MIT · Text: Cervantes, tr. W. K. Kelly (public domain) · Art: diffusion models
// Fonts: Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1) · Needs postext ≥ 1.93.0
//
// Volume XI of the twelve Exemplary Novels, one novella per hardcover: the series livery on
// the case, two ISBNs by the barcode, the twelve titles of the collection on the endpapers.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
import { buildCover, workIsbnCaption } 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 = 'collection-volume-endpapers';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#2a211c', accent: '#7a2a22', muted: '#6c6258', paper: '#fbf7ee',
  case: '#5e1c1a', gold: '#d2ae6a', bone: '#f1e8d4', endpaper: '#ece0c6' };
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' } },
];
const VOLUME = 11; // this book's place in the collection
const roman = (n) => 'I II III IV V VI VII VIII IX X XI XII'.split(' ')[n - 1];
const work = (en, es, id) => ({ id, title: t({ en, es }), resource: `cat-${id}` });

// #region answer: the volume and its collection: two ISBNs and the series' catalogue
// The collection is data of the book, beside its versions. The volume's barcode carries its
// own ISBN, and the collection's `isbn` prints as a line above the bars. `catalogue` lists
// the twelve titles with their cover pictures, and `volume` names the one this book is: the
// endpapers set the list and the pictures from it (section 4), this volume marked in both.
const collection = {
  name: t({ en: 'Exemplary Novels', es: 'Novelas ejemplares' }),
  isbn: '978-84-0000-200-8',
  catalogue: [
    work('The Little Gipsy Girl', 'La gitanilla', 'gitanilla'),
    work('The Generous Lover', 'El amante liberal', 'amante'),
    work('Rinconete and Cortadillo', 'Rinconete y Cortadillo', 'rinconete'),
    work('The Spanish-English Lady', 'La española inglesa', 'espanola'),
    work('The Licentiate Vidriera', 'El licenciado Vidriera', 'vidriera'),
    work('The Force of Blood', 'La fuerza de la sangre', 'fuerza'),
    work('The Jealous Estremaduran', 'El celoso extremeño', 'celoso'),
    work('The Illustrious Scullery-Maid', 'La ilustre fregona', 'fregona'),
    work('The Two Damsels', 'Las dos doncellas', 'doncellas'),
    work('The Lady Cornelia', 'La señora Cornelia', 'cornelia'),
    work('The Deceitful Marriage', 'El casamiento engañoso', 'casamiento'),

Собранный script.js работает как есть: вставьте его в модульный скрипт любой страницы или откройте рецепт на CodePen. Папка рецепта на GitHub ↗ (открывается в новой вкладке)

Варианты

#Одеть крышку в суперобложку

У твёрдого переплёта flaps добавляет суперобложку, четвёртый лист с собственными клапанами. Штрихкод и ISBN всего издания переходят на её заднюю сторонку, а с ними и аннотация, чей фрейм называет jacket.

   versions: [{ id: 'hardcover', name: t({ en: 'Hardcover', es: 'Tapa dura' }),
-    binding: 'case-flat', isbn: '978-84-0000-198-8', isbnAddOn: '90000' }],
+    binding: 'case-flat', isbn: '978-84-0000-198-8', isbnAddOn: '90000', flaps: true }],

#Набрать следующий том

Для тома XII дизайн остаётся как есть: VOLUME называет запись каталога в collection.volume, поэтому номер в кольце, золотая рамка на форзацах и выделенное название следуют за ним. Markdown обложки, иллюстрация и ISBN — уже того тома.

-const VOLUME = 11; // this book's place in the collection
+const VOLUME = 12; // this book's place in the collection

Частые ошибки

  • В списке снимков листы идут после страниц книги: крышка — страница 27, на единицу больше числа страниц. Правка, которая добавит книге страницу, их сдвинет.
  • Проверка contentInConfig книги рецептов принимает строку, которую buildCover печатает над штрихкодом, за текст внутри дизайна. Пен вносит её в checks.contentInConfig.allow словами workIsbnCaption, функции, которой пользуется движок.
  • Элемент catalogue рисует только картинки. Список названий даёт ::catalogue в Markdown, поэтому лист без этой строки показывает иллюстрации без подписей под ними.
  • Цифры штрихкода названы шрифтом OCR-B, которого нет ни на одном сервере шрифтов. Загрузите штрихкод с font-family, который пен уже загружает, иначе PDF не соберётся.

Источники и лицензии

Рецепт
Ignacio Ferro
Текст
Изображения
  • The front cover: a pale ensign leaning on his sword at the gate of the hospital of Valladolid, in oils · Generated With Diffusion Models · оригинал
  • The cover painting of volume 1, The Little Gipsy Girl, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 2, The Generous Lover, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 3, Rinconete and Cortadillo, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 4, The Spanish-English Lady, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 5, The Licentiate Vidriera, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 6, The Force of Blood, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 7, The Jealous Estremaduran, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 8, The Illustrious Scullery-Maid, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 9, The Two Damsels, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 10, The Lady Cornelia, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 11, The Deceitful Marriage, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
  • The cover painting of volume 12, The Dialogue of the Dogs, on the endpapers, painted to match the front cover · Generated With Diffusion Models · оригинал
Шрифты
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)
SandboxPDF