Μετάβαση στο κύριο περιεχόμενο
Συνταγή αριθμός 176

Συνταγολόγιο · Κεφάλαιο 2 · Τυπογραφία και κείμενο

Ψηφία παλαιού τύπου, ευθυγραμμισμένα και πινακοειδή

Οι λογαριασμοί του Walden: το figureStyle δίνει ευθυγραμμισμένα ψηφία σε τίτλους μικρών κεφαλαίων, πινακοειδή στους λογαριασμούς, παλαιού τύπου στην πρόζα.

Σε αυτή τη σελίδα
Έξοδος
Canvas · PDF
Επίπεδο
Μεσαίο
Postext
Δοκιμασμένο με το Postext 1.65.0
Απαιτεί ≥ 1.65.0 · postext-pdf ≥ 1.65.0
Άδεια
Ενημέρωση: 31 Οκτ 2026
Κώδικας MIT · Κείμενο CC BY 4.0
  • Δείγμα στα αγγλικά: δεν υπάρχει ακόμη ελληνική έκδοση
  • Διάσταση σελίδας 140 × 216 mm
  • 1 στήλη
  • Alegreya 10,8/14,5
  • Alegreya SC
  • Alegreya SC@lnum
  • Alegreya Sans
  • Alegreya@tnum
  • 6 σελίδες
  • Επίπεδο
  • Postext 1.65.0
  • Σελιδοποίηση σε 124 ms
  • 160 γραμμές κώδικα

Με λίγα λόγια

Σύντομη έκδοση των οικιακών λογαριασμών που τύπωσε ο Thoreau στο Walden. Οι αριθμοί του κειμένου είναι μικροί σαν πεζά, οι χρονολογίες στις επικεφαλίδες ψηλές όσο τα κεφαλαία, και τα ποσά στοιχίζονται σε στήλες.

Τι θα στοιχειοθετήσετε

Μια σύντομη έκδοση των λογαριασμών που τύπωσε ο Thoreau στο πρώτο κεφάλαιο του Walden: πόσο κόστισε το σπίτι του, τι απέδωσε το χωράφι με τα φασόλια, τι έφαγε σε οκτώ μήνες. Στοιχειοθετείται σε σελίδα 140 × 216 mm με την οικογένεια Alegreya, με τη χαλκογραφία του 1854 με την καλύβα πάνω από την αρχή. Τα ψηφία αλλάζουν ανάλογα με τη δουλειά που κάνουν. Στο κείμενο, τα March, 1845 και $13.34 χρησιμοποιούν ψηφία παλαιού τύπου που ανεβαίνουν και κατεβαίνουν σαν πεζά γράμματα, έτσι οι ημερομηνίες δεν ξεχωρίζουν από τη γραμμή. Οι επικεφαλίδες είναι σε μικρά κεφαλαία, και οι χρονολογίες τους έχουν το ύψος των κεφαλαίων. Στους λογαριασμούς κάθε ψηφίο έχει το ίδιο πλάτος, έτσι τα σεντς δεκατριών γραμμών με σανίδες, πήχεις και καρφιά στέκονται το ένα κάτω από το άλλο ως το σύνολο.

Αυτή η συνταγή απαντά

  • Πώς στοιχειοθετώ ψηφία παλαιού τύπου στο κυρίως κείμενο, ευθυγραμμισμένα ψηφία στις επικεφαλίδες και ψηφία σταθερού πλάτους στους πίνακες;
  • Πώς στοιχειοθετώ μη αριθμημένα εικαστικά: κοσμήματα, βινιέτες, λογότυπα;

Η σύντομη απάντηση

script.js · γραμμές 34–55στον πλήρη κώδικα
// Alegreya's own figures are old-style, so the prose asks for none: the cut Fontsource
// serves has no onum, and 'oldstyle' would change nothing (see the write-up).
const bodyText = {
  fontFamily: TEXT, fontSize: pt(10.8), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  textAlign: 'justify', firstLineIndent: mm(4.5), indentAfterHeading: false,
  hyphenation: { enabled: true }, optimalLineBreaking: true,
  avoidWidows: true, avoidOrphans: true, avoidRunts: true,
};
// Small capitals take lining figures (lnum), at the height of the capitals around them.
const section = { level: 2, fontFamily: CAPS, fontSize: pt(12.5), lineHeight: pt(LEAD),
  fontWeight: 400, letterSpacing: pt(0.6), color: col('accent'), figureStyle: 'lining',
  marginTop: pt(LEAD), marginBottom: pt(0) };
