本文へスキップ
レシピ番号157

レシピ集 · 第12章 · 教科書

Markdownから地名を入れる学校地図帳

文字を1つも含まない、描かれた地図に、リソースのアンカーごとの::label行で地名を入れます。組版ページと見開きで、スペイン語・英語・アラビア語の3版を組みます。

このページの内容

2〜3ページ(全4ページ)

  • スペイン語の見本:日本語版はまだありません
  • 仕上がり210 × 280 mm
  • 1段
  • Source Sans 3 10/14
  • Source Serif 4
  • 4ページ
  • レベル
  • Postext 1.57.1
  • 組版時間100 ms
  • コード250行

かんたんな説明

架空の国の学校地図帳から3ページ。地図は文字を入れずに描いた画像で、地名はすべて本文に書くので、翻訳では言葉だけを替え、地図はそのまま使えます。

できあがり

架空の国ヴァレニアの学校地図帳から、図版を3枚組みます。図版1は大陸の中での位置を示します。図版2は地形図を左右2ページに広げ、リラ海からブルナビアとの国境まで、段彩で高さを表し、3本の川と断面線を描きます。図版3は、その断面線に沿ってアルバル山脈を切った断面図です。どの図版も青い帯で始まり、凡例か用語集と、授業で使う問題で終わります。3枚の地図は画像モデルで描いたもので、文字が1つもありません。国境、町、縮尺、方位記号は、画像といっしょに描いたベクターの記号です。断面線は画像の一部ではありません。テンプレートの2本のコネクターが、地図の2つのアンカーを結んでいます。地名、標高、縮尺の数字はすべてMarkdownの::label行で、それぞれの地図が持つアンカーの位置に置かれます。海の上に立つ図版1の凡例も同じです。そのためスペイン語版・英語版・アラビア語版は同じ3枚の画像を共有し、アラビア語版は右から読み、右綴じになります。

このレシピが答える質問

  • 地図の地名を本文の側から入れて、翻訳では絵に手を付けずに言葉だけを替えるには?
  • 1枚の地図を見開きに広げ、右から左に読む版でも地名を読みやすく保つには?

手短な答え

script.js · 43〜71行コード全体で見る
// A label takes the style its anchor names: seas and rivers in italic blue, ranges in spaced
// brown capitals, towns on a white halo. Arabic is neither slanted nor letter-spaced, and
// Naskh and Kufi set small, so the Arabic edition gets the same styles upright, unspaced and
// 15 % larger.
const [SLANT, TRACK, SIZE] = AR ? ['normal', 0, 1.15] : ['italic', 1, 1];
const halo = { color: col('paper'), width: pt(1.4) };
const style = (id, size, color, more) => ({ id, fontFamily: LABEL, fontSize: pt(size * SIZE),
  fontWeight: AR ? 500 : 400, color: col(color), ...more });
const water = (id, size, spacing, more) => style(id, size, 'water', { fontStyle: SLANT,
  textTransform: spacing ? 'uppercase' : 'none', letterSpacing: spacing * TRACK, ...more });
const caps = (id, size, color, spacing, more) => style(id, size, color, {
  fontWeight: AR ? 700 : 600, textTransform: 'uppercase', letterSpacing: spacing * TRACK,
  ...more });
const labelStyles = [
  water('ocean', 9.5, 0.3), water('sea', 7.5, 0.16), water('river', 6.8, 0, { halo }),
  caps('range', 7, 'relief', 0.32, { halo }), caps('region', 6.5, 'muted', 0.24, { halo,
    leader: { color: col('ink'), width: pt(0.6), endCap: 'dot', capSize: mm(1.2) } }),
  style('legend', 7.6, 'ink', { kind: 'legend', background: col('paper'), padding: mm(2.4),
    border: { color: col('muted'), width: pt(0.4) }, radius: mm(1) }),
  caps('country', 8.5, 'muted', 0.36, { halo }), caps('nation', 12, 'ink', 0.42, { halo }),
  style('capital', 7.6, 'ink', { fontWeight: 700, halo }), style('town', 7, 'ink', { halo }),
  style('peak', 6.5, 'ink', { fontWeight: AR ? 700 : 600, halo }),
  style('island', 6.5, 'ink', { halo }),
  style('point', 8.5, 'band', { fontWeight: 700, halo }), style('tick', 6, 'muted'),
];
// An anchor is a point of the picture in fractions of its width and height, with the side of
// the label that stands there, its turn and its style. km(win) reads a point in km off a map.
const km = (win) => (id, x, y, labelStyle, more) => ({ id, x: (x - win.x0) / (win.x1 - win.x0),
  y: (y - win.y0) / (win.y1 - win.y0), style: labelStyle, ...more });

