Kurz gesagt
Ein kurzes Kapitel, das die Zeichen der Logik und der Mengenlehre lesen lehrt. Den Schriften des Buchs fehlen diese Zeichen; eine zweite Schrift setzt sie ein, am Bildschirm und im gedruckten PDF.
Was Sie setzen
Das erste Kapitel einer kleinen Logikfibel auf einer Seite von 155 × 235 mm: ein weinroter Balken mit den Zeichen des Kapitels in großem Grad, danach vier Abschnitte, die ∀, ∃, ∈, ∪, ∅ und ℵ vorlesen, mit den Formeln im Fließtext und abgesetzt zwischen den Absätzen. Der Text steht in Crimson Pro, die Überschriften in Cormorant Garamond, die Auszeichnungen in IBM Plex Sans Condensed. Keine der drei hat ∀, ∈ oder einen griechischen Buchstaben in den Dateien, die Fontsource ausliefert. Eine einzige Einstellung, symbolFont, stellt Noto Sans Math hinter jede von ihnen. So kommen alle Zeichen aus derselben Schrift, im Text, in den Überschriften, den Kolumnentiteln und den Tabellenzellen, und das PDF druckt sie alle.
Dieses Rezept beantwortet
- Wie drucke ich Logik- und Mengenzeichen (∀, ∈, ℵ) und Griechisch, die meiner Textschrift fehlen, ohne leere Kästchen im PDF?
Die kurze Antwort
// None of the three faces has ∀, ∈, ℵ or Greek. config.symbolFont (below) lists Noto Sans
// Math after every family the document names: what a face lacks is drawn from it, at the
// face's size and colour, in the canvas, the PDF, the HTML and the EPUB.
const SYMBOLS = 'Noto Sans Math';
// Fontsource serves Noto Sans Math whole in its "latin" file, and the kit would declare
// that file for the Latin range only. The screen and the PDF take it here with no range,
// so every glyph in it can be used.
const symbolFile = async () =>
`${await fontsourceAt('noto-sans-math')}files/noto-sans-math-latin-400-normal.woff2`;
const resolve = async (family, ...face) =>
(family === SYMBOLS ? [{ source: await symbolFile() }] : fontsourceResolver(family, ...face));
const pdfFonts = async (family, ...face) => (family !== SYMBOLS
? fontsourceProvider(family, ...face)
: decompressWoff2(new Uint8Array(await (await fetch(await symbolFile())).arrayBuffer())));
Zutaten
- Funktionen
- SymbolschriftIm PDF eingebettete SchriftenSchriften vor dem LayoutHoch- und TiefstellungAbsatzformateTabellen aus DatenTabellenformatGestaltete AuftakteÜberschriftenattributeKolumnentitel und SeitenzahlenGespiegelte RänderSemantische FarbpalettePDF-Export
- Nutzt außerdem
- Abbildungen genau hierAbbildung und Tabelle in Ihrer SpracheKopfzeilen nach SeitenrolleEigene Ressourcentypen
- Schrift
- Crimson Pro, Cormorant Garamond, IBM Plex Sans Condensed, Noto Sans Math (SIL OFL 1.1)
- Dateien
- Keine: Jedes Bild wird im Code gezeichnet
Zubereitung
#1 · Eine Symbolschrift hinter allen Schriften
Der Code dieses Schritts ist die kurze Antwort oben. symbolFont: 'Noto Sans Math' (Symbolschrift) stellt die Familie hinter jede Familie, die die Konfiguration nennt: Ein Zeichen, das der Schrift fehlt, wird aus Noto Sans Math gezeichnet, im Grad und in der Farbe der Schrift, und der Rest der Zeile bleibt in ihr. Fontsource liefert Noto Sans Math vollständig in der Datei latin aus, 3.033 Zeichen, aber das Kit meldet diese Datei nur für den lateinischen Bereich an, und der Browser würde sie nicht nach ∀ fragen. resolve und pdfFonts des Rezepts reichen dieselbe Datei ohne Bereich weiter, am Bildschirm und an renderToPdf. Nur fehlende Zeichen wechseln die Schrift: Crimson Pro hat ¬, die Negation im Text bleibt also in Crimson Pro.
#2 · Ein erster Satz ohne sie zeigt, was fehlt
// Each paragraph that sets a character its face lacks is a glyphFallbackAt warning with its
// page; with no symbol font it names no family that draws them, and the PDF would print
// empty boxes. The pages shown are the second build's.
const fonts = { ...kitFonts(FONTS), resolve }; // the kit's resolver, with the symbol file
const bare = await buildDocumentWithFonts({ markdown, resources }, { ...config, symbolFont: '' },
fonts);
console.info((bare.contentWarnings ?? []).filter((w) => w.kind === 'glyphFallbackAt')
.map(formatWarning).join('\n'));
Der erste Satzlauf lässt symbolFont leer und gibt seine glyphFallbackAt-Warnungen aus, eine je Absatz, Überschrift oder Tabelle mit Zeichen, für die ihre Schrift keine Glyphe hat, mit Seite und Zeichen. Die englische Ausgabe meldet achtzehn: vierzehn Absätze in Crimson Pro, drei Überschriften in Cormorant Garamond und die Kopfzeile von Tabelle 1.1 in IBM Plex Sans Condensed fett. Ohne eine Familie, die sie zeichnet, nimmt die Leinwand die Zeichen aus einer Systemschrift des Lesers, und das PDF druckt für jedes ein leeres Kästchen. Der zweite Satzlauf, mit der Symbolschrift, ist der auf der Seite; seine Warnungen nennen "Noto Sans Math" als die Familie, die sie zeichnet.
#3 · Die Zeichen der Eröffnung sind Text
const BAND = 78; // mm from the trim to the foot of the band
const onBand = { color: col('paper'), align: 'left' };
const below = (id, y, width) => ({ anchor: { to: `#${id}`, edge: 'below' }, offset: { y: mm(y) },
size: { width: mm(width) } });
const opener = { enabled: true, minHeight: mm(BAND - TOP + 2), slot: { elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('accent') },
placement: { anchor: { to: 'bleed', edge: 'top-left' }, size: { height: mm(BAND) } } },
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...onBand, fontFamily: LABEL,
fontWeight: 600, fontSize: pt(8.5), letterSpacing: pt(1.8), textTransform: 'uppercase',
placement: { anchor: { to: 'container', edge: 'top-left' }, offset: { y: mm(2) } } },
{ kind: 'text', id: 'title', content: '{titleText}', ...onBand, fontFamily: DISPLAY,
fontWeight: 600, fontSize: pt(38), lineHeight: 1.02, placement: below('kicker', 3, 110) },
// The signs are text in Cormorant Garamond, which has none of them: Noto Sans Math draws
// every one, at 30 pt, in the band's white.
{ kind: 'text', id: 'signs', content: '{attr.signs}', ...onBand, fontFamily: DISPLAY,
fontSize: pt(30), lineHeight: 1, letterSpacing: pt(9), placement: below('title', 7, 114) },
] } };
Die Zeile aus sieben Zeichen unter dem Titel ist ein Gestaltungstext in Cormorant Garamond zu 30 pt, gespeist aus dem Attribut signs der Überschrift. Cormorant Garamond hat keines davon, also kommen alle sieben aus der Symbolschrift, im Weiß des Balkens. Eine Sperrung von 9 pt verteilt sie über die Satzbreite.
#4 · Zellen und Kolumnentitel nehmen dieselbe Schrift
const [T, F] = t({ en: ['T', 'F'], es: ['V', 'F'] });
const connectives = [['¬*p*', (p) => !p], ['*p* ∧ *q*', (p, q) => p && q],
['*p* ∨ *q*', (p, q) => p || q], ['*p* → *q*', (p, q) => !p || q],
['*p* ↔ *q*', (p, q) => p === q]];
const cell = (content, isHeader = false) => ({ content, align: 'center', isHeader });
const truth = [[true, true], [true, false], [false, true], [false, false]].map(([p, q]) =>
[p, q, ...connectives.map(([, f]) => f(p, q))].map((v) => cell(v ? T : F)));
const table = (id, rows, columnWidths, caption, position) => ({ id, typeId: 'table',
kind: 'table', caption, createdAt: 0, updatedAt: 0, placement: { position },
table: { model: { headerRowCount: 1, columnWidths, rows } } });
const resources = [
table('truth', [['*p*', '*q*', ...connectives.map(([s]) => s)].map((s) => cell(s, true)),
...truth],
[1, 1, 1.3, 1.6, 1.6, 1.6, 1.6], t({ en: 'The five connectives, row by row.',
es: 'Las cinco conectivas, fila a fila.' }), 'top'), // to the head of a page
table('signs', parseTSV(signs.trim()).rows.map((row, r) => row.map(({ content }, c) => ({
content, align: c === 0 ? 'center' : 'left', isHeader: r === 0 }))), [0.8, 2.1, 5.3],
t({ en: 'Where the signs come from.', es: 'De dónde vienen los signos.' }), 'here'),
];
Die Wahrheitstafel entsteht aus den Junktoren selbst: Der Kopf jeder Spalte ist die Formel, jede Zelle das, was die Formel in dieser Zeile ergibt. Die Kopfzellen stehen in IBM Plex Sans Condensed fett kursiv, die übrigen in Crimson Pro; die Symbolschrift bedient beide. Ihr einziger gerader Schnitt zeichnet für jedes Gewicht und jede Lage, sodass das ∧ im fetten Kopf und das ∈ einer kursiven Formel dasselbe aufrechte Zeichen sind. Der Kolumnentitel der rechten Seite druckt den laufenden Abschnitt, {firstMark.h2}, und SETS: ∈, ∪, ∩ AND ∅ auf Seite 3 nimmt seine Zeichen ebenfalls aus Noto Sans Math.