// The accounts: every figure on one width (tnum), so the cents stand in columns.
// 'tabular' keeps the font's form, old-style; 'lining-tabular' would set them at cap height.
const tableStyle = {
  figureStyle: 'tabular', bodyFontFamily: TEXT, bodyFontSize: pt(9.8), bodyColor: col('ink'),
  rules: 'booktabs', groupRules: true, borderColor: col('rule'), lightRuleWidth: pt(0.4),
  heavyRuleWidth: pt(0.7), headerBackgroundEnabled: false, headerFontFamily: TEXT,
  headerFontSize: pt(9.8), headerColor: col('ink'), headerBold: false, headerItalic: false,
  cellPadding: mm(0.7),
};

Υλικά

Γραμματοσειρές
Alegreya, Alegreya SC, Alegreya Sans (SIL OFL 1.1)
Αρχεία
  • cabin-860.jpg
  • The vignette of Thoreau’s cabin from the title page of the first edition (1854), cropped and levelled to black on white (Ticknor and Fields, Boston, 1854 (engraver unknown), κοινό κτήμα)

Προετοιμασία

#1 · Ένα στιλ ψηφίων για κάθε στιλ κειμένου

Ο κώδικας είναι η σύντομη απάντηση παραπάνω. Το figureStyle ζητά από τη γραμματοσειρά ενός στιλ τα ψηφία OpenType της (στιλ ψηφίων). Το κυρίως κείμενο δεν ζητά τίποτα, γιατί τα ψηφία της ίδιας της Alegreya είναι ήδη παλαιού τύπου και αναλογικά: το 1 έχει πλάτος 342 μονάδες και το 0 533. Οι επικεφαλίδες επιπέδου 2 ζητούν από την Alegreya SC 'lining', τα ψηφία lnum της, που είναι ψηλά όσο τα κεφαλαία γύρω τους. Το στιλ του πίνακα ζητά 'tabular', τα tnum της γραμματοσειράς: τα ψηφία κρατούν τη μορφή παλαιού τύπου και παίρνουν όλα το ίδιο πλάτος, 450 μονάδες το καθένα, έτσι μια στήλη τιμών διαβάζεται ίσια προς τα κάτω. Το 'lining-tabular' θα τα έβαζε αντίθετα στο ύψος των κεφαλαίων (δείτε τις Παραλλαγές).

#2 · Οι λογαριασμοί είναι πίνακες πέντε στηλών

