Pular para o conteúdo principal
Receita número 108

Receitas · Capítulo 1 · Página e grade

Uma página de jornal árabe em duas colunas

Um diário árabe com locale 'ar': a primeira coluna é a da direita, as manchetes ocupam as duas e as notas breves vão em três colunas da direita para a esquerda.

Nesta página
Saída
Canvas · PDF
Postext
Testada com o Postext 1.65.0
Requer ≥ 1.65.0 · postext-pdf ≥ 1.65.0
Licença
Atualizada em 31 de out. de 2026
Código MIT · Texto CC BY 4.0

p. ١ · 1 de 2

  • Amostra em inglês: ainda sem edição em português
  • Refile 246 × 328 mm
  • 2 colunas, medianiz de 6 mm
  • Noto Naskh Arabic 10,7/16
  • Aref Ruqaa
  • Noto Kufi Arabic
  • 2 páginas
  • Nível
  • Postext 1.65.0
  • Diagramado em 175 ms
  • 167 linhas de código

Em poucas palavras

A primeira página e uma página interna de um jornal árabe. A matéria começa na coluna da direita e continua na da esquerda, do jeito que os leitores árabes leem a página.

O que você vai compor

Duas páginas de الساحل, um diário imaginário de uma cidade portuária imaginária, num formato compacto de 246 × 328 mm. A primeira página traz o nome do jornal em Aref Ruqaa de 84 pt, a matéria principal sobre o novo bonde da cidade sob uma manchete na largura da página e um mapa desenhado em código, e uma faixa de três notas breves no pé. A página 2 abre a seção local sob uma retranca azul, com cinco matérias e os horários de oração do dia. Tudo se lê a partir da direita: a primeira coluna de texto, as notas breves, as colunas da tabela, as orelhas do cabeçalho. A primeira página em inglês compõe os mesmos elementos da esquerda para a direita.

Esta receita responde a

  • Qual coluna vem primeiro em uma página árabe, e como componho um jornal em duas colunas?

A resposta curta

script.js · linhas 38–48no código completo
// locale 'ar' mirrors the page: the body's first column is the right one, the story runs down
// it and on at the top of the left one, and the column rule sits between them as before.
const layout = { layoutType: 'double', gutterWidth: mm(6),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
// A headline over both columns is a page-span box without a frame: the columns under it start
// level, right then left, and a box with placement="bottom" closes the page the same way.
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  titleStyle: { ...kufi(9, 700, 'sea'), gap: mm(1.2) }, // the kicker, from the fence's title
  marginTop: pt(0), marginBottom: pt(LEAD / 2),
  body: { fontFamily: TEXT, fontSize: pt(13), lineHeight: pt(21), textAlign: 'right' } };

Ingredientes

Tipografia
Aref Ruqaa, Noto Kufi Arabic, Noto Naskh Arabic (SIL OFL 1.1)
Materiais
Nenhum: todas as imagens são desenhadas em código

Preparo

#1 · Duas colunas, a primeira à direita

O código é a resposta curta logo acima. layoutType: 'double' e o fio entre colunas são as mesmas configurações de um jornal em inglês; locale: 'ar' vira a página, por isso a matéria preenche primeiro a coluna da direita e continua no alto da coluna da esquerda (Ordem das páginas e encadernação à direita). Uma manchete sobre as duas colunas é um boxe na largura da página sem moldura, e as colunas abaixo dela começam niveladas. A faixa de notas breves é um boxe na largura da página que flutua para o pé, com :::columns{count=3} dentro, e as colunas também correm da direita para a esquerda, assim como a tabela de horários de oração da página 2: uma tabela composta na direção do documento põe a primeira coluna à direita.

#2 · Um cabeçalho entre duas orelhas