材料

併用する機能
枠に固定した飾り
種類
Source Sans 3, Source Serif 4, Noto Naskh Arabic, Noto Kufi Arabic (SIL OFL 1.1)
素材
  • locator-1776.jpg
  • relief-1984.jpg
  • section-1760.jpg
  • The locator map of Varenia and its neighbours, painted as a physical map with a golden wash over Varenia. (Generated With Diffusion Models, オリジナル)
  • The relief map of Varenia across a double page: hypsometric tints, hill shading, coastal shelf, rivers and a lake. (Generated With Diffusion Models, オリジナル)
  • The section from A to B painted as a slice of land cut along the line, in the height bands of the map. (Generated With Diffusion Models, オリジナル)

作り方

#1 · 場所は絵の上の1点

script.js · 434〜478行コード全体で見る
const above = { verticalAlign: 'bottom' }, below = { verticalAlign: 'top' };
const r = km(WIN.relief), l = km(WIN.locator);
const ANCHORS = {
  relief: [
    r('ocean', 172, 157, 'ocean'), r('lira', 20, 52, 'sea', { rotate: -84 }),
    r('gulf', 318, 154, 'sea', { width: 0.07 }), r('nema', 22, 100, 'island', above),
    r('albar-range', 98, 108, 'range', { rotate: -33 }),
    r('gris-range', 308, 96, 'range', { rotate: -86 }),
    r('plateau', 236, 78, 'region'), r('plain', 70, 98, 'region', { width: 0.08 }),
    r('sela', 108, 62, 'river', { rotate: -4 }), r('duna', 121, 136, 'river', { rotate: -62 }),
    r('merel', 281, 92, 'river', { rotate: -47 }), r('ormo', 254, 104, 'river', above),
    // Calvera's name goes below its dot: the River Sela runs in just above it.
    ...TOWNS.map(([id, x, y]) => (id === 'calvera' ? r(id, x, y + 2.6, 'town', below)
      : r(id, x, y - 2.6, id === 'almaren' ? 'capital' : 'town', above))),
    ...PEAKS.map(([id, x, y]) => r(`${id}-peak`, x, y + 2.4, 'peak', below)),
    r('ostelia', 300, 9, 'country'), r('brunavia', 390, 112, 'country', { rotate: -90 }),
    r('varenia', 250, 46, 'nation'),
    r('a', PROFILE[0][0], PROFILE[0][1] - 2, 'point', above),
    r('b', PROFILE[1][0], PROFILE[1][1] + 2, 'point', below),
    r('scale-0', SCALE.x, SCALE.y + 3, 'tick', below),
    r('scale-25', SCALE.x + 25, SCALE.y + 3, 'tick', below),
    r('scale-50', SCALE.x + 50, SCALE.y + 3, 'tick', below),
    r('north', NORTH.x, NORTH.y - 8, 'point', above),
    r('a-end', ...PROFILE[0]), r('b-end', ...PROFILE[1]),
  ],
  locator: [
    l('varenia', 205, 80, 'nation'), l('ostelia', 150, -100, 'country'),
    l('brunavia', 560, -120, 'country'), l('lira', 210, -250, 'sea', { rotate: 20 }),
    l('ocean', -180, -40, 'ocean', { width: 0.2 }), l('almaren', 259, 127 + 22, 'capital', below),
    { id: 'key', x: 0.115, y: 0.965, style: 'legend', verticalAlign: 'bottom' },
  ],
  // The section: fractions of the drawing, whose plot starts 14 mm in and runs 3 to 51 mm down.
  section: (() => {
    const [w, h] = MAP.section, x = (u) => (14 + u * (w - 14)) / w;
    const y = (m) => (h - 7 - m * (h - 10) / PROFILE_TOP) / h;
    return [
      { id: 'a', x: x(0), y: (h - 5.5) / h, style: 'point', ...below },
      { id: 'b', x: x(0.98), y: (h - 5.5) / h, style: 'point', ...below },
      ...[500, 1000, 1500, 2000].map((m) => ({ id: `m${m}`, x: 7 / w, y: y(m), style: 'tick' })),
      { id: 'sela', x: x(0.3), y: y(40), style: 'region', labelAt: { x: x(0.3), y: y(850) } },
      { id: 'crest', x: x(0.47), y: y(2260), style: 'range', ...above },
      { id: 'plain', x: x(0.82), y: y(160), style: 'region', labelAt: { x: x(0.82), y: y(850) } },
    ];
  })(),
};