script.js · γραμμές 59–122στον πλήρη κώδικα
// A row starting '=' is a total (header cells: a light rule above it), '+' heads a group.
const C = (content, align = 'left', extra = {}) => ({ content, align, ...extra });
function account(tsv) {
  const rows = tsv.replace(/^\n+|\n+$/g, '').split('\n').map((line) => {
    const total = line.startsWith('='), group = line.startsWith('+');
    const [item, dollar, amount, fraction, remark] = line.replace(/^[=+]/, '').split('\t');
    if (group) return [C(item, 'left', { colSpan: 5, isHeader: true }),
      ...[1, 2, 3, 4].map(() => C('', 'left', { hiddenBy: { row: -1, col: 0 } }))];
    const h = { isHeader: total };
    return [C(item, 'left', h), C(dollar ? '\\$' : '', 'right', h), // `$` alone opens maths
      C(amount ?? '', 'right', h), C(fraction ?? '', 'left', h), C(remark ?? '', 'left', h)];
  });
  rows.forEach((row, r) => row.forEach((cell) => cell.hiddenBy && (cell.hiddenBy.row = r)));
  return { rows, headerRowCount: 0, columnWidths: [34, 2.4, 8, 3.6, 35] };
}
const accounts = String.raw`=== house
Boards,	$	8.03	½	mostly shanty boards.
Refuse shingles for roof sides,		4.00
Laths,		1.25
Two second-hand windows with glass,		2.43
One thousand old brick,		4.00
Two casks of lime,		2.40		That was high.
Hair,		0.31		More than I needed.
Mantle-tree iron,		0.15
Nails,		3.90
Hinges and screws,		0.14
Latch,		0.10
Chalk,		0.01
Transportation,		1.40		I carried a good part on my back.
=In all,	$	28.12	½
=== farm
	$	23.44
Deducting the outgoes,		14.72	½
=There are left,	$	8.71	½
=== food
Rice,	$	1.73	½
Molasses,		1.73		Cheapest form of the saccharine.
Rye meal,		1.04	¾
Indian meal,		0.99	¾	Cheaper than rye.
Pork,		0.22
+All experiments which failed:
Flour,		0.88		Costs more than Indian meal, both money and trouble.
Sugar,		0.80
Lard,		0.65
Apples,		0.25
Dried apple,		0.22
Sweet potatoes,		0.10
One pumpkin,		0.06
One watermelon,		0.02
Salt,		0.03
=== outgoes
House,	$	28.12	½
Farm one year,		14.72	½
Food eight months,		8.74
Clothing, etc., eight months,		8.40	¾
Oil, &c., eight months,		2.00
=In all,	$	61.99	¾
=== income
	$	23.44
Earned by day-labor,		13.34
=In all,	$	36.78
`; // content.accounts.<lang>.md: one block per table
const tables = Object.fromEntries(accounts.split(/^=== /m).filter(Boolean)
  .map((block) => [block.slice(0, block.indexOf('\n')).trim(), block.slice(block.indexOf('\n'))]));

Οι λογαριασμοί του Thoreau φυλάσσονται ως TSV στο content.accounts.en.md, ένα μπλοκ ανά λογαριασμό, έτσι η ισπανική έκδοση μεταφράζει τα είδη και αλλάζει την υποδιαστολή σε κόμμα χωρίς να αγγίξει τον κώδικα. Κάθε γραμμή έχει ένα είδος, ένα σύμβολο δολαρίου, το ποσό, ένα κλάσμα και μια παρατήρηση. Τα μισά και τα τέταρτα έχουν δική τους στήλη: το ½ έχει πλάτος 713 μονάδες και το ¾ 689, περισσότερο από ένα πινακοειδές ψηφίο, και η Alegreya δεν έχει διάστημα ψηφίου για να γεμίσει τα άλλα ποσά. Ένα σύνολο φτιάχνεται από κελιά κεφαλίδας, έτσι το groupRules τραβά μια λεπτή γραμμή από πάνω του, όπως ο τυπογράφος του Thoreau τραβούσε μια γραμμή πριν από το In all. Το σύμβολο του δολαρίου γράφεται \$, γιατί ένα σκέτο $ ανοίγει τύπο σε ένα κελί όπως και στο κείμενο. Ο τύπος πόρου account δεν έχει αριθμό ούτε πρόθεμα λεζάντας, και η προεπιλεγμένη τοποθέτησή του είναι 'here', έτσι κάθε λογαριασμός μπαίνει εκεί όπου τον εισάγει η φράση του Thoreau.

#3 · Η πρώτη σελίδα ορίζει τα δικά της ψηφία