Das ganze Rezept
// ═══ Postext Cookbook · Nº 185 · Logic signs from a symbol font ═════════════════════
// https://postext.dev/en/cookbook/symbol-font-for-logic
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Crimson Pro, Cormorant Garamond, IBM Plex, Noto Sans Math (OFL) · Needs postext ≥ 1.73.0
// A primer of logical notation set in faces that have no ∀, no ∈, no ℵ and no Greek:
// symbolFont names Noto Sans Math, which draws those characters on the canvas and in the PDF.
import {
buildDocumentWithFonts, renderPageToCanvas, defaultResourceTypes, parseTSV, formatWarning,
} 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 = 'symbol-font-for-logic';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = {
ink: '#1f1c22', // text: a cool near-black
accent: '#7b2a3b', // claret: the opener band, labels, the table heads
tint: '#f4ece9', // the even rows of the truth table
rule: '#c3b4b2', // hairlines
muted: '#6a6064', // 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 = 'Crimson Pro', DISPLAY = 'Cormorant Garamond', LABEL = 'IBM Plex Sans Condensed';
const TRIM = [155, 235], INNER = 20, OUTER = 21, TOP = 23; // mm: a trade-size primer
const LEAD = 15; // pt: the body leading
// #region answer: one symbol font behind every face, on the canvas and in the PDF
// None of the three faces has ∀, ∈, ℵ or Greek. config.symbolFont (below) lists Noto Sans
// Math after every family the document names: what a face lacks is drawn from it, at the
// face's size and colour, in the canvas, the PDF, the HTML and the EPUB.
const SYMBOLS = 'Noto Sans Math';
// Fontsource serves Noto Sans Math whole in its "latin" file, and the kit would declare
// that file for the Latin range only. The screen and the PDF take it here with no range,
// so every glyph in it can be used.
const symbolFile = async () =>
`${await fontsourceAt('noto-sans-math')}files/noto-sans-math-latin-400-normal.woff2`;
const resolve = async (family, ...face) =>
(family === SYMBOLS ? [{ source: await symbolFile() }] : fontsourceResolver(family, ...face));
const pdfFonts = async (family, ...face) => (family !== SYMBOLS
? fontsourceProvider(family, ...face)
: decompressWoff2(new Uint8Array(await (await fetch(await symbolFile())).arrayBuffer())));
// #endregion
Das zusammengesetzte script.js läuft unverändert: Fügen Sie es in das Modulskript einer beliebigen Seite ein, oder öffnen Sie das Rezept auf CodePen. Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)
Varianten
#Den ersten Satzlauf weglassen
Sind die Warnungen gelesen, genügt ein Satzlauf.
-const bare = await buildDocumentWithFonts({ markdown, resources }, { ...config, symbolFont: '' },
- fonts);
-console.info((bare.contentWarnings ?? []).filter((w) => w.kind === 'glyphFallbackAt')
- .map(formatWarning).join('\n'));Häufige Fehler
Layoutwarnung · glyphFallbackAt
Zeichen, die der Schrift hier fehlen
Ursache. Ein Absatz enthält Zeichen, die seiner Textschrift fehlen: mathematische Buchstaben und Operatoren (∪, ℵ), Griechisch in einer lateinischen Schrift, Pfeile (glyphFallback nennt die Schrift, dies den Absatz). supplier ist die Familie, die sie zeichnet, meist die symbolFont; ohne sie druckt das PDF leere Kästchen.
Lösung. Eine symbolFont angeben, die sie enthält (Noto Sans Math deckt fast die ganze Mathematik ab), oder eine Textfamilie wählen, die sie hat. Ist das Zeichen falsch (ein hebräisches Aleph, wo der Autor ein Komplement meinte), den Text korrigieren. Doku →
- Eine Schrift, deren Fontsource-Dateien Griechisch enthalten (Source Serif 4, Alegreya), setzt φ und Γ selbst, und das Kit lädt diese Datei, wenn der Text Griechisch enthält: Dann gehen nur die Zeichen an die Symbolschrift. Crimson Pro hat keine griechische Datei, ihr Griechisch kommt also aus Noto Sans Math.
- Die Symbolschrift hat nur einen Schnitt, gerade und normal. Eine fette Überschrift oder eine kursive Formel setzt ihre Zeichen in diesem Schnitt, so wie die Mathematik sie druckt.
Nachweise
- Rezept
- Ignacio Ferro
- Text
- The primer of logical notation, in English and Spanish · Ignacio Ferro · CC BY 4.0
- Schriften
- Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · IBM Plex Sans Condensed (SIL OFL 1.1) · Noto Sans Math (SIL OFL 1.1)
- Code
- MIT, wie Postext
Diesen Text bearbeiten ↗ (öffnet sich in einem neuen Tab)Ordner des Rezepts auf GitHub ↗ (öffnet sich in einem neuen Tab)