アンカーは、画像の幅と高さに対する割合で表した点です。枠が地図をどの大きさに置いても成り立ち、収まらないときに地図が縮められても、地名はいっしょに動きます。km()は、画像の上に重ねた格子から読み取ったキロメートルの座標をこの割合に直します。都市の点とその名前はどちらもTOWNSから来るので、ずれることがありません。アンカーが持つのは言語ではなく場所に属するものです。スタイル、川や山脈の名前を流れや稜線に沿わせる回転、そしてラベルのどの側を点に合わせるか。都市名は点の上に中央そろえで置きます。align: 'start'は英語の名前では左、アラビア語の名前では右になるからです。

3枚の画像は順に描きました。まず地形図の図版を、この国の陰影付き標高図をもとに画像モデルで描き、位置図は地形図から、断面図は同じ標高から描いたので、3枚とも海岸線と高さがそろいます。それぞれの画像に重ねた格子から各アンカーのキロメートル値を読み取り、国境線は描かれた海岸に届くところで切ってあります。

#2 · 3つのMarkdownに1つのリソース

script.js · 482〜492行コード全体で見る
// A resource has no alt text, caption or note here: each edition's `:::figure` says its own.
const PAINTINGS = { // each plate's painting, a file in assets/, named by its width in pixels
  locator: asset('locator-1776.jpg'), relief: asset('relief-1984.jpg'),
  section: asset('section-1760.jpg') };
const drawings = { locator: locatorMap, relief: reliefMap, section: profile };
const resources = Object.entries(MAP).map(([id, [w, h]]) => ({ id, typeId: 'map', kind: 'svg',
  createdAt: 0, updatedAt: 0, svg: { fileId: `${id}.svg`, width: w * 10, height: h * 10 },
  anchors: ANCHORS[id] }));
for (const [id, draw] of Object.entries(drawings)) {
  await loadSvg(`${id}.svg`, draw(MAP[id], await dataUrl(PAINTINGS[id])));
}

リソースは画像が1つ(画像と、その上に重ねたベクターの記号を収めたSVG)、アンカーの一覧が1つで、すべての版が共有します。各版は:::figure{resource="relief" slot="map"}の中に、アンカーごとに::label[…]{at="…"}を1行書きます。::label[Llanura de Calvera]{at="plain"}と::label[Calvera Plain]{at="plain"}は同じ位置に置かれ、必要ならアンカーのwidthで2行に折り返されます。代替テキストも版ごとに変わります。各:::figureが::alt[…]の行で自分の分を書き、キャプションや注も同じく::caption[…]と::note[…]で書けます。スタイルを指定したアンカーにある版がラベルを書かないとanchorUnlabelledが出ます。atが存在しないアンカーを指すラベルは描かれず、labelAnchorUnknownが出ます。

#3 · 1ページの図版と見開きの図版