script.js · linhas 52–68no código completo
const ear = (id, side, lines) => lines.map(([key, content, look], i) => text(`${id}-${key}`,
  content, { ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, 4)
    : at(`#${id}-${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(48) } }));
const nameplate = { enabled: true, minHeight: mm(46), slot: { elements: [
  text('name', '{titleText}', { fontFamily: NAME, fontSize: pt(84), fontWeight: 700,
    lineHeight: 1.1, color: col('sea'), align: 'center' },
  { ...at('container', 'top', 0, -3), size: { width: 'fill' } }),
  // In the mirrored page, 'right' is the start of the line: issue and date there, price opposite.
  ...ear('start', 'right', [['k', '{attr.issue}', kufi(8, 700, 'sea')],
    ['d', '{publishDate}', kufi(9, 400)]]),
  ...ear('end', 'left', [['k', '{attr.city}', kufi(8, 700, 'sea')],
    ['p', '{attr.price}', kufi(9, 400)]]),
  { kind: 'rule', id: 'thick', thickness: pt(2.5), color: col('ink'),
    placement: { ...at('container', 'top-left', 0, 40), size: { width: 'fill' } } },
  { kind: 'rule', id: 'thin', thickness: pt(0.5), color: col('ink'),
    placement: { ...at('#thick', 'below', 0, 0.8), size: { width: 'fill' } } },
] } };

O título de nível 1 da primeira página é o nome do jornal, pintado por um estilo de título. O design dele é desenhado na página espelhada, de modo que top-right é o início da linha: o número da edição e a data vão ali, a cidade e o preço na outra ponta (O que significam esquerda, direita, início e fim). A ruqʿa é uma letra de título para poucas palavras em corpo grande; não tem kashida, e o texto corrido nunca a usa.

#3 · Retrancas de seção e linhas de fólio

script.js · linhas 72–86no código completo
const flag = { enabled: true, minHeight: mm(13), slot: { elements: [
  { kind: 'rule', id: 'bar', thickness: pt(3), color: col('ink'),
    placement: { ...at('container', 'top-left', 0, 9), size: { width: 'fill' } } },
  text('flag', '{titleText}', { ...kufi(12, 700, 'paper'), align: 'right',
    box: { backgroundColor: col('sea'), padding: { top: mm(1), right: mm(3), bottom: mm(1.4),
      left: mm(3) } } }, at('#bar', 'above')),
] } };
// The folio line keeps its physical sides: the number at the outer corner of each page.
const folio = (parity, edge, x) => ({ kind: 'text', id: `n-${parity}`, parity,
  content: '{pageNumber}  ·  {title}  ·  {publishDate}', ...kufi(8, 600, 'muted'),
  align: edge, placement: at('page', `top-${edge}`, x, 7) });
const header = { elements: [folio('even', 'right', -SIDE), folio('odd', 'left', SIDE),
  { kind: 'rule', id: 'folio-rule', thickness: pt(0.5), color: col('rule'),
    placement: { ...at('page', 'top-left', SIDE, 11.5),
      size: { width: mm(TRIM.width - 2 * SIDE) } } }] };

Uma página interna abre com um título de nível 1 desenhado como retranca sobre um fio grosso. A linha do fólio é um cabeçalho, por isso mantém os lados físicos: a página 2, par, tem o número no canto direito, o externo num jornal que abre pela direita. A primeira página esvazia o cabeçalho no estilo de título.

#4 · Um mapa desenhado em código

script.js · linhas 266–296no código completo
function routeSvg() { // 222 × 44 mm, 1 unit = 1 mm
  const [W, H] = [222, 44];
  const coast = 'M0 36C30 33 52 40 80 35S128 24 152 28S196 37 222 31V44H0Z';
  // Eighteen stations along a line that leaves the port (east, on the right) for the university.
  const line = 'M210 22C186 17 170 13 150 16S112 25 92 20S56 9 34 12S14 19 10 17';
  const stops = Array.from({ length: 18 }, (_, i) => i / 17);
  const pointAt = (t) => { // the line as three cubic pieces, sampled per piece
    const seg = [[210, 22, 186, 17, 170, 13, 150, 16], [150, 16, 130, 19, 112, 25, 92, 20],
      [92, 20, 72, 15, 56, 9, 34, 12], [34, 12, 22, 14, 14, 19, 10, 17]];
    const k = Math.min(3, Math.floor(t * 4));
    const u = t * 4 - k;
    const [x0, y0, x1, y1, x2, y2, x3, y3] = seg[k];
    const b = (a, c, d, e) => (1 - u) ** 3 * a + 3 * (1 - u) ** 2 * u * c + 3 * (1 - u) * u * u * d
      + u ** 3 * e;
    return [b(x0, x1, x2, x3), b(y0, y1, y2, y3)];
  };
  const rings = stops.map((t, i) => {
    const [x, y] = pointAt(t);
    const big = i === 0 || i === 17 || i === 8;
    return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="${big ? 2.6 : 1.6}" `
      + `fill="${palette.paper}" stroke="${palette.ink}" stroke-width="${big ? 1 : 0.7}"/>`;
  }).join('');
  let grid = '';
  for (let x = 6; x < W; x += 12) grid += `M${x} 0V${H}`;
  for (let y = 6; y < H; y += 12) grid += `M0 ${y}H${W}`;
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${W * 10}" height="${H * 10}" `
    + `viewBox="0 0 ${W} ${H}"><rect width="${W}" height="${H}" fill="${palette.sand}"/>`
    + `<path d="${grid}" stroke="${palette.paper}" stroke-width="0.6"/>`
    + `<path d="${coast}" fill="${palette.sea}" fill-opacity="0.25"/>`
    + `<path d="${line}" fill="none" stroke="${palette.sea}" stroke-width="2.4"/>${rings}</svg>`;
}

O mapa do bonde é um SVG de traçados e círculos nas cores da paleta, sem nenhum texto: os nomes dos lugares ficam na legenda, na letra da página. O tipo de imagem não tem contador nem rótulo, porque jornais não numeram as fotos.

A receita completa

