跳到主要内容
食谱编号62

排版食谱 · 第2章 · 字体与文字

图形诗:赫伯特的Easter Wings,逐行居中

乔治·赫伯特的Easter Wings和The Altar排成居中的正文,每行诗一个段落,诗行的长短画出两个图形。

本页内容
类型
诗歌
输出
Canvas
难度
基础
Postext
已用Postext 1.65.0测试
需要≥ 1.25.0
许可证
更新于2026年10月11日
代码MIT · 文本CC BY 4.0

第2–3页,共4页

  • 英文样例:尚无中文版本
  • 成品尺寸148 × 210 mm
  • 1栏
  • IM Fell English 12.4/17
  • IM Fell English SC
  • IM Fell Great Primer
  • 4页
  • 难度
  • Postext 1.57.1
  • 排版用时50 ms
  • 99行代码

简单来说

两首英国古诗,诗行排出来像图画,一首是祭坛,一首是一对翅膀。每行只是居中,长短不同就拼出了形状。

成品一览

一本四页A5的纪念小册,由一张A4纸对折而成,收录乔治·赫伯特The Temple中的两首图形诗,拼写依照1633年初版。扉页仿照1633年版,连《诗篇》第29篇的题词也照样保留。内页中,The Altar与Easter Wings相对。两首诗都没有一行靠缩进或空格来调整;每行都居中,于是祭坛立在一根窄窄的支柱上,翅膀的每个诗节收窄到两个词再放宽。最后一页在赫伯特的箴言下有一段说明,讲1633年的印刷商如何把翅膀横着排,版权信息一行比一行短。全部内容都用IM Fell字体排成正文或三级标题之一,不用具名样式,也不用页面设计。西班牙语版排的是一个逐行对应的译本,保留了两个图形。

这道食谱解答

  • 空行不起作用时,怎样在两个块之间加额外的垂直间距?
  • 怎样排诗歌:每句一行,诗节间留空,折行悬挂缩进,不断词?
  • 怎样排题词、献词、署名,或带大号引号的引文框?
  • 怎样强制分页或分栏,并让每章都从右页开始?

简短回答

script.js · 第26–38行在完整代码中
// Postext joins the lines of a Markdown paragraph, so every line of the poem is a paragraph
// of its own, with a blank line after it. Centred, each line keeps its natural width on the
// axis of the measure, and the lengths Herbert gave his lines draw the figure:
//   Lord, who createdst man in wealth and store,
//
//   Though foolishly he lost the same,
//
//   Decaying more and more,
const verse = {
  fontFamily: 'IM Fell English', fontSize: pt(12.4), lineHeight: pt(LEAD), color: col('ink'),
  textAlign: 'center', // ragged on both sides; only justified text is hyphenated by default
  firstLineIndent: pt(0), // the default 1.5 em moves every line 3.3 mm off the titles' axis
};

用料

类型
IM Fell English, IM Fell Great Primer, IM Fell English SC(SIL OFL 1.1)
素材
无:所有图片都用代码绘制

做法

#1 · 一行诗就是一个居中的段落

代码见上文简短回答。Postext会把Markdown段落中的各行连成一行,所以每行诗都是一个段落,后面跟一个空行。textAlign: 'center'把每行按其自然宽度排在行长的中轴上;而默认只对两端对齐的文字断词(除非打开hyphenation.ragged),所以没有词被拆开(正文)。每行都是所在段落的首行,所以默认1.5 em的首行缩进会把它推到标题中轴右侧3.3 mm处;firstLineIndent: pt(0)让诗和标题保持在同一条中轴上。

#2 · 行长要容得下最长的一行

script.js · 第42–47行在完整代码中
// A line too long for the measure wraps, and both halves are centred, which adds a step to
// the outline.
// The widest line, 'Lord, who createdst man in wealth and store,', is 80.7 mm in 12.4 pt
// Fell, so the 110 mm measure takes every line of both poems whole.
const TRIM = { w: 148, h: 210 }; // mm: A5, one A4 sheet folded once
const MARGIN = { top: 22, bottom: 24, inner: 17, outer: 21 }; // mm: the measure is 110 mm

放不下的行会折行,折出的两半各自居中,于是轮廓上多出一个赫伯特原图中没有的台阶。行长为75 mm时,The Altar有三行、Easter Wings有两行会折行,小册会增加到六页。这里最宽的一行是Easter Wings的第一行,英语为80.7 mm,西班牙语为80.0 mm,所以A5页面上110 mm的行长能让每一行完整排下。