script.js · 75〜118行コード全体で見る
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const kicker = { kind: 'text', id: 'unit', content: '{attr.unit}', fontFamily: LABEL,
  fontSize: pt(AR ? 10 : 8.5), fontWeight: AR ? 500 : 600, letterSpacing: pt(1.3 * TRACK),
  textTransform: 'uppercase', color: col('sky'), align: AR ? 'right' : 'left',
  // Decoration stands on the sheet: the kicker goes to the side the page starts reading from.
  placement: at('container', AR ? 'top-right' : 'top-left', 0, -11) };
const band = { kind: 'box', id: 'band', style: { backgroundColor: col('band') },
  placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: mm(BAND + 3) } } };
const sheet = {
  id: 'sheet', header: false, decoration: { elements: [band, kicker] },
  frames: [
    { name: 'title', takes: 'h1', placement: at('container', 'top-left', 0, -3) },
    { name: 'text', flow: true, columns: 2, columnGap: mm(7),
      placement: at('container', 'top-left', 0, BAND - PAGE.top + 7) },
    { name: 'map' },
    { name: 'key', style: 'key', width: mm(66) },
    { name: 'tasks', style: 'tasks', placement: at('#key', 'right-of', 6) },
  ],
  // A longer text pushes the map and the key down; the map is set smaller before the text is.
  groups: [{ name: 'column', kind: 'stack', frames: ['text', 'map', 'key'], gap: mm(6) }],
};
const locator = { id: 'locator', extends: 'sheet', frames: [{ name: 'key', remove: true },
  { name: 'tasks', placement: at('#map', 'below', 0, 6) }],
  groups: [{ name: 'column', frames: ['text', 'map'] }] };
// Line A–B: two connectors between two anchors of the map, dotted ends, a see-through paper casing.
const section = (id, color, width, more) => ({ kind: 'connector', id, routing: 'straight',
  from: { to: '#map', anchor: 'a-end' }, to: { to: '#map', anchor: 'b-end' }, color: col(color),
  width: mm(width), ...more });
const sectionLine = [section('ab-casing', 'paper', 0.9, { opacity: 0.55 }), section('ab-line',
  'ink', 0.5, { dash: [mm(1), mm(1)], startCap: 'dot', endCap: 'dot', capSize: mm(2) })];
// The double sheet: one band and one map across both pages, the boxes under the map.
const spread = {
  id: 'spread', spread: true, header: false,
  decoration: { elements: [band, kicker, ...sectionLine] },
  frames: [
    { name: 'title', takes: 'h1', width: mm(177), placement: at('container', 'top-left', 0, -3) },
    { name: 'map', crossGutter: true, // the one frame that runs across the spine
      placement: at('container', 'top-left', 0, BAND - PAGE.top + 5) },
    { name: 'text', flow: true, columns: 2, columnGap: mm(7), width: mm(177) },
    { name: 'key', style: 'key', width: mm(72), placement: at('#map', 'below', 213, 6) },
    { name: 'tasks', style: 'tasks', placement: at('#key', 'right-of', 6) },
  ],
  groups: [{ name: 'column', kind: 'stack', frames: ['map', 'text'], gap: mm(6) }],
};

1ページの図版と見開きの図版は同じ5つの枠でできているので、図版のMarkdownは1ページでも2ページでも同じ形になります。タイトル、スロットを指定しない本文、地図、凡例、問題です。位置図の図版は1ページの図版をextendsで受け継ぎ、凡例の枠をremove: trueで外します。凡例が地図の上のラベルだからで、問題は地図の下に下がります。断面線は見開きの図版のものです。その装飾にある2つのconnector要素が、地図の枠に入った画像のアンカーa-endからアンカーb-endまでまっすぐ(straight)引かれます。0.9 mmの紙色の線の上に0.5 mmのインクの破線を重ね、両端に点を付けたものです。紙色の線には地図と一緒に描いた国境の縁取りと同じopacity: 0.55を指定しているので、下の段彩が透けて見え、緑や黄土色の上でも破線が読めます。anchorを持つ端は画像の切り抜きと拡大縮小に従うので、調整の段階で地図が小さく組まれても、線はAとBから離れません。装飾は枠の下に描かれますが、端にanchorを持つコネクターは画像の中を指すため、枠の上に描かれ、線が画像の上に見えます。見開きの図版ではspread: trueが2ページを幅390 mmの1枚のシートとして組み、crossGutterを指定しているのは地図の枠だけです。地図はのどをまたぎ、本文と囲みはそれぞれのページに収まります。本文、地図、凡例はstackグループです。テストベンチの負荷テストですべての文章を30 %長くすると、アラビア語版は位置図を87.5 %に縮め、その下の囲みが上に詰まります。警告は出ません。

