Skip to main content
Recipe number 161

Cookbook · Chapter 12 · Textbooks

Handwriting workbook in ten scripts

A first handwriting book in every site language: each country's school script on its own ruling, a model, dotted letters to trace and empty rows.

On this page
Output
Canvas · PDF
Postext
Tested with Postext 1.65.0
Needs ≥ 1.65.0 · postext-pdf ≥ 1.65.0
Licence
Updated 31 Oct 2026
Code MIT · Text CC BY 4.0
  • Trim 210 × 297 mm
  • 1 column
  • Andika 14/20
  • Lexend
  • Playwrite GB J
  • 12 pages
  • Level
  • Postext 1.65.0
  • Laid out in 98 ms
  • 300 lines of code

In short

A children's handwriting book made ten times, once per language. Each lesson shows a word written out, then in dots to go over, then empty lines, in the joined letters and lined paper of that country's schools.

What you'll build

Twelve pages of a first-year handwriting book on A4, in ten editions that are ten different books. Each language gets the joined script its schools teach, from Google's Playwrite families (GB J, ES, FR Trad, DE VA, IT Trad, BR) or Playpen Sans Arabic, on the paper its children write on: the Spanish pauta, French Seyès squares with a red margin, the German Lineatur with its yellow middle band, Brazilian caligrafia lines. The Chinese edition writes in 田字格 squares, where children trace pale red characters (描红), with pinyin on four lines; the Japanese one in マス squares with a dotted cross, tracing in grey (なぞり書き). The lessons follow each spelling: ñ and the silent h in Spanish, l·l in Catalan, ß and capital nouns in German, the particles は, を and へ in Japanese, the four forms of a letter and the letters that do not join in Arabic. Every row goes from a model to dots to nothing. Twenty-nine paintings, generated with a diffusion model, are shared by all editions.

This recipe answers

  • How do I make a handwriting workbook: a model, dotted letters to trace and empty lines, on each country's school ruling?
  • How do I build a worksheet page: fill-in lines, answer boxes, word banks, checklists?

The short answer

script.js · lines 70–93in full code
// :::callout{type="palabra" title="Repasa y escribe"} / niña / ::: draws four rows: the model
// and copies, a row of copies, the model and a copy, an empty row, all of them the box's word
// ({boxText}); a copy has `dotted`, `repeat` fills its row. A design text's baseline falls 0.8
// of its line below its top; a tall line keeps the descenders inside its clip.
const G = CJK ? null : geometry(ED.ruling, ED.u); // rows, baselines and the face's size
const [LABEL_H, GAP] = [7, 3 * ED.u]; // mm: the box's title above its ruling; between copies
const hand = (id, placement, extra) => text(id, '{boxText}', HAND, G.size / 0.3528, placement,
  { lineHeight: mm(G.line), overflow: 'clip', ...extra });
const dots = (many) => ({ color: col('dots'), dotted: { spacing: mm(0.2 * ED.u),
  size: mm(0.11 * ED.u) }, ...(many && { repeat: { gap: mm(GAP) } }) });
const onRow = (n, size) => at('container', 'top-left', 0, G.base[n] - 0.8 * G.line, size);
const model = (n) => hand(`model-${n}`, onRow(n));
// Copies after the model of row n (as many as fit, or one), or from the row's start.
const after = (n, many) => hand(`after-${n}`, { anchor: { to: `#model-${n}`,
  edge: 'right-of' }, offset: { x: mm(GAP) } }, dots(many));
const copies = (n, many) => hand(`copies-${n}`, onRow(n, { width: 'fill' }), dots(many));
const ruled = (rows, picture, texts) => ({ setsContent: true, minHeight: mm(G.height(rows)),
  slot: { elements: [image('ruling', picture, at('container', 'top-left', 0, 0,
    box(W, G.height(rows)))), ...texts] } });