#3 · 简朴的居中标题

script.js · 第51–71行在完整代码中
// headings.textAlign centres every level. The Fell faces ship weight 400 only, so no level
// asks for bold.
const titles = {
  fontFamily: 'IM Fell Great Primer', fontWeight: 400, color: col('violet'), textAlign: 'center',
  levels: [
    // The keepsake's title opens page 1, where a break changes nothing; a second # title
    // would open on a recto.
    { level: 1, fontSize: pt(40), lineHeight: pt(LEAD * 3), textTransform: 'uppercase',
      marginBottom: pt(LEAD), breakBefore: { enabled: true, parity: 'odd' } },
    // A poem opens the next page, recto or verso: The Altar (page 2) faces Easter Wings.
    // A heading that opens a page drops its top margin, so the title is lowered by its
    // line box instead: three lines deep, it sets the title about 5 mm down. The default
    // half-em margin under it rounds up to a whole line, and each poem starts on line 5.
    { level: 2, fontSize: pt(24), lineHeight: pt(LEAD * 3), textTransform: 'uppercase',
      breakBefore: { enabled: true, parity: 'any' } },
    // The small-capital labels on pages 1 and 4: the sister face at the body size, with no
    // margins, since the :::space lines place them.
    { level: 3, fontFamily: 'IM Fell English SC', fontSize: pt(12.4), lineHeight: pt(LEAD),
      marginTop: pt(0), marginBottom: pt(0) },
  ],
};

各级标题都没有设计,只有字体设置,headings.textAlign让三级标题都居中(标题)。奇偶设为'any'时,每首诗从下一页开始,不论左右页,所以第2页的祭坛与第3页的翅膀相对。marginTop不能把这些标题往下移,因为开页标题上方的空白会被去掉。改由二级标题三行高的行框把每个标题降低约5 mm,两首诗都从版心第5行开始。一级标题是文档的开头,这里不需要分页;仍给它设了分页,是为了让第二个#标题从右页开始。三级标题用IM Fell English SC的小型大写字母、正文字号,排第1页和第4页的四个标签。

#4 · 用Markdown安排间距和分页

script.js · 第75–92行在完整代码中
// A blank line adds no space, so every gap on these pages is a :::space{lines=N}, which adds
// N lines of the 17 pt grid (one without the attribute). ## opens a page for each poem, and
// :::pagebreak opens the last page.
const config = () => ({
  colorPalette,
  locale: t({ en: 'en-us', es: 'es' }), // the language of each edition, and of its bundle
  page: { // mirror: left is the inner margin; 150 dpi is for the screen
    sizePreset: 'custom', width: mm(TRIM.w), height: mm(TRIM.h), dpi: 150,
    backgroundColor: col('paper'),
    margins: { top: mm(MARGIN.top), bottom: mm(MARGIN.bottom), left: mm(MARGIN.inner),
      right: mm(MARGIN.outer), mirror: true },
  },
  layout: { layoutType: 'single' }, // the default is two columns
  bodyText: verse, // a :ref added to these pages takes main-color, the ink, like bold and italic
  headings: titles,
  header: { elements: [] }, // a folded keepsake of four pages: no running heads,
  footer: { elements: [] }, // and no folios
});

段落之间的空行不增加间距,所以这几页上的每一处空白都来自:::space:Easter Wings的两个诗节之间一行,扉页上《诗篇》标签上方五行、题词下方十行(:::space)。按这些行数,第1页的出版信息在版心最后一行结束,《诗篇》上方和说明上方的两个标签都在第13行,距页顶94 mm。:::pagebreak开始最后一页(:::pagebreak)。版权信息也是每行一个段落,在短语结束处断开,所以四行逐渐收窄,形成尾饰。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 062 · Shaped verse: Herbert's Easter Wings, centred line by line ═
// https://postext.dev/en/cookbook/shaped-verse
// Code: MIT · Text: G. Herbert, The Temple, 1633 (PD; EEBO-TCP, CC0) · Spanish version: CC BY 4.0
// Fonts: IM Fell English, Great Primer and English SC (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'shaped-verse';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // every colour in the config links to one of these
  ink: '#241d29', // the text: a violet-black
  violet: '#5c2a6f', // the one accent: the titles and the small-capital labels
  paper: '#fbf7ee', // the sheet: an uncoated cream
};
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' } })),
  // Italic and bold take their colour from 'main-color' unless set. With 'main-color' in ink,
  // the italic subtitle, epigraph and motto print in ink instead of the default blue.
  { id: 'main-color', name: 'ink (defaults)', value: { hex: palette.ink, model: 'hex' } },
];
const LEAD = 17; // pt: the leading of every line, verse and prose alike