#4 · 地図の上の凡例と、引き出し線の付いた地名

script.js · 43〜71行コード全体で見る
// A label takes the style its anchor names: seas and rivers in italic blue, ranges in spaced
// brown capitals, towns on a white halo. Arabic is neither slanted nor letter-spaced, and
// Naskh and Kufi set small, so the Arabic edition gets the same styles upright, unspaced and
// 15 % larger.
const [SLANT, TRACK, SIZE] = AR ? ['normal', 0, 1.15] : ['italic', 1, 1];
const halo = { color: col('paper'), width: pt(1.4) };
const style = (id, size, color, more) => ({ id, fontFamily: LABEL, fontSize: pt(size * SIZE),
  fontWeight: AR ? 500 : 400, color: col(color), ...more });
const water = (id, size, spacing, more) => style(id, size, 'water', { fontStyle: SLANT,
  textTransform: spacing ? 'uppercase' : 'none', letterSpacing: spacing * TRACK, ...more });
const caps = (id, size, color, spacing, more) => style(id, size, color, {
  fontWeight: AR ? 700 : 600, textTransform: 'uppercase', letterSpacing: spacing * TRACK,
  ...more });
const labelStyles = [
  water('ocean', 9.5, 0.3), water('sea', 7.5, 0.16), water('river', 6.8, 0, { halo }),
  caps('range', 7, 'relief', 0.32, { halo }), caps('region', 6.5, 'muted', 0.24, { halo,
    leader: { color: col('ink'), width: pt(0.6), endCap: 'dot', capSize: mm(1.2) } }),
  style('legend', 7.6, 'ink', { kind: 'legend', background: col('paper'), padding: mm(2.4),
    border: { color: col('muted'), width: pt(0.4) }, radius: mm(1) }),
  caps('country', 8.5, 'muted', 0.36, { halo }), caps('nation', 12, 'ink', 0.42, { halo }),
  style('capital', 7.6, 'ink', { fontWeight: 700, halo }), style('town', 7, 'ink', { halo }),
  style('peak', 6.5, 'ink', { fontWeight: AR ? 700 : 600, halo }),
  style('island', 6.5, 'ink', { halo }),
  style('point', 8.5, 'band', { fontWeight: 700, halo }), style('tick', 6, 'muted'),
];
// An anchor is a point of the picture in fractions of its width and height, with the side of
// the label that stands there, its turn and its style. km(win) reads a point in km off a map.
const km = (win) => (id, x, y, labelStyle, more) => ({ id, x: (x - win.x0) / (win.x1 - win.x0),
  y: (y - win.y0) / (win.y1 - win.y0), style: labelStyle, ...more });

legendスタイルはkind: 'legend'のラベルで、白い板、細い枠線、角の丸みを持ちます。そのMarkdownは図の中の:::label{at="key" style="legend"}ブロックで、1行が1項目です。:icon[]{resource="key-mark" color="country"} Vareniaは小さな正方形のリソースをパレットの色で塗り、:icon[]{line="dashed" color="border"}は国境の見本を描きます。行の頭の記号は1つの列にそろうので、言葉はその右に、アラビア語版では左に並びます。角かっこは空のままです。後に続く語がその行の名前になり、代替テキストのない記号は飾りとして読まれます。断面図では、アンカーselaとplainが地面にあり、そのlabelAtが名前を850 mの高さの空に置きます。regionスタイルのleaderが、各名前からその位置まで、点の付いた0.6 ptの線を引きます。

#5 · ページ、段彩、凡例に1つのパレット