// Every practice box: no frame, its title in the label face LABEL_H above the drawing.
const practice = (id, design, gap = mm(4)) => ({ id, design, backgroundEnabled: false,
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) }, titleStyle: {
    fontFamily: LABEL, fontSize: pt(9), fontWeight: LW, color: col('accent'), lineHeight: mm(5),
    gap: mm(LABEL_H - 5), ...caps(1.2) }, marginTop: gap, marginBottom: mm(5), snapToGrid: false });

A practice box: the model in the school face, then dots, then nothing

Ingredients

Type
Andika, Lexend, Playwrite GB J, Playwrite ES, Playwrite FR Trad, Playwrite DE VA, Playwrite IT Trad, Playwrite BR, LXGW WenKai TC, Noto Serif SC, Noto Sans SC, Klee One, Zen Maru Gothic, Playpen Sans Arabic, Noto Naskh Arabic, Baloo Bhaijaan 2 (SIL OFL 1.1)
Assets
  • apple-480.jpg
  • bee-480.jpg
  • bird-480.jpg
  • boat-480.jpg
  • butterfly-480.jpg
  • cake-480.jpg
  • cat-480.jpg
  • cover-1600.jpg
  • dog-480.jpg
  • duck-480.jpg
  • fire-480.jpg
  • fish-480.jpg
  • flower-480.jpg
  • grip-480.jpg
  • house-480.jpg
  • icecream-480.jpg
  • key-480.jpg
  • kite-480.jpg
  • medal-480.jpg
  • moon-480.jpg
  • mountain-480.jpg
  • owl-480.jpg
  • penguin-480.jpg
  • shoe-480.jpg
  • spider-480.jpg
  • sun-480.jpg
  • tree-480.jpg
  • umbrella-480.jpg
  • water-480.jpg
  • Two children writing in notebooks at a school table, a cat asleep on a chair beside them. (Generated With Diffusion Models, original)
  • A smiling sun. (Generated With Diffusion Models, original)
  • A crescent moon with three stars. (Generated With Diffusion Models, original)
  • A ginger cat sitting. (Generated With Diffusion Models, original)
  • A brown and white puppy. (Generated With Diffusion Models, original)
  • An orange fish with blue stripes. (Generated With Diffusion Models, original)
  • A honey bee flying. (Generated With Diffusion Models, original)
  • A little black spider on a thread. (Generated With Diffusion Models, original)
  • A red apple. (Generated With Diffusion Models, original)
  • A golden key. (Generated With Diffusion Models, original)
  • A red child's shoe. (Generated With Diffusion Models, original)
  • A small house with a red roof. (Generated With Diffusion Models, original)
  • A small sailing boat. (Generated With Diffusion Models, original)
  • A yellow duckling. (Generated With Diffusion Models, original)
  • A colourful kite. (Generated With Diffusion Models, original)
  • A birthday cake with three candles. (Generated With Diffusion Models, original)
  • A penguin. (Generated With Diffusion Models, original)
  • An owl on a branch. (Generated With Diffusion Models, original)
  • A red umbrella in the rain. (Generated With Diffusion Models, original)
  • An ice-cream cone with two scoops. (Generated With Diffusion Models, original)
  • A blue and orange butterfly. (Generated With Diffusion Models, original)
  • A leafy tree. (Generated With Diffusion Models, original)
  • A snowy mountain. (Generated With Diffusion Models, original)
  • A daisy. (Generated With Diffusion Models, original)
  • A small blue bird on a twig. (Generated With Diffusion Models, original)
  • Splashing water. (Generated With Diffusion Models, original)
  • A small campfire. (Generated With Diffusion Models, original)
  • A child's hand holding a pencil with the tripod grip. (Generated With Diffusion Models, original)
  • A golden star medal with coloured pencils. (Generated With Diffusion Models, original)

Method

#1 · Give each edition its school script and its paper

