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

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

Обложка с окном на титул

Овальное окно, вырезанное в обложке через dieCuts и отмеренное по картине титула: край ложится на золотую раму, а линия вырубки на свою форму.

На этой странице

с. 1 из 10

  • Образец на английском: русского издания пока нет
  • Обрезной формат 130 × 195 мм
  • 1 колонка
  • EB Garamond 10,5/14
  • Cormorant Garamond
  • 10 страниц
  • Уровень
  • Postext 1.84.0
  • Свёрстано за 14 мс
  • Строк кода: 179

Коротко

Небольшая книга с рассказом По в твёрдой обложке с узором и овальным вырезом. В нём видно лицо с портрета, напечатанного на титуле под обложкой.

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

«Овальный портрет», рассказ Эдгара Аллана По 1842 года в более коротком тексте, напечатанном им в 1845-м, как книга в твёрдом переплёте из десяти страниц 130 × 195 мм. Обложка — старинная камка с прорезанным овальным окном. Под ней лежит титул, сам портрет в золочёной мавританской раме, а окно расположено так, что его край ложится на позолоту: у закрытой книги лицо обрамлено дважды, золотом и вырезом. Рассказ идёт на кремовой бумаге с буквицей, а задняя сторонка повторяет камку с текстом на тёмной панели. Файл для печати несёт контур окна на отдельной форме.

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

  • Как вырезать в обложке окно, в котором виден титульный лист?
  • Как отправить изготовителю штампа контур вырубки отдельной формой в PDF?

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

script.js · строки 41–48в полном коде
// The window is cut through the first leaf, so the closed book shows page 3 through it.
// Its size is measured on the title-page painting: a little wider than the frame's opening,
// so the cut edge falls on the gilt and the face sits in the middle of the hole.
const dieCuts = {
  shapes: [{ id: 'window', name: t({ en: 'Oval window', es: 'Ventana oval' }),
    shape: 'ellipse', x: mm(26), y: mm(15.7), width: mm(78), height: mm(102) }],
  pages: [{ pages: '1', die: 'window' }], // page 1, the front board
};

Ингредиенты

Шрифты
EB Garamond, Cormorant Garamond (SIL OFL 1.1)
Материалы
  • damask.jpg
  • portrait.jpg
  • Cover and back: a pomegranate damask (Generated With Diffusion Models, оригинал)
  • Title page: the oval portrait on a velvet wall (Generated With Diffusion Models, оригинал)

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

#1 · Окно, совмещённое с рамой

Код — в разделе «Короткий ответ» выше. Окно — это ellipse на странице 1, отмеренный от левого верхнего угла обрезного формата. Отверстие в странице 1 смотрит на страницу 3, поэтому меряйте его по картине титула: здесь проём рамы и её внешний край сняты с картинки в пикселях и переведены в миллиметры, а окно поставлено на треть ширины золочёной полосы, чтобы внутри выреза оставалось тонкое кольцо золота.

#2 · Картины, подвешенные к обрезному формату

script.js · строки 52–93в полном коде
// Both paintings are placed in trim millimetres, the same frame the die is measured in. The
// portrait is set a little larger than the page so the frame is centred on it (and on the
// window); the cover type sits on a dark cartouche below the window.
const bleed = (x, y, width, height) => ({ kind: 'image', id: 'painting',
  resourceId: '{attr.picture}', fit: 'cover', placement: at('page', 'top-left', x, y,
    { width: mm(width), height: mm(height) }) });
const sheet = bleed(-BLEED, -BLEED, WIDTH + 2 * BLEED, HEIGHT + 2 * BLEED);
const portrait = bleed(-3.6, -BLEED, 140, 210); // its oval centred at x = WIDTH / 2
const box = (id, y, h) => ({ kind: 'box', id, placement: at('page', 'top-left', 17, y,
  { width: mm(WIDTH - 34), height: mm(h) }), style: { backgroundColor: col('plate'),
  borderColor: col('gold'), borderWidth: pt(0.75) } });