script.js · 19〜33行コード全体で見る
const palette = {
  ink: '#1f2a2e', paper: '#ffffff', muted: '#55646a',
  band: '#1d5f73', // the accent: the head of each sheet, box stripes, list numbers
  sky: '#d4e9f2', // the kicker on the band
  tint: '#eef2ef', // the key's box
  water: '#0b2a47', sea: '#8ec5e9', // the names of water, and the sea of the key
  // The key's tints are the median colours of the painted relief at each height band.
  low: '#aec67f', hill: '#ced285', upland: '#efce80', mount: '#d79c61', peak: '#b5734b',
  relief: '#5a3519', // the names of ranges
  land: '#e1dfbe', country: '#ebcb73', border: '#8a3b52', // the locator map's washes and border
};
// col(id) links a colour to its palette entry; the vector symbols read the same hex from `palette`.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.band }) // the defaults' id
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));

5段階の高さの色はパレットの項目(palette.lowからpalette.peak)で、描かれた地形が各層で持つ中央値の色に合わせてあります。図版2の凡例は同じIDで:swatch{color="low"}を書きます。画像はパレットに従いません。16進値を1つ変えると、変わるのは凡例とベクターの記号だけで、画像はそのままです。地図の色を変えるには描き直します。水域の名前に使うwaterは、描かれた海の上で少なくとも6:1のコントラストがあり、白いタイトルはbandの上で7.2:1です。

#6 · アラビア語版

コードは上の手短な答えにあります。locale: 'ar'で本文は右から左に組まれ、本は右綴じになります。見開きは右ページから始まり、枠は左右反転した版面に従います。タイトルと本文は右に、凡例は問題の右に来ます。地図そのものは反転せず、アラビア語の地名はそれぞれの場所が描かれた位置に置かれます。アラビア語ではラベルスタイルからイタリックと字間を外し、15 %大きくします。クーフィー体は小さく組まれるからです。装飾とノンブルはシートに対して置かれるので、柱の小見出しは右上に移り、ノンブルは左右が入れ替わります。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 157 · A school atlas labelled from the Markdown ═══════
// https://postext.dev/en/cookbook/school-atlas-labelled-maps
// Code: MIT · Text: original (CC BY 4.0) · Maps: painted with diffusion models, symbols set in code
// Fonts: Source Sans 3, Source Serif 4, Noto Naskh and Kufi Arabic (OFL) · Needs postext ≥ 1.49.0
//
// Three pages of a school atlas of Varenia, an invented country: a locator map, the relief map
// across a double page and a section through the mountains. The maps are painted without a letter.
// Every name on them is a ::label in content.<lang>.md, standing at an anchor of the resource,
// so the Spanish, English and Arabic editions share the same paintings and the same anchors.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'es'; // @lang: the language of the sample document ('es' | 'en' | 'ar')
const RECIPE = 'school-atlas-labelled-maps';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the page's colours and the key's tints, one object for both
const palette = {
  ink: '#1f2a2e', paper: '#ffffff', muted: '#55646a',
  band: '#1d5f73', // the accent: the head of each sheet, box stripes, list numbers
  sky: '#d4e9f2', // the kicker on the band
  tint: '#eef2ef', // the key's box
  water: '#0b2a47', sea: '#8ec5e9', // the names of water, and the sea of the key
  // The key's tints are the median colours of the painted relief at each height band.
  low: '#aec67f', hill: '#ced285', upland: '#efce80', mount: '#d79c61', peak: '#b5734b',
  relief: '#5a3519', // the names of ranges
  land: '#e1dfbe', country: '#ebcb73', border: '#8a3b52', // the locator map's washes and border
};
// col(id) links a colour to its palette entry; the vector symbols read the same hex from `palette`.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.band }) // the defaults' id
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const AR = LANG === 'ar';
// Three voices per script: a text face, a display face and the face of the map labels.
const [TEXT, DISPLAY, LABEL] = AR ? ['Noto Naskh Arabic', 'Noto Kufi Arabic', 'Noto Kufi Arabic']
  : ['Source Sans 3', 'Source Serif 4', 'Source Sans 3'];