script.js · lines 30–54in full code
// hand: the school model the children copy; ruling: the paper they copy it on; u: its
// x-height in mm (the height of an a), the unit every ruling is drawn in; rise: the room its
// capitals need above a title. The Chinese text is in Song: the Kai face, cut for Hong Kong
// and Taiwan, centres its commas, so it sets only the titles and the squares.
const EDITIONS = {
  en: { hand: 'Playwrite GB J', ruling: 'gb', u: 3.6 },
  es: { hand: 'Playwrite ES', ruling: 'pauta', u: 3.6 },
  ca: { hand: 'Playwrite ES', ruling: 'pauta', u: 3.6 },
  fr: { hand: 'Playwrite FR Trad', ruling: 'seyes', u: 3, rise: 5 },
  de: { hand: 'Playwrite DE VA', ruling: 'lineatur', u: 3.6 },
  it: { hand: 'Playwrite IT Trad', ruling: 'righe', u: 3.6 },
  pt: { hand: 'Playwrite BR', ruling: 'caligrafia', u: 3.2 },
  zh: { hand: 'LXGW WenKai TC', ruling: 'tian', text: 'Noto Serif SC',
    label: 'Noto Sans SC', pinyin: 'Andika', cell: 16 },
  ja: { hand: 'Klee One', ruling: 'masu', text: 'Klee One', label: 'Zen Maru Gothic', cell: 16 },
  ar: { hand: 'Playpen Sans Arabic', ruling: 'satr', u: 3.6,
    text: 'Noto Naskh Arabic', label: 'Baloo Bhaijaan 2' },
};
const ED = { text: 'Andika', label: 'Lexend', rise: 0, ...EDITIONS[LANG] };
const [HAND, TEXT, LABEL] = [ED.hand, ED.text, ED.label];
const CJK = ED.cell !== undefined; // a grid of squares, one character to each
const RTL = LANG === 'ar';
const LW = CJK ? 700 : 600; // the labels' weight: the CJK label faces ship no 600
// Labels in tracked capitals, where the script has capitals.
const caps = (n) => (!CJK && !RTL ? { textTransform: 'uppercase', letterSpacing: pt(n) } : {});

u is the x-height in millimetres, the unit every ruling is drawn in: 3.6 mm for most editions, 3 mm for French, whose Seyès lines are one x-height apart. The Playwrite faces all draw their x-height at half the em, so the model's size is u / 0.5, and the ruling's lines fall where the face's own proportions put its ascenders and descenders. The Chinese text is set in Song (Noto Serif SC): LXGW WenKai TC centres its commas the way Hong Kong and Taiwan print them, so the Kai face sets only the titles and the squares.

#2 · Set the model on the ruling, live

script.js · lines 70–93in full code
// :::callout{type="palabra" title="Repasa y escribe"} / niña / ::: draws four rows: the model
// and copies, a row of copies, the model and a copy, an empty row, all of them the box's word
// ({boxText}); a copy has `dotted`, `repeat` fills its row. A design text's baseline falls 0.8
// of its line below its top; a tall line keeps the descenders inside its clip.
const G = CJK ? null : geometry(ED.ruling, ED.u); // rows, baselines and the face's size
const [LABEL_H, GAP] = [7, 3 * ED.u]; // mm: the box's title above its ruling; between copies
const hand = (id, placement, extra) => text(id, '{boxText}', HAND, G.size / 0.3528, placement,
  { lineHeight: mm(G.line), overflow: 'clip', ...extra });
const dots = (many) => ({ color: col('dots'), dotted: { spacing: mm(0.2 * ED.u),
  size: mm(0.11 * ED.u) }, ...(many && { repeat: { gap: mm(GAP) } }) });
const onRow = (n, size) => at('container', 'top-left', 0, G.base[n] - 0.8 * G.line, size);
const model = (n) => hand(`model-${n}`, onRow(n));
// Copies after the model of row n (as many as fit, or one), or from the row's start.
const after = (n, many) => hand(`after-${n}`, { anchor: { to: `#model-${n}`,
  edge: 'right-of' }, offset: { x: mm(GAP) } }, dots(many));
const copies = (n, many) => hand(`copies-${n}`, onRow(n, { width: 'fill' }), dots(many));
const ruled = (rows, picture, texts) => ({ setsContent: true, minHeight: mm(G.height(rows)),
  slot: { elements: [image('ruling', picture, at('container', 'top-left', 0, 0,
    box(W, G.height(rows)))), ...texts] } });