Sandbox
// ═══ Postext Cookbook · Nº 108 · A two-column Arabic newspaper page ══════════════════
// https://postext.dev/en/cookbook/arabic-newspaper-two-columns
// Code: MIT · Text: original Arabic news copy (CC BY 4.0) · Map: drawn in code
// Fonts: Aref Ruqaa, Noto Kufi Arabic, Noto Naskh Arabic (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the frame; the paper is Arabic in both editions
const RECIPE = 'arabic-newspaper-two-columns';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: newsprint, a cold ink and the sea blue of the paper's name
const palette = {
  ink: '#121416', // text and the heavy rules
  sea: '#0f5f7a', // the accent: the nameplate, section flags, kickers, the tram line
  sand: '#e9e2d2', // the In brief strip and the map's land
  rule: '#9b988f', // hairlines: the column rule, the folio line
  muted: '#5b5852', // bylines, captions' credits, the imprint
  paper: '#f8f5ee', // newsprint, and type reversed out of the flags
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [NAME, HEAD, TEXT] = ['Aref Ruqaa', 'Noto Kufi Arabic', 'Noto Naskh Arabic'];
const TRIM = { width: 246, height: 328 }; // mm: a 3 : 4 compact
const SIDE = 12; // mm: newspaper margins, narrow and not mirrored
const LEAD = 16; // pt: the body leading, 1.5 × an 10.7 pt Naskh
const kufi = (size, weight, colour = 'ink') => ({ fontFamily: HEAD, fontSize: pt(size),
  fontWeight: weight, color: col(colour) });
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
  ...look, placement });

// #region answer: two columns, the first one on the right
// locale 'ar' mirrors the page: the body's first column is the right one, the story runs down
// it and on at the top of the left one, and the column rule sits between them as before.
const layout = { layoutType: 'double', gutterWidth: mm(6),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
// A headline over both columns is a page-span box without a frame: the columns under it start
// level, right then left, and a box with placement="bottom" closes the page the same way.
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  titleStyle: { ...kufi(9, 700, 'sea'), gap: mm(1.2) }, // the kicker, from the fence's title
  marginTop: pt(0), marginBottom: pt(LEAD / 2),
  body: { fontFamily: TEXT, fontSize: pt(13), lineHeight: pt(21), textAlign: 'right' } };

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

#Três colunas nas notas breves, quatro numa página mais larga

A faixa é um boxe com colunas próprias, por isso pode ter mais que as duas do texto.

-:::columns{count=3 breaks="2,3"}
+:::columns{count=4 breaks="2,3,4"}

#Algarismos europeus para um jornal do Magreb

-  locale: 'ar', // written out, never LANG (gotcha: arabic-locale-tag): rtl, digits ٠–٩
+  locale: 'ar-MA', // rtl, digits 0–9

Erros comuns

Erro comum

Marque um livro árabe como 'ar', não com LANG

As edições de uma receita são en e es, mas uma amostra árabe é árabe nas duas: `locale: LANG` a comporia da esquerda para a direita, a encadernaria pela esquerda, numeraria as suas páginas 1 2 3 e chamaria as suas figuras de Figure ou Figura. Desde o postext 1.30 a marcação é também o idioma em que o texto é composto (em que é medido, pintado e incorporado), então, sob uma marcação inglesa ou espanhola, uma fonte como a Markazi Text não desenha as formas árabes das aspas angulares e dos pontos, e as linhas quebram em outro ponto. Escreva você mesmo a marcação: 'ar' (algarismos arábico-índicos, a convenção do Machrek), uma região como 'ar-EG' ou 'ar-SA', ou 'ar-MA', 'ar-DZ' ou 'ar-TN' para uma edição magrebina com algarismos europeus. Uma página latina que só cita árabe mantém o seu próprio locale. Texto da direita para a esquerda →

Erro comum

Fontes árabes precisam do seu arquivo arabic, pelo bloco arabic

O Fontsource serve Amiri, Noto Naskh Arabic ou Scheherazade New em um arquivo por subconjunto, e as letras árabes estão no arquivo arabic. loadFonts baixa só latin (e latin-ext), então na tela o árabe vem de uma fonte do sistema e é medido errado, e o fontsourceProvider entrega ao PDF esse arquivo latin, que imprime caixas vazias. Inclua o bloco arabic do kit, chame loadArabicFonts(FONTS, markdown) depois de loadFonts, com todos os pesos que as páginas usam em árabe listados em FONTS, e passe a renderToPdf fontProvider: arabicPdfProvider. Fontes árabes →

  • Os horários de oração estão digitados com algarismos arábico-índicos nas células da tabela: locale só muda os números que o motor escreve, de modo que uma edição do Magreb precisa digitá-los de novo.

Créditos

Texto
  • Two pages of an imaginary Arabic daily, الساحل, and its city, written in Arabic for the recipe · Postext Cookbook · original
Fontes
Aref Ruqaa (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1)
SandboxPDF