// #region answer: centred text, one line of verse to a paragraph
// Postext joins the lines of a Markdown paragraph, so every line of the poem is a paragraph
// of its own, with a blank line after it. Centred, each line keeps its natural width on the
// axis of the measure, and the lengths Herbert gave his lines draw the figure:
//   Lord, who createdst man in wealth and store,
//
//   Though foolishly he lost the same,
//
//   Decaying more and more,
const verse = {
  fontFamily: 'IM Fell English', fontSize: pt(12.4), lineHeight: pt(LEAD), color: col('ink'),
  textAlign: 'center', // ragged on both sides; only justified text is hyphenated by default
  firstLineIndent: pt(0), // the default 1.5 em moves every line 3.3 mm off the titles' axis
};
// #endregion

// #region measure: an A5 leaf whose measure holds the longest line whole
// A line too long for the measure wraps, and both halves are centred, which adds a step to
// the outline.
// The widest line, 'Lord, who createdst man in wealth and store,', is 80.7 mm in 12.4 pt
// Fell, so the 110 mm measure takes every line of both poems whole.
const TRIM = { w: 148, h: 210 }; // mm: A5, one A4 sheet folded once
const MARGIN = { top: 22, bottom: 24, inner: 17, outer: 21 }; // mm: the measure is 110 mm
// #endregion

组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)

变化

#每首诗从右页开始

奇偶设为'odd'时,The Altar和Easter Wings分别从第3页和第5页(都是右页)开始,小册增加到六页,第2、4页空白。

-      breakBefore: { enabled: true, parity: 'any' } },
+      breakBefore: { enabled: true, parity: 'odd' } },

#诗行齐左

用textAlign: 'left'时,每行都从页边距开始,两首诗只剩右侧的轮廓;其余正文(从副标题到版权信息)也都齐左,只有标题仍然居中。

-  textAlign: 'center', // 两侧不齐;默认只对两端对齐的文字断词
+  textAlign: 'left', // 右侧不齐;默认只对两端对齐的文字断词

常见问题

  • 对行长来说太长的诗行会折行,两半各自居中。选定字号和页边距之前,先量一量最宽的一行。诗行齐左、折行悬挂的排法,见逐行排诗。
  • 段落开头的空格会被去掉,所以不能用空格把一行垫成想要的形状。每行的宽度只取决于它的文字,译本必须找到与原作宽度相近的诗行,西班牙语版就是这样做的。
  • 居中让每行保持自然宽度,所以The Altar的台面和底座排不成方形:台面的第三、四行比前两行窄。两端对齐也无法把它们排方,因为两端对齐段落的最后一行保持自然宽度,而这里每一行都是一个独立的段落。
  • 扉页和最后一页都排满到网格的最后一行。扉页上多出一行,无论来自更长的题词、一行折行还是更大的:::space,都会把页脚的标签及其下两行挤到单独一页;最后一页多出一行,会把版权信息的最后一行单独挤到第五页。要在这两页上加一行,就从它上方的某个:::space中减去一行。
  • Postext不能像1633年的印刷商排Easter Wings那样把文字横过来排:只有整个图和表可以旋转。这里诗节是竖直排的,第4页的说明也提到了这一点。

致谢

文本
  • “The Altar” and “Easter wings”, the title, subtitle, byline and epigraph of the title page, and Herbert’s motto with a clause of the printers’ preface, from the first edition of The Temple (Cambridge, 1633) in the EEBO-TCP transcription (CC0 1.0); the letters and stops it marks as illegible or unknown at six line ends (four in The Altar, two in Easter wings) are supplied · George Herbert; Text Creation Partnership · 公有领域
  • Psalm 29:9 in the Spanish edition, from the Reina-Valera Bible of 1909 · Reina-Valera 1909 · 公有领域
  • The Spanish versions of both poems, of the subtitle, the motto and the printers’ clause, and the title-page imprint, the note on the text and the colophon of both editions, written for this recipe · Ignacio Ferro · CC BY 4.0
字体
IM Fell English (SIL OFL 1.1) · IM Fell Great Primer (SIL OFL 1.1) · IM Fell English SC (SIL OFL 1.1)
沙盒