かんたんな説明
小さな子ども向けの英語の読み方の本から、文字Mを学ぶ3ページです。単語の音はひとつずつ色のついた小さなラベルに入り、マス目に並ぶ単語にはそれぞれ画像がついています。
できあがり
架空の英語のフォニックス教本『Letter by Letter』の第12単元、mの音を学ぶ3ページです。単元の扉では、クリーム色の帯に190ptのDynaPuffでMmを組み、その横に、英語の名前がmで始まる2つのもの、サル(「monkey」)と月(「moon」)を置きます。単語は音に分け、音はひとつずつ、その単語の母音の色のチップに入ります。aは赤、eはオレンジ、iはティール、oは青、uは紫です。mは塗りつぶし、ほかの音は輪郭だけにするので、子どもはこの単元の音が「map」や「gum」のどこにあるかを見分けられます。38ページでは、画像のついた6つの単語を角の丸いマス目に並べ、各マスに水彩画を1枚入れ、その下になぞり書きを3行置きます。水彩画は拡散モデルで生成したもので、帯とアイコンとなぞり書きの行はコードで描いています。39ページには、24ptの4つの文、色を塗る単語の囲み、保護者へのメモがあります。
スペイン語版は翻訳ではなく、別の単元です。同じ文字を学ぶ『Letra a letra』の第7単元です。スペイン語の読み方は開音節(ma、me、mi、mo、mu)で教えるので、そのチップには{mi·mo·sa}のように音節が入ります。こうした音節は英語では単語にならず、英語の教本は音をひとつずつ教えます。そこで英語の単元は{m·a·p}のように短い単語の音をつなげ、韻を踏む語の仲間(-at、-an、-ug、-op)にまとめます。2つの単元は同じコードから組まれます。チップスタイルも、syllables()関数も、マス目も、なぞり書きの行も、囲みも同じです。
このレシピが答える質問
- キーボードのキー、タグ、練習問題の語群などのインラインのチップを作るには?
- 表のセルに画像やアイコンを入れるには?
- 空行を入れても効かないとき、2つのブロックの間に縦のスペースを追加するには?
- 記入線、解答欄、語群、チェックリストのあるワークシートのページを作るには?
手短な答え
// A word's syllables are chips with nothing between them, so their boxes touch and the white
// border draws the seam. Across a word space a chip keeps at least `gap`: 0.5 em sets the
// words of a 24 pt row 4.2 mm apart, where the space alone leaves 2.3 mm. Inside a sentence
// the '-frase' twins keep no gap, so the word space alone parts a chip from the word before.
// A 24 pt chip, padding and border included, is 10.4 mm tall (gotcha: chip-overlap).
const syllable = { fontFamily: TEXT, bold: true, borderWidth: pt(1), borderColor: col('paper'),
paddingX: em(0.26), paddingY: em(0.05), gap: em(0.5) };
const chipStyles = [
...'aeiou'.split('').flatMap((v) => [ // one pair per vowel
{ ...syllable, id: v, background: col(v), color: col('paper') }, // a syllable with m
{ ...syllable, id: `${v}-borde`, background: col('paper'), color: col(v), borderColor: col(v) },
]).flatMap((style) => [style, { ...style, id: `${style.id}-frase`, gap: em(0) }]),
{ ...syllable, id: 'pinta', bold: false, background: col('paper'), color: col('ink'),
borderColor: col('ink'), borderWidth: pt(0.8) }, // an outline for the child to colour in
];
const vowel = (s) => s.normalize('NFD').toLowerCase().match(/[aeiou]/)[0]; // 'mú' → 'u'
const chipOf = (s, v, end) => `:chip[${s}]{style="${v}${/m/i.test(s) ? '' : '-borde'}${end}"}`;
// {mi·mo·sa} → :chip[mi]{style="i"}:chip[mo]{style="o"}:chip[sa]{style="a-borde"}, and a word
// written after another word, as in 'me {mi·ma}.', takes the '-frase' twins. A piece with no
// vowel, the m and the p of the English {m·a·p}, takes the vowel of its word.
const syllables = (text) => text.replace(/(\p{L} )?\{([\p{L}·]+)\}/gu, (_, before = '', word) =>
before + word.split('·').map((s) => chipOf(s, vowel(s + word), before && '-frase')).join(''));
材料
- 機能
- インラインのチップ表のセル内の画像デザインした章扉見出しの属性見出しスタイルページデザインの画像ページデザインのテキスト・罫・ボックスデザイン要素の基準位置柱とノンブル名前付きの表スタイル段落スタイル明示的な縦のアキ囲みセマンティックカラーパレットリソースとしての図と表独自のリソースの種類その場に置く図キャンバス上のページ
- 種類
- Andika, DynaPuff, Playpen Sans (SIL OFL 1.1)
- 素材
man-640.jpgmano-640.jpgmanzana-480.jpgmapa-640.jpgmariposa-660.jpgmat-640.jpgmesa-640.jpgmimosa-640.jpgmono-640.jpgmoon-480.jpgmop-640.jpgmud-640.jpgmug-640.jpgmuneca-640.jpg- A watercolour of the butterfly on the opener (Generated With Diffusion Models, オリジナル)
- A watercolour of the apple on the opener (Generated With Diffusion Models, オリジナル)
- A watercolour of the hand in the picture grid (Generated With Diffusion Models, オリジナル)
- A watercolour of the map in the picture grid of both units (Generated With Diffusion Models, オリジナル)
- A watercolour of the table in the picture grid (Generated With Diffusion Models, オリジナル)
- A watercolour of the mimosa sprig in the picture grid (Generated With Diffusion Models, オリジナル)
- A watercolour of the monkey: in the picture grid of the Spanish unit and on the opener of the English one (Generated With Diffusion Models, オリジナル)
- A watercolour of the doll in the picture grid (Generated With Diffusion Models, オリジナル)
- A watercolour of the moon on the opener of the English unit (Generated With Diffusion Models, オリジナル)
- A watercolour of the mat in the picture grid of the English unit (Generated With Diffusion Models, オリジナル)
- A watercolour of the man in the picture grid of the English unit (Generated With Diffusion Models, オリジナル)
- A watercolour of the mug in the picture grid of the English unit (Generated With Diffusion Models, オリジナル)
- A watercolour of the mop in the picture grid of the English unit (Generated With Diffusion Models, オリジナル)
- A watercolour of the mud in the picture grid of the English unit (Generated With Diffusion Models, オリジナル)
- The cream band, the activity icons and the tracing rows, drawn in code in the page’s palette (Ignacio Ferro, MIT)
作り方
#1 · 母音ごとのチップスタイルと、チップを書く関数
手短な答えでは、1つのsyllableオブジェクトを展開して21のチップスタイルを作ります。mの音には母音ごとの塗りつぶしのスタイル、それ以外の音には母音ごとの輪郭のスタイルがあり、その10個それぞれに-fraseの対があります。さらに、子どもが色を塗る墨の輪郭pintaがあります。syllables()は{m·a·p}を、あいだに何もはさまない3つの:chip[…]に変えます。そのため単語の音は互いに接し、白い縁が継ぎ目を描きます。チップの色は中の母音で決まり、ここのmやpのように母音のない部分は、その単語の母音の色になります。そのため「map」は端から端まで赤です。語間をはさむと、チップは少なくとも自分のgapの分だけ離れます。0.5emにすると、24ptの列の単語は4.2mm離れます。スペースだけなら2.3mmです。文の中ではこのgapが新しい単語の前のアキをほぼ2倍にしてしまうので、別の単語に続く単語には-fraseの対を使います。そのgapは0なので、2.3mmのスペースはそのまま残ります。スペイン語版では、区切りは{mi·mo·sa}のように音節で、どれにも自分の母音があります。
#2 · チップがぶつからない行送り
// A 24 pt chip is 10.4 mm tall: at 30 pt (10.6 mm) leading the chips of two sentences would
// stand 0.1 mm apart, so every line the child reads has 45 pt, and the syllables 60 pt.
paragraphStyles: [
{ id: 'consigna', fontFamily: LABEL, fontSize: pt(10), lineHeight: pt(GRID),
color: col('muted') }, // the instruction under each activity
{ id: 'fila', fontSize: pt(34), lineHeight: pt(4 * GRID), textAlign: 'center' },
{ id: 'palabras', fontSize: pt(24), lineHeight: pt(3 * GRID), textAlign: 'center' },
{ id: 'lectura', fontSize: pt(24), lineHeight: pt(3 * GRID) },
{ id: 'colofon', fontSize: pt(7.5), lineHeight: pt(10), // Andika: Playpen has no italic
color: col('muted'), marginTop: pt(GRID) },
],
チップの上下の内側余白と縁は行の外側に描かれ、行送りを増やしません。そのため行送りより背の高いチップは、下の行のチップにぶつかります。24ptのチップは高さが10.4mmあり、30ptの行送り(10.6mm)では、2つの文のチップの間隔は0.1mmしかありません。子どもが読む行には45pt、最初の活動の34ptの列には60ptを与えています。指示文の15ptのグリッドの3行分と4行分です。
#3 · すべてのマスに絵を
const PICTURE_WORDS = t({ en: ['m·a·p', 'm·a·t', 'm·a·n', 'm·u·g', 'm·o·p', 'm·u·d'],
es: ['ma·no', 'ma·pa', 'me·sa', 'mi·mo·sa', 'mo·no', 'mu·ñe·ca'] });
const tableStyles = [{ id: 'dibujos', borderRadius: mm(5), // the frame and its fills, rounded
headerBackgroundEnabled: false, // a header row added later would print grey (#f0f0f0)
bodyBackgroundEnabled: true, bodyBackground: col('cream'), // cream tiles…
rules: 'grid', borderColor: col('paper'), borderWidth: pt(4), // …parted by white rules
bodyFontSize: pt(20), cellPadding: mm(3) }]; // the words' chips are 20 pt
const cells = (row) => PICTURE_WORDS.slice(row * 3, row * 3 + 3)
.map((word) => ({ content: syllables(`{${word}}`), align: 'center' }));
let grid = { columnWidths: [1, 1, 1], rows: [cells(0), cells(1)] };
PICTURE_WORDS.forEach((word, k) => { // the picture above the word, 0.72 of the cell's width
const resourceId = word.replaceAll('·', '').replace('ñ', 'n');
grid = setCellImage(grid, { row: Math.floor(k / 3), col: k % 3 }, { resourceId, width: 0.72 });
});
setCellImageはセルの文字の上に画像を置き、その幅をセルの内側の幅に対する比で決めます。ここでは0.72(36.5mm)で、行は画像が収まる高さまで伸びます。どの画像も白地に描いたJPEGで、タイルのクリーム色と乗算するので、枠なしでタイルになじみます。画像の下には、音のチップで組んだ単語があります。表のセルは、ふつうの段落と同じようにチップの記法を受け付けます。表スタイルdibujosは枠とその塗りの角を5mmで丸め、クリーム色のタイルを4ptの白い罫で仕切ります。
#4 · 囲みの前に1行の空き
calloutStyles: [
{ id: 'colorea', background: col('cream'), borderRadius: mm(4),
marginTop: pt(0), // the :::space before the box is the whole gap above it
padding: { top: mm(4), right: mm(5), bottom: mm(5), left: mm(5) },
titleStyle: { fontFamily: LABEL, fontSize: pt(15), fontWeight: 700, color: col('ink') },
body: { fontFamily: LABEL, fontSize: pt(10), lineHeight: pt(GRID), color: col('muted') } },
{ id: 'familia', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('rule') },
padding: { top: mm(3), right: mm(0), bottom: mm(0), left: mm(0) },
titleStyle: { fontFamily: LABEL, fontSize: pt(8.5), fontWeight: 700, color: col('ink'),
...tag },
body: { fontSize: pt(10.5), lineHeight: pt(GRID) } },
],
Markdownでは、最後の文と色塗りの囲みのあいだに:::space{lines=1}を置いています。15ptの1行分(5.3mm)です。囲みのmarginTopは0なので、この1行がアキのすべてです。これがないと、囲みは最後の文の行が終わる位置から始まります。囲みの冒頭にある:::spaceは捨てられるので、囲みは指示の行と色見本のチップで始まり、囲み自身の:::spaceはそのあと、色見本と色塗りの課題のあいだに置きます。
#5 · 文字の扉
const THINGS = t({ en: ['monkey', 'moon'], es: ['mariposa', 'manzana'] }); // ids and labels
const BAND = 104; // mm: the depth of the band's drawing; its wave dips to 101.9 mm
// The opener reserves seventeen grid lines, the first grid line past the foot of the band's
// image, so the first activity title stands on the grid like the others: two lines under
// the band, its instruction right under it.
const opener = { enabled: true, minHeight: pt(17 * GRID),
slot: { elements: [
picture('band', 'banda', at(0, 0, { width: mm(210), height: mm(BAND) })),
words('unit', '{attr.unit}', LABEL, 9, 700, 'paper', at(SIDE, 12.5), { ...tag,
box: { backgroundColor: col('ink'), borderRadius: mm(3),
padding: { top: mm(1.2), right: mm(2.8), bottom: mm(1.2), left: mm(2.8) } } }),
words('kicker', '{attr.kicker}', LABEL, 8.5, 600, 'muted', // level with the pill's text
{ anchor: { to: '#unit', edge: 'right-of' }, offset: { x: mm(4), y: mm(1.4) } }, tag),
words('letter', '{titleText}', DISPLAY, 190, 700, 'ink', at(SIDE - 3, 19), { lineHeight: 1 }),
words('name', '{attr.name}', LABEL, 20, 600, 'ink', at(SIDE + 1, 76)),
picture('first', THINGS[0], at(146, 12, { width: mm(40) })),
picture('second', THINGS[1], at(151, 53, { width: mm(30) })),
...[45.5, 84.5].map((y, k) => words(THINGS[k], THINGS[k], LABEL, 10, 600, 'muted',
at(146, y, { width: mm(40) }), { align: 'center' })), // its name under each picture
] } };
Mmは見出しのテキスト({titleText})で、単元番号、シリーズ名、文字の下の呼び名は同じ見出し行の属性です。帯、サル、月は画像です。帯の高さは104mmで、扉はその下端のすぐ下のグリッド行までを確保します。そのため最初の活動の題は118.5mmから始まります。グリッドに乗り、波のいちばん低い点(101.9mm)より16.6mm下です。
#6 · 活動の題の横のアイコン
const ICON = 9; // mm
const H2 = { level: 2, marginBottom: pt(0), // two grid lines per title, and two above it
lineHeight: pt(2 * GRID), marginTop: pt(2 * GRID) };
const activity = (id, icon) => ({ id, advancedDesign: { enabled: true, slot: { elements: [
picture('icon', icon, { anchor: { to: 'container', edge: 'top-left' },
size: { width: mm(ICON), height: mm(ICON) } }),
words('title', '{titleText}', LABEL, 15, 700, 'ink', { anchor: { to: '#icon',
edge: 'right-of' }, offset: { x: mm(3) }, size: { width: mm(140), height: mm(ICON) } },
{ verticalAlign: 'middle' }), // centred on the icon
] } } });
各活動の題は## Read the sentences {style="lee"}のように見出しスタイルを指定し、そのスタイルがアイコンを描いて、題をその横の中央に置きます。題はレベル2の見出しのままなので、間隔はH2のレベルが決めます。題そのものにlineHeightでグリッド2行分、その上にmarginTopでさらに2行分です。
レシピの全体
// ═══ Postext Cookbook · Nº 060 · Early reader with syllable chips ════════════════
// https://postext.dev/en/cookbook/reading-primer-syllables
// Code: MIT · Text: original (CC BY 4.0) · Pictures: diffusion models · Icons: drawn in code
// Fonts: Andika, DynaPuff, Playpen Sans (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import {
buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage, setCellImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'reading-primer-syllables';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#242832', paper: '#ffffff', muted: '#5f6470', // text; instructions
cream: '#f6f0e3', rule: '#d3c9b6', // the band, the tiles and the pictures' ground; guides
// The vowel code: a syllable takes its vowel's colour. White on these fills measures
// 3.2–4.9:1, above WCAG's 3:1 for large text: the vowel chips are bold, 20 pt or more.
a: '#d9482b', e: '#dd740c', i: '#1f9a8f', o: '#3f6fd8', u: '#9152cf' };
// Every colour is linked to its palette entry by id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// The engine's defaults are linked to 'main-color': point it at the ink.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, DISPLAY, LABEL] = ['Andika', 'DynaPuff', 'Playpen Sans']; // Andika: one-storey a
const [TOP, SIDE, GRID] = [18, 20, 15]; // mm, mm, pt: every activity starts on the 15 pt grid
// #region answer: one chip style per vowel, and {ma·má} in the text written out as chips
// A word's syllables are chips with nothing between them, so their boxes touch and the white
// border draws the seam. Across a word space a chip keeps at least `gap`: 0.5 em sets the
// words of a 24 pt row 4.2 mm apart, where the space alone leaves 2.3 mm. Inside a sentence
// the '-frase' twins keep no gap, so the word space alone parts a chip from the word before.
// A 24 pt chip, padding and border included, is 10.4 mm tall (gotcha: chip-overlap).
const syllable = { fontFamily: TEXT, bold: true, borderWidth: pt(1), borderColor: col('paper'),
paddingX: em(0.26), paddingY: em(0.05), gap: em(0.5) };
const chipStyles = [
...'aeiou'.split('').flatMap((v) => [ // one pair per vowel
{ ...syllable, id: v, background: col(v), color: col('paper') }, // a syllable with m
{ ...syllable, id: `${v}-borde`, background: col('paper'), color: col(v), borderColor: col(v) },
]).flatMap((style) => [style, { ...style, id: `${style.id}-frase`, gap: em(0) }]),
{ ...syllable, id: 'pinta', bold: false, background: col('paper'), color: col('ink'),
borderColor: col('ink'), borderWidth: pt(0.8) }, // an outline for the child to colour in
];
const vowel = (s) => s.normalize('NFD').toLowerCase().match(/[aeiou]/)[0]; // 'mú' → 'u'
const chipOf = (s, v, end) => `:chip[${s}]{style="${v}${/m/i.test(s) ? '' : '-borde'}${end}"}`;
// {mi·mo·sa} → :chip[mi]{style="i"}:chip[mo]{style="o"}:chip[sa]{style="a-borde"}, and a word
// written after another word, as in 'me {mi·ma}.', takes the '-frase' twins. A piece with no
// vowel, the m and the p of the English {m·a·p}, takes the vowel of its word.
const syllables = (text) => text.replace(/(\p{L} )?\{([\p{L}·]+)\}/gu, (_, before = '', word) =>
before + word.split('·').map((s) => chipOf(s, vowel(s + word), before && '-frase')).join(''));
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#チップを丸いピル形にする
チップの高さの半分を超える角丸の半径は、その半分に切り詰められます。そのため大きな値を与えると両端が丸くなります。1文字のチップはほぼ円になり、単語の中の継ぎ目は切れ込みになります。
- paddingX: em(0.26), paddingY: em(0.05), gap: em(0.5) };
+ paddingX: em(0.26), paddingY: em(0.05), gap: em(0.5), borderRadius: em(1) };よくあるつまずき
つまずき
行送りより高いチップは次の行に触れる
箱が行送りより高いチップは、次の行のチップに触れます(chipOverlap警告)。上下のパディング、枠線、サイズを小さくするか、行送りを広げてください。 インラインのチップ →
つまずき
:::spaceは囲みや段の頭では捨てられる
:::spaceは、段の頭、:::columnsグループの頭、ほかに中身のあるタイトルなしの囲みの頭、分割された囲みの続きの頭では捨てられます。postext 1.5からは、:::spaceだけで作った囲みは空きが求めるとおりの高さになり(解答欄の囲み、書き込み用の場所)、囲みのタイトルのすぐ下に置いた空きは、その分だけ本文を下げて始めます。タイトルなしの囲みを空きで始めるには、タイトルか最初の行を与え、そのあとに空きを入れてください。 明示的な縦のアキ →
Sandboxの検査 · chipOverlap
チップが隣の行に接触
原因. チップスタイルのチップが行送りより高いため、連続する行のチップどうしが接します。
対処. チップの上下の内側余白、輪郭線、サイズを小さくするか、行送りを大きくしてください。 ドキュメント →
クレジット
- 本文
- 書き下ろしの文章, CC BY 4.0
- 画像
- A watercolour of the butterfly on the opener · Generated With Diffusion Models · オリジナル
- A watercolour of the apple on the opener · Generated With Diffusion Models · オリジナル
- A watercolour of the hand in the picture grid · Generated With Diffusion Models · オリジナル
- A watercolour of the map in the picture grid of both units · Generated With Diffusion Models · オリジナル
- A watercolour of the table in the picture grid · Generated With Diffusion Models · オリジナル
- A watercolour of the mimosa sprig in the picture grid · Generated With Diffusion Models · オリジナル
- A watercolour of the monkey: in the picture grid of the Spanish unit and on the opener of the English one · Generated With Diffusion Models · オリジナル
- A watercolour of the doll in the picture grid · Generated With Diffusion Models · オリジナル
- A watercolour of the moon on the opener of the English unit · Generated With Diffusion Models · オリジナル
- A watercolour of the mat in the picture grid of the English unit · Generated With Diffusion Models · オリジナル
- A watercolour of the man in the picture grid of the English unit · Generated With Diffusion Models · オリジナル
- A watercolour of the mug in the picture grid of the English unit · Generated With Diffusion Models · オリジナル
- A watercolour of the mop in the picture grid of the English unit · Generated With Diffusion Models · オリジナル
- A watercolour of the mud in the picture grid of the English unit · Generated With Diffusion Models · オリジナル
- The cream band, the activity icons and the tracing rows, drawn in code in the page’s palette · Ignacio Ferro · MIT
- フォント
- Andika (SIL OFL 1.1) · DynaPuff (SIL OFL 1.1) · Playpen Sans (SIL OFL 1.1)