script.js · γραμμές 126–144στον πλήρη κώδικα
const at = (to, edge, y, x = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// 'below' starts a text at the left edge of what it hangs from: the texts take the measure
// and start half the difference to the left of the vignette, so they centre on the page.
const centred = (to, y) => ({ ...at(to, 'below', y, (VIGNETTE - MEASURE) / 2),
  size: { width: mm(MEASURE) } });
const opener = { enabled: true, minHeight: pt(19 * LEAD), slot: { elements: [
  { kind: 'image', id: 'cabin', resourceId: 'cabin',
    placement: { ...at('container', 'top', 0), size: { width: mm(VIGNETTE) } } },
  { kind: 'text', id: 'kicker', content: '{attr.kicker}', fontFamily: LABEL, fontWeight: 500,
    fontSize: pt(7.5), letterSpacing: pt(1.5), textTransform: 'uppercase', color: col('accent'),
    align: 'center', placement: centred('#cabin', 6) },
  { kind: 'text', id: 'title', content: '{titleText}', fontFamily: CAPS, fontSize: pt(30),
    letterSpacing: pt(1.2), lineHeight: 1, color: col('ink'), align: 'center',
    placement: { ...at('#kicker', 'below', 2.5), size: { width: mm(MEASURE) } } },
  // A design text names its own family, so it states its figures too.
  { kind: 'text', id: 'dates', content: '{attr.dates}', fontFamily: CAPS, fontSize: pt(11),
    letterSpacing: pt(0.8), color: col('accent'), align: 'center', figureStyle: 'lining',
    placement: { ...at('#title', 'below', 2.5), size: { width: mm(MEASURE) } } },
] } };

Ένα κείμενο σχεδίασης ορίζει τη δική του οικογένεια, έτσι τα ψηφία του κυρίως κειμένου δεν φτάνουν ως εκεί. Το Concord, 1845–1847 είναι σε Alegreya SC και ζητά το ίδιο 'lining', όπως οι επικεφαλίδες. Η βινιέτα είναι η χαλκογραφία από τη σελίδα τίτλου του 1854, περικομμένη και εξισωμένη σε μαύρο πάνω σε λευκό, και ο υπέρτιτλος, ο τίτλος και οι χρονολογίες παίρνουν το πλάτος στοιχειοθεσίας και κεντράρονται κάτω από αυτήν.

#4 · Τρέχουσες κεφαλίδες με την ενότητα στη δεξιά σελίδα

script.js · γραμμές 148–161στον πλήρη κώδικα
const head = (id, content, parity, edge, x, extra = {}) => ({
  kind: 'text', id, content, parity, pages: 'body', fontFamily: LABEL, fontSize: pt(7.5),
  fontWeight: 500, letterSpacing: pt(1.2), textTransform: 'uppercase', color: col('muted'),
  placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(13) } }, ...extra });
const folio = { fontFamily: TEXT, fontSize: pt(9.5), fontWeight: 400, letterSpacing: pt(0),
  color: col('ink') };
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
  head('verso-title', '{title}', 'even', 'top-left', OUTER + 8),
  head('recto-title', '{firstMark.h2}', 'odd', 'top-right', -(OUTER + 8)),
  head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'top', 0, {
  ...folio, pages: 'opener', placement: at('container', 'top', 8) })] };

Η αριστερή σελίδα φέρει τον τίτλο του βιβλίου και η δεξιά την τρέχουσα ενότητα, {firstMark.h2}, έτσι η σελίδα 3 γράφει The Bean-Field, 1845. Οι αριθμοί σελίδας είναι σε Alegreya και κρατούν τα ψηφία παλαιού τύπου της.

Σελίδα 2: τα ψηφία παλαιού τύπου του λογαριασμού του σπιτιού έχουν όλα το ίδιο πλάτος, έτσι τα σεντς ευθυγραμμίζονται ως το σύνολο.

Η πλήρης συνταγή

Sandbox
// ═══ Postext Cookbook · Nº 176 · Old-style, lining and tabular figures ═══════════════
// https://postext.dev/en/cookbook/old-style-and-tabular-figures
// Code: MIT · Text: H. D. Thoreau, Walden (1854, public domain) · Vignette: 1854 title page (PD)
// Fonts: Alegreya, Alegreya SC, Alegreya Sans (SIL OFL 1.1) · Needs postext ≥ 1.65.0
// Thoreau's accounts from Walden. Each text style asks Alegreya for one kind of figures:
// old-style in the prose, lining in the small-capital headings, tabular in the accounts.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, defaultResourceTypes,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'old-style-and-tabular-figures';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = {
  ink: '#221e1a', // text: a warm near-black
  accent: '#7d3a1f', // walnut: headings, kicker, rules of the opener
  rule: '#8a7f73', // the light rules of the accounts
  muted: '#6b6158', // running heads, the colophon
  paper: '#ffffff',
};
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: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
const TEXT = 'Alegreya', CAPS = 'Alegreya SC', LABEL = 'Alegreya Sans';
const TRIM = [140, 216], INNER = 19, OUTER = 16; // mm: a trade paperback
const MEASURE = TRIM[0] - INNER - OUTER, VIGNETTE = 50; // mm
const LEAD = 14.5; // pt: the body leading, the grid the headings keep to

