In short
The opening of a famous comedy by Oscar Wilde, printed for actors. The speakers' names stand out in bold colour, and stage directions are in grey so they are easy to skip.
What you'll build
The opening of Oscar Wilde’s The Importance of Being Earnest, set as a five-page acting edition at 140 × 216 mm. The title page is a plum playbill in a double gold frame, with Importance and Earnest in fat-face capitals and a gold carnation under the title. Facing the first act, the cast list names the actor who created each part at the St James’s Theatre in 1895. Each speech opens with the speaker’s name in bold plum and hangs its turnover lines 5 mm, so an actor finds the next cue at a glance. Stage directions, inside a speech or between two, are grey italic, and the eye can skip them when running lines. The Spanish edition is a new translation that follows Spanish stage practice, with a dash after each name and the directions in parentheses.
This recipe answers
- How do I set a screenplay or a play: scene headings, character names, and dialogue indented from both sides?
- How do I colour key terms (bold or italic) in the body or inside boxes?
- How do I set unnumbered artwork: ornaments, vignettes, logos?
The short answer
// Speeches are plain paragraphs, the speaker's name in bold and each stage direction in
// italic; a direction between two speeches is a paragraph of its own, in a container:
// **LANE.** Yes, sir. *[Hands them on a salver.]*
// :::paragraphs{style="direction"}
// *[Enter Lane.]*
// :::
// The body's two emphasis colours then mark who speaks (plum) and what is done (grey).
const dialogue = {
fontFamily: TEXT, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('plum'), // **ALGERNON.**
italicColor: col('muted'), // *[Languidly.]*, in a speech or a paragraph of its own
minWordSpacing: 0.65, maxWordSpacing: 1.8, // justified (the default); limits inside 0.6–2
// A runt fix tracks by 5/1000 em at most (default 10). At 10, “that?” went up beside “as”
// and the speech stood darker than the ones around it; at 5 the word turns over.
maxRuntTracking: 5,
firstLineIndent: mm(5), hangingIndent: true, // the name at the margin, the turnovers hung
};
// Directions: smaller and centred, on the same grid. They are written *…* like the ones
// inside a speech, so both take the body's italic grey.
const direction = { id: 'direction', fontSize: pt(8.6),
textAlign: 'center', firstLineIndent: pt(0) };
A speech is a paragraph: the name in bold, the directions in italic
Ingredients
- Features
- Paragraph stylesBold, italic and their coloursTab stops and leadersIndents, alignment and paragraph spacingHeading levelsChapters that open on a rectoCustom resource typesFigures exactly hereHeading stylesCovers, title pages and colophonsHeading attributesPictures in page designsText, rules and boxes in page designsRunning heads and foliosHeads by page roleDocument metadataPaper colourSemantic colour palette
- Also uses
- Designed openersFigures and tables as resourcesRunning heads per sectionExplicit vertical space
- Type
- Libre Baskerville, Abril Fatface, Playfair Display SC (SIL OFL 1.1)
- Assets
- The title page’s frame and the carnation fleuron, drawn in code in the page’s palette (Ignacio Ferro, MIT)
Method
#1 · An act is a plain heading
const headings = {
fontFamily: LABEL, fontWeight: 400, color: col('ink'),
textAlign: 'center', // every level: the act, the cast list's heads, the scene
lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0), // whole lines of the grid
levels: [
{ level: 1, fontFamily: DISPLAY, fontSize: pt(24), lineHeight: pt(3 * LEAD),
color: col('plum'), textTransform: 'uppercase',
breakBefore: { enabled: true, parity: 'odd' } }, // a recto, facing the cast list
{ level: 2, fontSize: pt(13), lineHeight: pt(2 * LEAD) },
{ level: 3, fontSize: pt(9.5), color: col('plum') },
],
};
The act title is a first-level heading in Abril Fatface at 24 pt, with no design slot. textTransform sets it in capitals, and its three grid lines of 13.6 pt put the capitals 5.5 mm below the top of the text block (headings). textAlign: 'center' cannot be set per level, so it also centres the cast list’s headings and the Scene label. breakBefore with parity 'odd' starts the act on a recto, facing the cast list. The default, 'always-odd', would put two blank pages between them (break before).
#2 · The cast list is a row of dots to each actor
// A tab sends the actor to a stop at the end of the measure that ends the text there; the stop's
// leader fills the room before it with dots, from half an em after the person to half an em
// before the actor. The bill's head is a centred line in the face's own small capitals.
const person = { id: 'person', fontSize: pt(8.8), firstLineIndent: pt(0), textAlign: 'left',
tabStops: [{ position: 'end', align: 'end', leader: '.' }],
spaceBetween: pt(LEAD / 2) }; // a person every line and a half
const billHead = { id: 'bill-head', fontFamily: LABEL, fontSize: pt(8.5), color: col('plum'),
textAlign: 'center', firstLineIndent: pt(0), marginTop: pt(LEAD / 2),
marginBottom: pt(LEAD / 2) };
// The scenes: two stops, so `:tab Act I :tab Algernon’s flat` ends the act on the first
// (15 mm in) and starts the place on the second, 2 mm after it, as a two-column list would.
const scene = { id: 'scene', textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(LEAD / 2),
tabStops: [{ position: mm(15), align: 'end' }, { position: mm(17) }] };
Each person is a paragraph of the person style, the actor after :tab (tabs and tab stops). The style has one tab stop, at 'end', the end of the measure, and with align: 'end' the actor's name ends there. Its leader: '.' fills the room before the stop with full stops, half an em clear of the person and of the actor, and spaceBetween puts a person on every line and a half. The persons' names are bold, so they print in plum, as the speakers' names do in the dialogue. The original cast, the theatre and the date head the list in the bill-head style, centred in Playfair Display SC, whose lowercase letters are small capitals. The scenes take two stops: :tab Act I :tab … ends Act I on the first, 15 mm in, with align: 'end', so the three acts stand flush right on one column, and starts the place on the second, 2 mm after it. The time of the action is a centred line in the directions' style.
#3 · Ornaments with no number and no caption
// ::resource{id="fleuron"} sets it where it stands (gotcha: resource-double-quotes).
const unnumbered = (id, name, defaultPlacement) => ({ id, name, shortLabel: '', captionPrefix: '',
numberingTemplate: '{n}', resetOn: 'never', counterFormat: 'decimal', defaultPlacement });
const resourceTypes = [
unnumbered('ornament', 'Ornament', { position: 'here', width: 0.24, align: 'center' }),
];
A resource type with an empty captionPrefix and shortLabel prints its pictures bare (resource types). Its defaultPlacement puts the carnation where ::resource{id="fleuron"} stands, centred and 0.24 of the 107 mm measure wide, about 26 mm.
#4 · The title page is a heading style
// # The Importance of Being Earnest {style="playbill" small="The" big="Importance" …}
// Each attribute is a playbill line in its own face and size. The ground is an image that
// fills the sheet: the heading reserves down to its foot, so the cast list starts on page 2.
const line = (id, content, font, size, y, color, extra = {}) => ({ kind: 'text', id, content,
fontFamily: font, fontSize: pt(size), lineHeight: 1, color: col(color), align: 'center',
placement: { anchor: { to: 'page', edge: 'top' }, offset: { y: mm(y) } }, ...extra });
const tracked = (track) => ({ textTransform: 'uppercase', letterSpacing: pt(track) });
const playbill = {
id: 'playbill', span: 'page', // kept in the column, its foot would cut the ground
header: { elements: [] }, footer: { elements: [] }, // no heads on p. 2, no folio on p. 1
advancedDesign: { enabled: true, slot: { elements: [
{ kind: 'image', id: 'ground', resourceId: 'playbill',
placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { width: 'fill' } } },
line('kicker', '{subtitle}', LABEL, 8.5, 36, 'gilt', tracked(1.7)),
line('small', '{attr.small}', TEXT, 17, 51, 'paper', { italic: true }),
line('big', '{attr.big}', DISPLAY, 40, 60, 'paper', { textTransform: 'uppercase' }),
line('link', '{attr.link}', TEXT, 17, 78, 'gilt', { italic: true }),
line('name', '{attr.name}', DISPLAY, 60, 87, 'paper', { textTransform: 'uppercase' }),
line('author', '{author}', LABEL, 13, 133, 'paper', tracked(3)),
line('theatre', '{attr.theatre}', LABEL, 8, 170, 'gilt', tracked(1.6)),
line('premiere', '{attr.premiere}', TEXT, 8.5, 176, 'paper', { italic: true }),
] } },
};
# The Importance of Being Earnest {style="playbill" …} carries the title in four attributes, which the design sets in two faces: Abril Fatface at 40 and 60 pt for the nouns, Libre Baskerville italic at 17 pt for The and of Being (heading attributes). The plum ground, the frame and the carnation are one SVG drawn in code and anchored to the bleed (image elements). The style sets span: 'page' although the book has one column. Kept in the column, the design would be cut off at the foot of the text block, 23.3 mm above the foot of the sheet. The style’s empty header keeps the running heads off the cast list, which belongs to the same section, and its empty footer keeps the drop folio off the title page, where it would print plum on plum (heading styles).
The ground is an image element, and an opener reserves down to the foot of its images, so the heading holds the whole sheet: The Persons of the Play starts on page 2 with no :::pagebreak after the title, wherever the title page’s lines stand. A centred line with letterSpacing needs no correction either. The spacing after its last letter is left out of the centring, and OSCAR WILDE stands on the centre of the page.
#5 · Running heads that skip the act’s first page
const head = (id, content, parity, edge, x, style) => ({
kind: 'text', id, content, parity, pages: 'body', // never on openers or blank pages
fontFamily: LABEL, fontSize: pt(8.5), letterSpacing: pt(0.8), color: col('muted'),
textTransform: 'uppercase', ...style,
placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(11) } },
});
const folio = { fontFamily: TEXT, letterSpacing: pt(0), color: col('plum') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
head('verso-title', '{title}', 'even', 'top-left', OUTER + 8),
head('recto-act', '{chapterTitle}', 'odd', 'top-right', -(OUTER + 8)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
// The act's first page carries a drop folio instead, centred under the text block.
const footer = { elements: [{ ...head('drop-folio', '{pageNumber}', 'all', 'top', 0, folio),
pages: 'opener', align: 'center',
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(8) } } }] };
The verso carries the play’s title from the frontmatter and the recto the act, from {chapterTitle}, both in Playfair Display SC capitals with the folio in plum at the outer edge (text elements). The act’s first page counts as an opener because its first block is a heading that breaks the page, so pages: 'body' keeps the heads off it, and the footer gives it a drop folio instead.
The whole recipe
// ═══ Postext Cookbook · Nº 070 · Play script: cast list, speakers and stage directions ═══
// https://postext.dev/en/cookbook/stage-play
// Code: MIT · Text: Oscar Wilde, 1895 (PD, Gutenberg #844), Spanish: the Cookbook · Art: in code
// Fonts: Libre Baskerville, Abril Fatface, Playfair Display SC (OFL 1.1) · Needs postext ≥ 1.25.0
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'stage-play';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // every colour in the config links to one of these
ink: '#221b1f', // the dialogue: a near-black with a little plum in it
plum: '#5b2349', // the one accent: speakers' names, act titles, the title page's ground
gold: '#b48a45', // rules and ornaments
gilt: '#c9aa77', // gold lightened for small type on the plum ground (5.3:1)
muted: '#6c6168', // stage directions and running heads (5.5:1 on the paper)
paper: '#fbf6ec', // a cream stock
};
// A colour is its hex and the palette entry it follows.
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' } })),
// The engine's defaults link to 'main-color': point it at the accent, so nothing prints blue.
{ id: 'main-color', name: 'plum (defaults)', value: { hex: palette.plum, model: 'hex' } },
];
const [TEXT, DISPLAY, LABEL] = ['Libre Baskerville', 'Abril Fatface', 'Playfair Display SC'];
const [BODY, LEAD] = [9.4, 13.6]; // pt: the dialogue and its leading, the pitch of the grid
const TRIM = { width: 140, height: 216 }; // mm: 5½ × 8½ in, the acting-edition size
const [TOP, INNER, OUTER, LINES] = [20, 18, 15, 36]; // mm, and 36 lines to a full page
// #region answer: a speech is a paragraph: the name in bold, the directions in italic
// Speeches are plain paragraphs, the speaker's name in bold and each stage direction in
// italic; a direction between two speeches is a paragraph of its own, in a container:
// **LANE.** Yes, sir. *[Hands them on a salver.]*
// :::paragraphs{style="direction"}
// *[Enter Lane.]*
// :::
// The body's two emphasis colours then mark who speaks (plum) and what is done (grey).
const dialogue = {
fontFamily: TEXT, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('plum'), // **ALGERNON.**
italicColor: col('muted'), // *[Languidly.]*, in a speech or a paragraph of its own
minWordSpacing: 0.65, maxWordSpacing: 1.8, // justified (the default); limits inside 0.6–2
// A runt fix tracks by 5/1000 em at most (default 10). At 10, “that?” went up beside “as”
// and the speech stood darker than the ones around it; at 5 the word turns over.
maxRuntTracking: 5,
The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)
Variations
#Line the directions up with the turnovers
Set flush left with a 5 mm first-line indent, a one-line direction starts where the turnover lines of the speeches do, and the scene description becomes two indented paragraphs under its centred label.
const direction = { id: 'direction', fontSize: pt(8.6),
- textAlign: 'center', firstLineIndent: pt(0) };
+ textAlign: 'left', firstLineIndent: mm(5) };#Leave a line between speeches
paragraphSpacing: true adds a blank grid line after every speech. The English act then runs to five pages instead of three, the Spanish one to four.
firstLineIndent: mm(5), hangingIndent: true, // the name at the margin, the turnovers hung
+ paragraphSpacing: true,
};Pitfalls
Pitfall
::resource{id="…"} takes double quotes only
A block embed is recognised only as ::resource{id="…"} with double quotes; any other form stays in the text as a visible line. Figures exactly here →
- Every italic run in the dialogue takes
italicColor, emphasis included, so Lane’s emphatic is prints in the grey of the directions. The grey goes onbodyTextbecause most directions stand inside a speech, in the same paragraph as the emphasis; only roman type would keep the is in ink. - Three of Wilde’s speeches end on a word alone: information., you. and that? The runt fix can pull the third up onto the line before, but only with the 1 % of negative tracking that
bodyText.maxRuntTrackingallows by default, and the speech then stands darker than the ones around it.maxRuntTracking: 5halves that cap: that? turns over, and the line above it opens to 1.78 times the normal word space, inside the limit of 1.8. The English pages keep the three runts rather than change Wilde’s words. The Spanish translation was reworded wherever a line ended on a one-letter word or a syllable stood alone. - Names hyphenate like any other word: Au-gusta and Gwen-dolen break across lines on page 5. A word joiner (U+2060) inside Augusta keeps it whole, but it stretches the line above to 1.71 times the normal word space, so the English text keeps the hyphens.
- Playfair Display SC draws fi as a lowercase ligature on the canvas, so first would print a lowercase fi among small capitals. That is why the cast list’s head says The original cast.
Credits
- Recipe
- Ignacio Ferro
- Text
- The Importance of Being Earnest (1895): the persons and scenes of the play, the first cast and the opening of the first act · Oscar Wilde · public domain
- The Spanish translation of the extract, the cast list and the scenes · Postext Cookbook · original
- Images
- The title page’s frame and the carnation fleuron, drawn in code in the page’s palette · Ignacio Ferro · MIT
- Fonts
- Libre Baskerville (SIL OFL 1.1) · Abril Fatface (SIL OFL 1.1) · Playfair Display SC (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