// Every practice box: no frame, its title in the label face LABEL_H above the drawing.
const practice = (id, design, gap = mm(4)) => ({ id, design, backgroundEnabled: false,
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) }, titleStyle: {
    fontFamily: LABEL, fontSize: pt(9), fontWeight: LW, color: col('accent'), lineHeight: mm(5),
    gap: mm(LABEL_H - 5), ...caps(1.2) }, marginTop: gap, marginBottom: mm(5), snapToGrid: false });

A practice row is a box, and the word to practise is its content: :::callout{type="palabra" title="Trace and write"}, then owl on a line of its own, then :::. All the rows of one shape share a box style and differ only in their words. The style's design draws the ruling as a picture and sets the word on it as text in the school face through {boxText}, the model and its copies alike; setsContent keeps the box from setting its content a second time under the drawing. A design text's baseline falls at 0.8 of its line height below the top of its box, so the model's box is placed at the row's baseline minus 0.8 of its line, and the letters stand on the line the ruling draws. The line is ten x-heights tall so that the box's clip falls 2 u below the baseline, deep enough for the tail of a g. The box's title is the row's label. The headings are left to the book's outline: the cover is its only level-1 heading, each lesson a level-2 one, and the cover style's sectionEnd: 'heading' stops its blank running heads at the first lesson.

#3 · Write the copies in dots

A copy is the same {boxText} with dotted: the engine paints its letters as rows of dots along the middle of each stroke, 0.2 x-heights apart, and leaves the layout as it is. The dots follow the face as the browser shapes it, so the joins of the school script and the forms of an Arabic word come out right, and the dot of an i or an accent is one dot. repeat sets the word again after itself as many whole times as the row holds, 3 u apart: the copies after the model are a text anchored right-of the model, the full row one as wide as the box, the copy after the second model the same text without repeat. Edit the word in the Markdown and every copy and its dots change with it.

#4 · Trace characters in their squares

script.js · lines 97–129in full code
// :::callout{type="caracteres" title="写一写"} with one character per list item: each in the
// first square of its row, three copies to trace in the pale red (描红) or grey (なぞり書き) of
// the next squares, then empty ones. A Han or kana character is one em wide, so tracking of
// (square − em) sets one per square.
const [CELL, EM] = [ED.cell ?? 16, (ED.cell ?? 16) * 0.72]; // mm: the square, its character
const SQUARES = Math.floor(W / CELL);
const row = (n, y, content, x, color) => text(`r${n}-${x}`, content, HAND, EM / 0.3528,
  at('container', 'top-left', x * CELL + (CELL - EM) / 2, y + (CELL - EM) / 2 + EM * 0.06,
    box(W - x * CELL, EM)),
  { lineHeight: mm(EM), letterSpacing: mm(CELL - EM), overflow: 'clip', color: col(color) });
// A sentence (type="frase") takes three rows: written out, traced, and a row to write it alone.
const squareBlock = (rows, sentence) => ({ setsContent: true, minHeight: mm(rows * CELL),
  slot: { elements: [image('grid', `squares-${rows}`,
    at('container', 'top-left', 0, 0, box(SQUARES * CELL, rows * CELL))),
  ...(sentence ? [row(0, 0, '{boxText}', 0, 'ink'), row(1, CELL, '{boxText}', 0, 'trace')]
    : Array.from({ length: rows }, (_, n) => [
      row(n, n * CELL, `{boxText.${n + 1}}`, 0, 'ink'),
      row(n, n * CELL, `{boxText.${n + 1}}`.repeat(3), 1, 'trace'),
    ]).flat()),
  ] } });
// Pinyin on four lines and three spaces (四线三格), :::callout{type="pinyin"} / bā / ::: —
// the syllable, copies to trace in the pale red, the syllable again and room after it.
const P = ED.pinyin ? geometry('sixian', 3.6) : null;
const pinyin = (id, n, x, content, color) => text(id, content, ED.pinyin, P.size / 0.3528,
  at('container', 'top-left', x, P.base[n] - 0.8 * P.line, { width: mm(W - x) }),
  { lineHeight: mm(P.line), overflow: 'clip', color: col(color) });
