Em poucas palavras
O começo de uma comédia famosa de Oscar Wilde, impressa para os atores. O nome de quem fala se destaca em negrito colorido, e as rubricas ficam em cinza para que o ator possa pulá-las.
O que você vai compor
O começo de The Importance of Being Earnest, de Oscar Wilde, composto como uma edição para atores de cinco páginas em 140 × 216 mm. A folha de rosto é um cartaz cor de ameixa dentro de uma moldura dupla dourada, com Importance e Earnest em maiúsculas fat face e um cravo dourado sob o título. Diante do primeiro ato, o elenco dá o nome do ator que criou cada papel no St James’s Theatre em 1895. Cada fala abre com o nome do personagem em negrito ameixa e recua 5 mm as linhas seguintes, de modo que o ator acha a próxima deixa de relance. As rubricas, dentro de uma fala ou entre duas, vêm em itálico cinza, e o olho as salta quando o ator repassa o texto. A edição em espanhol é uma tradução nova que segue o costume do teatro em espanhol, com travessão depois de cada nome e as rubricas entre parênteses.
Esta receita responde a
- Como componho um roteiro de cinema ou uma peça de teatro: cabeçalhos de cena, nomes de personagens e diálogo recuado dos dois lados?
- Como dou cor aos termos-chave (em negrito ou itálico) no texto ou dentro dos boxes?
- Como componho ilustrações sem numeração: ornamentos, vinhetas, logotipos?
A resposta curta
// 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) };
Ingredientes
- Funcionalidades
- Estilos de parágrafoNegrito, itálico e suas coresParadas de tabulação e pontilhadosRecuos, alinhamento e espaço entre parágrafosNíveis de títuloCapítulos que abrem em página ímparTipos de recurso personalizadosFiguras exatamente aquiEstilos de títuloCapas, folhas de rosto e colofõesAtributos de títuloImagens nos designs de páginaTextos, fios e caixas nos designs de páginaCabeços e fóliosCabeços por tipo de páginaMetadados do documentoCor do papelPaleta de cores semântica
- Também usa
- Aberturas desenhadasFiguras e tabelas como recursosCabeços por seçãoEspaço vertical explícito
- Tipografia
- Libre Baskerville, Abril Fatface, Playfair Display SC (SIL OFL 1.1)
- Materiais
- The title page’s frame and the carnation fleuron, drawn in code in the page’s palette (Ignacio Ferro, MIT)
Preparo
#1 · Um ato é um título comum
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') },
],
};
O título do ato é um título de nível 1 em Abril Fatface de 24 pt, sem espaço de design. textTransform o passa para maiúsculas, e as três linhas de 13,6 pt da grade que ele ocupa deixam as maiúsculas 5,5 mm abaixo do topo da mancha (títulos). textAlign: 'center' não aceita um valor por nível, por isso centraliza também os títulos do elenco e o rótulo Scene. breakBefore com paridade 'odd' leva o ato para uma página ímpar, diante do elenco. O padrão, 'always-odd', deixaria duas páginas em branco entre os dois (quebrar antes).
#2 · O elenco é uma fileira de pontos até cada ator
// 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) }] };
Cada personagem é um parágrafo do estilo person, com o ator depois de :tab (tabulações e paradas de tabulação). O estilo tem uma só parada, em 'end', o fim da medida, e com align: 'end' o nome do ator termina nela. O leader: '.' enche de pontos o espaço antes da parada, a meio em do personagem e do ator, e spaceBetween põe um personagem a cada linha e meia. Os nomes dos personagens estão em negrito, por isso saem em ameixa, como os nomes de quem fala no diálogo. O elenco original, o teatro e a data encabeçam a lista no estilo bill-head, centralizados na Playfair Display SC, cujas minúsculas são versaletes. As cenas usam duas paradas: :tab Act I :tab … termina Act I na primeira, a 15 mm da margem, com align: 'end', de modo que os três atos ficam alinhados à direita numa coluna, e começa o lugar na segunda, 2 mm depois. A época da ação é uma linha centralizada no estilo das rubricas.
#3 · Ornamentos sem número nem legenda
// ::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' }),
];
Um tipo de recurso com captionPrefix e shortLabel vazios imprime as imagens sozinhas (tipos de recurso). O defaultPlacement dele coloca o cravo onde está ::resource{id="fleuron"}, centralizado e com 0,24 da medida de 107 mm, uns 26 mm.
#4 · A folha de rosto é um estilo de título
// # 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" …} leva o título em quatro atributos, que o design compõe em duas famílias: Abril Fatface de 40 e 60 pt para os substantivos e Libre Baskerville itálico de 17 pt para The e of Being (atributos de título). O fundo ameixa, a moldura e o cravo são um único SVG desenhado em código e ancorado na sangria (elementos de imagem). O estilo usa span: 'page' embora o livro tenha uma só coluna. Preso à coluna, o design seria cortado no pé da mancha, 23,3 mm acima do pé da folha. O header vazio do estilo tira os cabeços do elenco, que pertence à mesma seção, e o footer vazio tira da folha de rosto o fólio no pé, que sairia em ameixa sobre ameixa (estilos de título).
O fundo é um elemento de imagem, e uma abertura reserva altura até o pé de suas imagens, por isso o título ocupa a folha inteira: The Persons of the Play começa na página 2 sem nenhum :::pagebreak depois da folha de rosto, onde quer que fiquem as linhas dela. As linhas centralizadas com letterSpacing também dispensam correção. O espaçamento depois da última letra não entra na centralização, e OSCAR WILDE fica no centro da página.
#5 · Cabeços que pulam a primeira página do ato
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) } } }] };
A página par traz o título da peça, tirado do front matter, e a ímpar o do ato, de {chapterTitle}, os dois em maiúsculas de Playfair Display SC, com o fólio em ameixa na margem externa (elementos de texto). A primeira página do ato conta como abertura porque o primeiro bloco dela é um título que quebra a página, de modo que pages: 'body' tira os cabeços dela, e o rodapé lhe dá no lugar um fólio no pé.
A receita completa
// ═══ 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,
O script.js montado funciona como está: cole-o como script de módulo em qualquer página ou abra a receita no CodePen. Pasta da receita no GitHub ↗ (abre em uma nova aba)
Variações
#Alinhar as rubricas com as linhas recuadas
Alinhada à esquerda e com um recuo de primeira linha de 5 mm, uma rubrica de uma linha começa onde começam as linhas recuadas das falas, e a descrição da cena vira dois parágrafos recuados sob o rótulo centralizado.
const direction = { id: 'direction', fontSize: pt(8.6),
- textAlign: 'center', firstLineIndent: pt(0) };
+ textAlign: 'left', firstLineIndent: mm(5) };#Deixar uma linha entre as falas
paragraphSpacing: true acrescenta uma linha da grade em branco depois de cada fala. O ato em inglês passa então de três para cinco páginas, e o em espanhol para quatro.
firstLineIndent: mm(5), hangingIndent: true, // the name at the margin, the turnovers hung
+ paragraphSpacing: true,
};Erros comuns
Erro comum
::resource{id="…"} só aceita aspas duplas
Uma inserção em bloco só é reconhecida como ::resource{id="…"} com aspas duplas; qualquer outra forma fica no texto como uma linha visível. Figuras exatamente aqui →
- Todo trecho em itálico do diálogo assume
italicColor, inclusive a ênfase, por isso o is enfático de Lane sai no cinza das rubricas. O cinza fica embodyTextporque a maioria das rubricas está dentro de uma fala, no mesmo parágrafo que a ênfase; só em redondo o is ficaria em tinta. - Três falas de Wilde terminam numa palavra sozinha: information., you. e that? A terceira pode subir para a linha anterior, mas só com o 1 % de tracking negativo que
bodyText.maxRuntTrackingadmite por padrão, e a fala fica mais escura que as vizinhas.maxRuntTracking: 5reduz esse teto à metade: that? desce para uma linha própria e a de cima se abre até 1,78 vez o espaço normal, dentro do limite de 1,8. As páginas em inglês ficam com as três linhas curtas para não mudar as palavras de Wilde. A tradução espanhola foi reescrita onde uma linha terminava numa palavra de uma letra ou onde uma sílaba ficava sozinha. - Os nomes são hifenizados como qualquer outra palavra: Au-gusta e Gwen-dolen se partem entre duas linhas na página 5. Um word joiner (U+2060) dentro de Augusta mantém o nome inteiro, mas estica a linha de cima até 1,71 vez o espaço normal, por isso o texto em inglês fica com os hífens.
- No canvas, a Playfair Display SC desenha fi como uma ligadura em minúscula, e first sairia com um fi minúsculo entre versaletes. Por isso a linha que encabeça o elenco diz The original cast.
Créditos
- Receita
- Ignacio Ferro
- Texto
- 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 · domínio público
- The Spanish translation of the extract, the cast list and the scenes · Postext Cookbook · original
- Imagens
- The title page’s frame and the carnation fleuron, drawn in code in the page’s palette · Ignacio Ferro · MIT
- Fontes
- Libre Baskerville (SIL OFL 1.1) · Abril Fatface (SIL OFL 1.1) · Playfair Display SC (SIL OFL 1.1)
- Código
- MIT, como o Postext
Editar este texto ↗ (abre em uma nova aba)Pasta da receita no GitHub ↗ (abre em uma nova aba)