const type = (id, content, y, size, extra = {}) => ({ kind: 'text', id, content,
  fontFamily: DISPLAY, fontSize: pt(size), lineHeight: 1.1, color: col('gold'),
  align: 'center', placement: at('page', 'top-left', 17, y, { width: mm(WIDTH - 34) }),
  ...extra });
const caps = { fontWeight: 600, textTransform: 'uppercase', letterSpacing: pt(2.2) };
const full = (elements) => ({ enabled: true, minHeight: mm(HEIGHT - TOP),
  slot: { elements } });
const bare = { numbered: false, toc: false, header: { elements: [] },
  footer: { elements: [] } };
// A plate's section drops the foot margin, so its design reaches the foot of the page.
const flush = (top = TOP, side = 0) => ({ margins: { top: mm(top), bottom: mm(0),
  left: mm(INNER + side), right: mm(OUTER + side) } });
const dark = { palette: { paper: palette.velvet }, marginTop: pt(0), marginBottom: pt(0) };
const behind = (el) => ({ ...el, reserve: false }); // painted under the section's text
const headingStyles = [
  { id: 'cover', ...bare, ...dark, ...flush(), advancedDesign: full([sheet,
    box('plate', 130, 44), type('title', '{title}', 138, 27, { italic: true, fontWeight: 500 }),
    type('author', '{author}', 159, 9.5, caps)]) },
  { id: 'titlepage', ...bare, ...dark, ...flush(), breakBefore: { enabled: true, parity: 'odd' },
    advancedDesign: full([portrait, type('title', '{title}', 146, 30,
      { italic: true, fontWeight: 500 }), type('author', '{author}', 166, 10, caps)]) },
  { id: 'colophon', ...bare, hidden: true, ...flush(132), breakBefore: { parity: 'any' },
    bodyStyle: { fontSize: pt(9), lineHeight: pt(12.5), color: col('muted'), textAlign: 'left' } },
  { id: 'tale', numbered: false, toc: true, breakBefore: { enabled: true, parity: 'odd' },
    marginTop: mm(30), marginBottom: pt(28),
    dropCap: { lines: 3, fontFamily: DISPLAY, color: col('ink'), gap: mm(1.2) } },
  // The back: the damask again, and the copy set in gold on a cartouche.
  { id: 'back', ...bare, ...dark, ...flush(74, 10), breakBefore: { enabled: true,
    parity: 'even' }, advancedDesign: { enabled: true, slot: { elements: [behind(sheet),
      behind(box('plate', 62, 78))] } } },
];

Вырубка меряется в миллиметрах от обрезного формата, и картины тоже. Камка выходит на вылет за формат с каждой стороны; портрет на несколько миллиметров шире, чтобы рама на картине была по центру страницы и окна. У обложки и титула нет нижнего поля, поэтому их дизайны доходят до низа страницы, и оба печатают название и автора из метаданных.

#3 · Линия вырубки на своей форме

script.js · строки 105–106в полном коде
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },

PDF печатает обложку целиком и обводит контур окна на сепарации Die, которая печатается с наложением и никогда не получает краски: изготовитель штампа читает по ней форму, а машина её пропускает. convertImages: false сохраняет картины как JPEG в sRGB, что PDF/X-4 допускает, и файл остаётся меньше мегабайта.

#4 · Закрытая книга на столе

script.js · строки 128–134в полном коде
  folio: {
    tilt: 34, yaw: 0,
    paper: { type: 'bookWove', shade: '#f6efe2' },
    binding: { type: 'hardcover', cover: 'pages', coverMaterial: 'paper' },
    surface: { type: 'walnut' },
    lighting: { environment: 'lamp', intensity: 1.15 },
  },