const syllables = Array(5).fill('{boxText}').join('\u00a0\u00a0\u00a0\u00a0');
const pinyinBlock = P && { setsContent: true, minHeight: mm(P.height(3)),
  slot: { elements: [
    image('lines', 'sixian', at('container', 'top-left', 0, 0, box(W, P.height(3)))),
    pinyin('p1', 0, 0, '{boxText}', 'ink'), pinyin('p1-copies', 0, 36, syllables, 'trace'),
    pinyin('p2', 1, 0, syllables, 'trace'), pinyin('p3', 2, 0, '{boxText}', 'ink'),
  ] } };

A Han character or a kana is one em wide, so tracking of the square minus the em sets one character per square, as in a 字帖. The first square of a row holds the character in ink, the next three the same character in the pale red of 描红 (grey in the Japanese edition), and the rest stay empty. A row box lists its four characters as list items, which the design reads one by one with {boxText.1} to {boxText.4}. A sentence (a frase box) takes three rows: written out, traced, then empty, with the punctuation in a square of its own. The Chinese pinyin rows use the four-line ruling of the Latin editions with Andika, whose single-storey a and g are the ones children learn.

#5 · Mirror nothing for Arabic

The Arabic edition shares every design with the others. A design laid in the flow of a right-to-left page, a heading's or a box's, is mirrored by the engine, so the letter disc, the model, its copies and the dictionary's first picture move to the right by themselves; a repeated text starts on the side its direction starts on. Only the warm-up waves, drawn inside a picture, run from right to left in code. locale: 'ar' binds the book on the right.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 161 · Handwriting workbook in ten scripts ═══════════════
// https://postext.dev/en/cookbook/handwriting-workbook
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Playwrite, Playpen Sans Arabic, Klee One and others (SIL OFL) · 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 workbook (en es ca fr de it pt zh ja ar)
const RECIPE = 'handwriting-workbook';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a navy ink, one coral accent, the sun and the pale fields of the bands
const palette = {
  ink: '#22304a', accent: '#bf4630', // text and models; kickers, labels, folios
  sun: '#f4b73f', tint: '#fdf0da', // the boxes' stripe; opener bands, boxes
  rule: '#7f9ccc', dots: '#4d5b76', // the ruling; the dotted letters
  trace: LANG === 'ja' ? '#b4bccb' : '#e7a9a0', // traced over: 描红 in red, なぞり書き in grey
  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' } },
];
// #endregion

// #region editions: each language its school's script, its ruling and its faces
// hand: the school model the children copy; ruling: the paper they copy it on; u: its
// x-height in mm (the height of an a), the unit every ruling is drawn in; rise: the room its
// capitals need above a title. The Chinese text is in Song: the Kai face, cut for Hong Kong
// and Taiwan, centres its commas, so it sets only the titles and the squares.
const EDITIONS = {
  en: { hand: 'Playwrite GB J', ruling: 'gb', u: 3.6 },
  es: { hand: 'Playwrite ES', ruling: 'pauta', u: 3.6 },
  ca: { hand: 'Playwrite ES', ruling: 'pauta', u: 3.6 },
  fr: { hand: 'Playwrite FR Trad', ruling: 'seyes', u: 3, rise: 5 },
  de: { hand: 'Playwrite DE VA', ruling: 'lineatur', u: 3.6 },
  it: { hand: 'Playwrite IT Trad', ruling: 'righe', u: 3.6 },
  pt: { hand: 'Playwrite BR', ruling: 'caligrafia', u: 3.2 },
  zh: { hand: 'LXGW WenKai TC', ruling: 'tian', text: 'Noto Serif SC',
    label: 'Noto Sans SC', pinyin: 'Andika', cell: 16 },
  ja: { hand: 'Klee One', ruling: 'masu', text: 'Klee One', label: 'Zen Maru Gothic', cell: 16 },
  ar: { hand: 'Playpen Sans Arabic', ruling: 'satr', u: 3.6,
    text: 'Noto Naskh Arabic', label: 'Baloo Bhaijaan 2' },
};
const ED = { text: 'Andika', label: 'Lexend', rise: 0, ...EDITIONS[LANG] };

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