const PAGE = { w: 210, h: 280, top: 22, bottom: 20, inner: 18, outer: 15 }; // mm, mirrored
const BAND = 44; // mm from the trim to the foot of the band at the head of a sheet

// #region answer: label styles in the config, label fields on the anchors of a resource
// A label takes the style its anchor names: seas and rivers in italic blue, ranges in spaced
// brown capitals, towns on a white halo. Arabic is neither slanted nor letter-spaced, and
// Naskh and Kufi set small, so the Arabic edition gets the same styles upright, unspaced and
// 15 % larger.
const [SLANT, TRACK, SIZE] = AR ? ['normal', 0, 1.15] : ['italic', 1, 1];
const halo = { color: col('paper'), width: pt(1.4) };

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

アレンジ

#アンカーのない場所に名前を入れる

ラベルは、画像に対するパーセントで指定した点に、独自のスタイルで置くこともできます。

 :::figure{resource="relief" slot="map"}
+::label[Faro de Nema]{at="7% 68%" style="town"}
 ::label[Océano Brumoso]{at="ocean"}

#地図に番号とキャプションを付ける

地図の種類にカウンターと接頭辞を、各リソースにキャプションを与えます。番号付きの地図を載せた地図帳の図版は、地図のキャプションを青い帯の上に置いています。

よくあるつまずき

レイアウト警告 · labelAnchorUnknown

存在しないアンカーのラベル

原因. :::figureの::labelがat=で、図のリソースにないアンカーを指しています。ラベルは画像の上に描かれません。リフロー型EPUBでは引き続き一覧に出て、画像の代替テキストにも含まれます。

対処. at=のアンカーidを直す(警告にリソースのアンカーが並びます)か、リソースにアンカーを追加するか、at="x% y%"で位置を指定してください。 ドキュメント →

レイアウト警告 · anchorUnlabelled

ラベルのないアンカー

原因. 図のリソースのアンカーにラベルスタイルが設定されているのに、この言語ではそこに図の::labelが1つもありません。地図に置き場所のある語が、この版では抜けています。エラーではなく情報です。スタイルのないアンカー(漫画の話者のものなど)は報告されません。

対処. この言語のMarkdownにラベルを書く(::label[…]{at="アンカー"})か、この版でその語を使わないならアンカーのスタイルを外してください。 ドキュメント →

  • 各地図の代替テキストはMarkdownに、各:::figureの中の::alt[…]の行として、版ごとに1つ書きます。書かない図は、リソース自身のaltTextのままです。script.jsにはページの言葉が1つも残りません。
  • 端が枠しか指していないコネクターは、ほかの装飾といっしょに枠の下に描かれます。画像の上に出るのは、端にanchorを持つものだけです。注から地図の縁まで引いたアンカーのない線は、画像と重なるところで隠れます。
  • アンカーとベクターの記号(国境、町、山頂、断面線の両端)は、画像から読み取ったキロメートルの位置にあります。地図を描き直すと海岸線も川も尾根も動きます。新しい画像に格子を重ねて読み直さないと、地名が海に落ちます。
  • 右から左のページでは、枠は版面といっしょに反転しますが、テンプレートの装飾は反転しません。kickerのように、小見出しの位置を版ごとに決めてください。
  • 2段組みの枠は、段落を最後の1行の手前で切り、その1行を2段目の頭に残すことがあります。版ごとに段を確かめ、そうなったら1文を次の段落に移してください。

クレジット

レシピ
Ignacio Ferro
本文
書き下ろしの文章, CC BY 4.0
画像
  • The locator map of Varenia and its neighbours, painted as a physical map with a golden wash over Varenia. · Generated With Diffusion Models · オリジナル
  • The relief map of Varenia across a double page: hypsometric tints, hill shading, coastal shelf, rivers and a lake. · Generated With Diffusion Models · オリジナル
  • The section from A to B painted as a slice of land cut along the line, in the height bands of the map. · Generated With Diffusion Models · オリジナル
フォント
Source Sans 3 (SIL OFL 1.1) · Source Serif 4 (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1)
Sandbox