При binding.cover: 'pages' первая страница становится передней крышкой, поэтому Folio показывает книгу закрытой, с лицом в окне и стенками выреза, которые ловят свет лампы. Откройте обложку, чтобы увидеть титул целиком.

#5 · Плоская обложка, сквозь которую видно

script.js · строки 211–219в полном коде
const under = new Map();
const beneath = (i) => {
  if (!under.has(i) && doc.pages[i]) {
    const canvas = document.createElement('canvas');
    under.set(i, canvas);
    renderPageToCanvas(doc.pages[i], doc, canvas, { scale: 1, beneath });
  }
  return under.get(i);
};

На холсте beneath отдаёт отрисовке страницу 3 для окна обложки, и лицо видно и на плоской обложке. Под внутренней стороной обложки ничего нет, поэтому её отверстие показывает фон.

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

Sandbox
// ═══ Postext Cookbook · Nº 194 · A window cover that frames the title page ═══════════════
// https://postext.dev/en/cookbook/die-cut-window-cover
// Code: MIT · Text: Poe (PD) · Translation: CC BY 4.0 · Paintings: diffusion models
// Fonts: EB Garamond, Cormorant Garamond (SIL OFL 1.1) · Needs postext ≥ 1.84.0
//
// Poe's tale of a portrait in an oval frame, as a small hardback whose damask cover has an
// oval window cut through it. Closed, the book shows the face of the portrait on the title
// page through the window; the window's edge falls on the gilt of the painted frame.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createFolioFromDocument } from 'https://esm.sh/postext-folio';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'die-cut-window-cover';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: ink on cream inside; gold on a near-black for the cover and its plates
const palette = {
  ink: '#2b2320', // the text
  paper: '#f6efe2', // a cream book wove
  velvet: '#2a0d10', // the wall behind the portrait, and the endpapers
  plate: '#160c0b', // the cartouches on the damask
  gold: '#d9b36c', // the title type, the colour of the painted frame
  muted: '#6f6158', // the note on the text
};
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: 'gold (defaults)', value: { hex: palette.gold, model: 'hex' } },
];
// #endregion
const [WIDTH, HEIGHT, BLEED] = [130, 195, 3]; // mm: a small hardback, and its bleed
const [TOP, FOOT, INNER, OUTER] = [18, 24, 16, 19];
const [TEXT, DISPLAY] = ['EB Garamond', 'Cormorant Garamond'];
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });

// #region answer: one oval die through the cover, in register with the frame beneath
// The window is cut through the first leaf, so the closed book shows page 3 through it.
// Its size is measured on the title-page painting: a little wider than the frame's opening,
// so the cut edge falls on the gilt and the face sits in the middle of the hole.
const dieCuts = {
  shapes: [{ id: 'window', name: t({ en: 'Oval window', es: 'Ventana oval' }),
    shape: 'ellipse', x: mm(26), y: mm(15.7), width: mm(78), height: mm(102) }],
  pages: [{ pages: '1', die: 'window' }], // page 1, the front board
};

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

Варианты

#Назвать форму так, как её ждёт резак

Цифровые режущие столы ищут плашечную краску CutContour, обычно пурпурную, и волосную линию.

-    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },
+    dieLine: { output: 'page', ink: 'CutContour', cmyk: { c: 0, m: 100, y: 0, k: 0 },
+      width: pt(0.25) } },

#Круглое окно

Круг показывает одно лицо; рама остаётся скрытой под обложкой, пока её не откроют.

-    shape: 'ellipse', x: mm(26), y: mm(15.7), width: mm(78), height: mm(102) }],
+    shape: 'circle', x: mm(32), y: mm(24), width: mm(66), height: mm(66) }],

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

Рецепт
Ignacio Ferro
Текст
Изображения
  • Cover and back: a pomegranate damask · Generated With Diffusion Models · оригинал
  • Title page: the oval portrait on a velvet wall · Generated With Diffusion Models · оригинал
Шрифты
EB Garamond (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1)
SandboxPDF