#Use the US cursive

Playwrite has a family for many school models. For American cursive, change the English face; the dots follow it.

-  en: { hand: 'Playwrite GB J', ruling: 'gb', u: 3.6 },
+  en: { hand: 'Playwrite US Trad', ruling: 'gb', u: 3.6 },

#Write on every second Seyès line

Children starting school often write on every other heavy line. Give the French rows a pitch of eight lines.

-    seyes: { above: 4, below: 2, gap: -2, seyes: true }, // a row on every heavy line
+    seyes: { above: 4, below: 2, gap: 2, seyes: true },

Pitfalls

  • A design text clips at its box. A box as tall as one line cuts the descenders of the model's g and p: give it a tall line and place it from the baseline.
  • loadCjkFonts loads every face for the whole sample: a Chinese face that lacks a character the text uses anywhere fails the load. Name fonts in Latin letters in a colophon.

Credits

Text
Original prose, CC BY 4.0
Images
  • Two children writing in notebooks at a school table, a cat asleep on a chair beside them. · Generated With Diffusion Models · original
  • A smiling sun. · Generated With Diffusion Models · original
  • A crescent moon with three stars. · Generated With Diffusion Models · original
  • A ginger cat sitting. · Generated With Diffusion Models · original
  • A brown and white puppy. · Generated With Diffusion Models · original
  • An orange fish with blue stripes. · Generated With Diffusion Models · original
  • A honey bee flying. · Generated With Diffusion Models · original
  • A little black spider on a thread. · Generated With Diffusion Models · original
  • A red apple. · Generated With Diffusion Models · original
  • A golden key. · Generated With Diffusion Models · original
  • A red child's shoe. · Generated With Diffusion Models · original
  • A small house with a red roof. · Generated With Diffusion Models · original
  • A small sailing boat. · Generated With Diffusion Models · original
  • A yellow duckling. · Generated With Diffusion Models · original
  • A colourful kite. · Generated With Diffusion Models · original
  • A birthday cake with three candles. · Generated With Diffusion Models · original
  • A penguin. · Generated With Diffusion Models · original
  • An owl on a branch. · Generated With Diffusion Models · original
  • A red umbrella in the rain. · Generated With Diffusion Models · original
  • An ice-cream cone with two scoops. · Generated With Diffusion Models · original
  • A blue and orange butterfly. · Generated With Diffusion Models · original
  • A leafy tree. · Generated With Diffusion Models · original
  • A snowy mountain. · Generated With Diffusion Models · original
  • A daisy. · Generated With Diffusion Models · original
  • A small blue bird on a twig. · Generated With Diffusion Models · original
  • Splashing water. · Generated With Diffusion Models · original
  • A small campfire. · Generated With Diffusion Models · original
  • A child's hand holding a pencil with the tripod grip. · Generated With Diffusion Models · original
  • A golden star medal with coloured pencils. · Generated With Diffusion Models · original
Fonts
Andika (SIL OFL 1.1) · Lexend (SIL OFL 1.1) · Playwrite GB J (SIL OFL 1.1) · Playwrite ES (SIL OFL 1.1) · Playwrite FR Trad (SIL OFL 1.1) · Playwrite DE VA (SIL OFL 1.1) · Playwrite IT Trad (SIL OFL 1.1) · Playwrite BR (SIL OFL 1.1) · LXGW WenKai TC (SIL OFL 1.1) · Noto Serif SC (SIL OFL 1.1) · Noto Sans SC (SIL OFL 1.1) · Klee One (SIL OFL 1.1) · Zen Maru Gothic (SIL OFL 1.1) · Playpen Sans Arabic (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1) · Baloo Bhaijaan 2 (SIL OFL 1.1)
SandboxPDF