// #region answer: one figure style per text style
// Alegreya's own figures are old-style, so the prose asks for none: the cut Fontsource
// serves has no onum, and 'oldstyle' would change nothing (see the write-up).
const bodyText = {
  fontFamily: TEXT, fontSize: pt(10.8), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  textAlign: 'justify', firstLineIndent: mm(4.5), indentAfterHeading: false,
  hyphenation: { enabled: true }, optimalLineBreaking: true,
  avoidWidows: true, avoidOrphans: true, avoidRunts: true,
};
// Small capitals take lining figures (lnum), at the height of the capitals around them.
const section = { level: 2, fontFamily: CAPS, fontSize: pt(12.5), lineHeight: pt(LEAD),
  fontWeight: 400, letterSpacing: pt(0.6), color: col('accent'), figureStyle: 'lining',
  marginTop: pt(LEAD), marginBottom: pt(0) };
// The accounts: every figure on one width (tnum), so the cents stand in columns.
// 'tabular' keeps the font's form, old-style; 'lining-tabular' would set them at cap height.

Το συντεθειμένο script.js εκτελείται ως έχει: επικολλήστε το στο module script οποιασδήποτε σελίδας ή ανοίξτε τη συνταγή στο CodePen. Φάκελος της συνταγής στο GitHub ↗ (ανοίγει σε νέα καρτέλα)

Παραλλαγές

#Οι λογαριασμοί σε ευθυγραμμισμένα ψηφία

Ένα λογιστικό βιβλίο ή ένας τιμοκατάλογος σε σύγχρονο βιβλίο βάζει συχνά τα ψηφία του στο ύψος των κεφαλαίων.

-  figureStyle: 'tabular', bodyFontFamily: TEXT, bodyFontSize: pt(9.8), bodyColor: col('ink'),
+  figureStyle: 'lining-tabular', bodyFontFamily: TEXT, bodyFontSize: pt(9.8), bodyColor: col('ink'),

#Οι αριθμοί σελίδας σε ευθυγραμμισμένα ψηφία

Αριθμοί σελίδας σε ευθυγραμμισμένα ψηφία ταιριάζουν με τρέχουσες κεφαλίδες σε κεφαλαία.

-const folio = { fontFamily: TEXT, fontSize: pt(9.5), fontWeight: 400, letterSpacing: pt(0),
+const folio = { fontFamily: TEXT, fontSize: pt(9.5), fontWeight: 400, letterSpacing: pt(0),
+  figureStyle: 'lining',

Συνήθη λάθη

  • Τα λατινικά αρχεία που σερβίρει το Fontsource συχνά παραλείπουν το onum: οι Lora, EB Garamond, Source Serif 4, Crimson Pro, Newsreader και Literata κρατούν μόνο pnum και tnum. Με αυτά τα αρχεία το figureStyle: 'oldstyle' δεν αλλάζει τίποτα και το κείμενο κρατά ευθυγραμμισμένα ψηφία. Διαλέξτε μια οικογένεια με δικά της ψηφία παλαιού τύπου, όπως η Alegreya, η Gelasio ή η Cormorant Garamond, που προσθέτουν lnum για τις επικεφαλίδες, ή φορτώστε τα πλήρη αρχεία του χυτηρίου.
  • Ένα $ στο Markdown ή σε κελί πίνακα ανοίγει τύπο μέσα στη γραμμή. Γράψτε \$14.72½ στο κείμενο και \$ σε κελί.

Ευχαριστίες

Συνταγή
Ignacio Ferro
Κείμενο
  • The accounts and the passages around them from “Economy,” the first chapter of Walden; or, Life in the Woods (Boston: Ticknor and Fields, 1854) · Henry D. Thoreau · κοινό κτήμα
  • The headnote, and the Spanish translation of the passages and the accounts · Ignacio Ferro · CC BY 4.0
Εικόνες
Γραμματοσειρές
Alegreya (SIL OFL 1.1) · Alegreya SC (SIL OFL 1.1) · Alegreya Sans (SIL OFL 1.1)
SandboxPDF