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

レシピ集 · 第11章 · コミックと漫画

同じコマを三通りのページ割りで

五つのコマを三つの分割ツリーで組む。:::pageのsplit属性がページを割り、各絵のセーフエリアがどんな形のコマでも主役を画面に残します。

このページの内容
出力
Canvas · PDF
レベル
中級
Postext
Postext 1.65.0で検証済み
1.25.0以上が必要 · postext-pdf ≥ 1.25.0
ライセンス
2026年10月10日更新
コードMIT · 本文CC BY 4.0

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

  • 仕上がり168 × 259 mm
  • 1段
  • Zen Antique 10.5/15
  • Dela Gothic One
  • 4ページ
  • レベル
  • Postext 1.65.0
  • 組版時間381 ms
  • コード132行

かんたんな説明

一度描いた漫画のページを三通りに組みます。同じ五枚の絵と同じせりふが三種類のコマ割りに収まり、絵は新しいコマに合わせて切り直されます。

できあがり

漫画『ポースコーヴの灯』の一ページぶんのレイアウト校正です。表紙と、同じページを三案に組んだもので、作者が一つを選びます。五枚の絵(灯台へ登るマヤ、黙ったラジオの前の祖父、床を指さすマヤ、コードの上で眠る猫、夜にともった灯)と六つのせりふは変わらず、変わるのは各:::pageのsplitだけです。絵はコマごとに切り直され、吹き出しは話者のそばに置き直されます。判型はアメリカのコミックブックの168 × 259 mmで、校正は十の版に分かれ、それぞれの言語で写植されます。

このレシピが答える質問

  • ページをコマに割るには?
  • コマが絵をトリミングしても顔が切れないようにするには?
  • 漫画を別の言語で写植し直すには?

手短な答え

script.js · 48〜65行コード全体で見る
// Every :::page fills the type area; its split attribute cuts it into cells and its ::panel
// lines fill them in reading order (rows top to bottom, columns from the start side):
//   :::page{split="30 / 35 [* | * | *] / *"}    three tiers, the middle one in three
//   :::page{split="60 [* / *] | * [* / * / *]"} two columns, then each column in tiers
//   :::page{split="30 [30 | 20 | *] / *"}       a 30 % tier cut 30 | 20 | rest, then the rest
// A size is a percentage of the parent cell, * shares what is left, [ … ] cuts that cell
// on the other axis. A panel with inset="x y w h" sits over the panel before it.
const comics = {
  gutter: { horizontal: mm(4), vertical: mm(3) }, // between tiers, between panels in a tier
  panel: { borderWidth: pt(1), borderColor: col('ink'), background: col('paper') },
  lettering: { fontFamily: LETTERING, fontSize: pt(8), color: col('ink'), inset: mm(1) },
  balloonStyles: [
    { id: 'speech', stroke: col('ink') },
    { id: 'caption', fill: col('caption'), stroke: col('ink') },
    { id: 'sfx', fontFamily: SFX, color: col('accent'), haloColor: col('paper') },
  ],
  runningHeads: true, // a comic page has no running head unless asked: here, its folio
};

材料

種類
Comic Neue, Bangers, Zen Antique, Dela Gothic One, ZCOOL KuaiLe, ZCOOL QingKe HuangYou, Playpen Sans Arabic, Lalezar (SIL OFL 1.1)
素材
  • lh-arrive.jpg
  • lh-beam.jpg
  • lh-biscuit.jpg
  • lh-maya.jpg
  • lh-radio.jpg
  • Panel picture: Maya arrives at the lighthouse (Generated With Diffusion Models, オリジナル)
  • Panel picture: Tomás at the radio (Generated With Diffusion Models, オリジナル)
  • Panel picture: Maya finds the problem (Generated With Diffusion Models, オリジナル)
  • Panel picture: Biscuit asleep on the cable (Generated With Diffusion Models, オリジナル)
  • Panel picture: the lamp lit at night (Generated With Diffusion Models, オリジナル)

作り方

#1 · 分割ツリーでページを割る

コードは前の手短な答えにあります。:::pageは版面いっぱい、ここでは144 × 227 mmを占め、そのsplit属性がページを割ります。/は段を、|は列を分け、数値は割る対象のコマに対する百分率、*は残りを等分し、角括弧はそのコマをもう一方の向きでさらに割ります(ページの分割)。C案の30 [30 | 20 | *] / *は、高さ30%の段を作って幅30%と20%と残りの三コマに割り、その下に縦長の一コマを残します。間白はそれぞれの分割線をまたいで取られ、段と段の間が4 mm、同じ段のコマの間が3 mmです。::panelの行は読む順にコマを埋めます。段は上から、列は始まりの側からです。

C案:30 | 20 | 残りの段。猫は三コマ目に重ねた小ゴマ。

#2 · 絵ごとにセーフエリアを決める

script.js · 182〜293行コード全体で見る
// From the art manifest; fractions of each picture, the same in every language. The safe
// area is what every crop keeps: Tomás alone, not his radio, so a cell a fifth of the page
// wide still shows him; the lighthouse and the gallery, not the boat, so a tall cell holds them.
const ART = {
  'lh-arrive': { width: 1100, height: 733, safeArea: { x: 0.22, y: 0.08, width: 0.4, height: 0.64 },
    anchors: [{ id: 'maya', x: 0.29, y: 0.52, head: { x: 0.27, y: 0.47 },
      face: { x: 0.22, y: 0.42, width: 0.12, height: 0.16 } },
    { id: 'biscuit', x: 0.4, y: 0.68, face: { x: 0.37, y: 0.64, width: 0.07, height: 0.08 } }],
    avoid: [{ x: 0.51, y: 0.09, width: 0.1, height: 0.43 }],
    alt: t({ en: 'A girl in a yellow raincoat walks up a coastal path towards a red-and-white '
      + 'lighthouse, a fat orange cat ahead of her.',
      es: 'Una niña con chubasquero amarillo sube por un camino de costa hacia un faro rojo y '
        + 'blanco, con un gato naranja gordo delante.',
      ca: 'Una nena amb impermeable groc puja per un camí de costa cap a un far vermell i blanc, '
        + 'amb un gat taronja gras al davant.',
      zh: '一个穿黄色雨衣的女孩沿着海边小路走向红白相间的灯塔,一只胖胖的橘猫走在前面。',
      ar: 'فتاة بمعطف مطر أصفر تصعد دربًا ساحليًا نحو منارة حمراء وبيضاء، وأمامها قط برتقالي سمين.',
      ja: '黄色いレインコートの女の子が、赤と白の灯台へ続く海辺の小道をのぼっていく。前を太ったオレンジ色の猫が歩く。',
      pt: 'Uma menina de capa de chuva amarela sobe um caminho à beira-mar rumo a um farol '
        + 'vermelho e branco, com um gato laranja gordo à frente.',
      fr: 'Une fillette en ciré jaune monte un sentier côtier vers un phare rouge et blanc, '
        + 'précédée d’un gros chat roux.',
      de: 'Ein Mädchen in gelbem Regenmantel geht einen Küstenpfad zu einem rot-weißen '
        + 'Leuchtturm hinauf, eine dicke rote Katze vor ihr.',
      it: 'Una bambina con l’impermeabile giallo sale per un sentiero costiero verso un faro '
        + 'bianco e rosso, preceduta da un grosso gatto rosso.' }) },
  'lh-radio': { width: 1000, height: 1000,
    safeArea: { x: 0.27, y: 0.38, width: 0.24, height: 0.3 },
    anchors: [{ id: 'tomas', x: 0.345, y: 0.52, head: { x: 0.38, y: 0.44 },
      face: { x: 0.29, y: 0.4, width: 0.16, height: 0.18 } }],
    avoid: [{ x: 0, y: 0.44, width: 0.22, height: 0.26 }],
    alt: t({ en: 'The old keeper, white-bearded, in a navy sweater and cap, taps a valve radio '
      + 'with the microphone in his hand.',
      es: 'El viejo farero, de barba blanca, jersey azul marino y gorra, golpea una radio de '
        + 'válvulas con el micrófono en la mano.',
      ca: 'El vell faroner, de barba blanca, jersei blau marí i gorra, pica una ràdio de vàlvules '
        + 'amb el micròfon a la mà.',
      zh: '白胡子的老守塔人穿着藏青色毛衣、戴着帽子,手握话筒,敲着一台电子管收音机。',
      ar: 'حارس المنارة العجوز بلحيته البيضاء وكنزته الكحلية وقبعته ينقر على مذياع قديم '
        + 'والميكروفون في يده.',
      ja: '白いひげの老灯台守が、紺のセーターに帽子姿でマイクを握り、真空管ラジオをたたいている。',
      pt: 'O velho faroleiro, de barba branca, suéter azul-marinho e boné, dá batidinhas num '
        + 'rádio valvulado com o microfone na mão.',
      fr: 'Le vieux gardien, barbe blanche, pull bleu marine et casquette, tapote une radio à '
        + 'lampes, le micro à la main.',
      de: 'Der alte Wärter mit weißem Bart, marineblauem Pullover und Mütze klopft auf ein '
        + 'Röhrenradio, das Mikrofon in der Hand.',
      it: 'Il vecchio guardiano, barba bianca, maglione blu e berretto, picchietta su una radio a '
        + 'valvole con il microfono in mano.' }) },
  'lh-maya': { width: 1100, height: 1100, safeArea: { x: 0.25, y: 0.27, width: 0.41, height: 0.68 },
    anchors: [{ id: 'maya', x: 0.54, y: 0.565, head: { x: 0.5, y: 0.3 },
      face: { x: 0.4, y: 0.33, width: 0.24, height: 0.29 } }],
    avoid: [{ x: 0.27, y: 0.73, width: 0.25, height: 0.22 }],
    alt: t({ en: 'Close-up of Maya frowning at the floor and pointing down.',
      es: 'Primer plano de Maya, que frunce el ceño mirando al suelo y señala hacia abajo.',
      ca: 'Primer pla de la Maya, que arrufa les celles mirant a terra i assenyala avall.',
      zh: '玛雅的特写:她皱着眉头看着地板,手指向下指。',
      ar: 'لقطة قريبة لمايا وهي تعقد حاجبيها ناظرةً إلى الأرض وتشير إلى أسفل.',
      ja: 'マヤのアップ。眉をひそめて床を見つめ、下を指さしている。',
      pt: 'Close de Maya, de testa franzida, olhando para o chão e apontando para baixo.',
      fr: 'Gros plan sur Maya, sourcils froncés, qui fixe le sol et pointe le doigt vers le '
        + 'bas.',
      de: 'Nahaufnahme von Maya, die mit gerunzelter Stirn auf den Boden blickt und nach unten '
        + 'zeigt.',
      it: 'Primo piano di Maya, accigliata, che fissa il pavimento e indica in basso.' }) },
  'lh-biscuit': { width: 1000, height: 1000,
    safeArea: { x: 0.58, y: 0.25, width: 0.42, height: 0.33 },
    anchors: [{ id: 'biscuit', x: 0.72, y: 0.355, head: { x: 0.73, y: 0.32 },
      face: { x: 0.64, y: 0.27, width: 0.2, height: 0.18 } }],
    avoid: [{ x: 0.93, y: 0.28, width: 0.07, height: 0.24 },
      { x: 0, y: 0.72, width: 0.4, height: 0.1 }],
    alt: t({ en: 'Under the desk the fat orange cat sleeps on his back, right on top of the black '
      + 'radio cable.',
      es: 'Bajo la mesa, el gato naranja gordo duerme panza arriba justo encima del cable negro '
        + 'de la radio.',
      ca: 'Sota la taula, el gat taronja gras dorm panxa enlaire just a sobre del cable negre de '
        + 'la ràdio.',
      zh: '桌子底下,胖橘猫四脚朝天地睡着,正好压在收音机的黑色电线上。',
      ar: 'تحت المكتب ينام القط البرتقالي السمين على ظهره فوق سلك المذياع الأسود تمامًا.',
      ja: '机の下で、太ったオレンジ色の猫がラジオの黒いコードの真上にあおむけで眠っている。',
      pt: 'Debaixo da mesa, o gato laranja gordo dorme de barriga para cima bem em cima do cabo '
        + 'preto do rádio.',
      fr: 'Sous le bureau, le gros chat roux dort sur le dos, juste sur le câble noir de la '
        + 'radio.',
      it: 'Sotto la scrivania, il grosso gatto rosso dorme a pancia in su, proprio sopra il cavo '
        + 'nero della radio.',
      de: 'Unter dem Schreibtisch schläft die dicke rote Katze auf dem Rücken, genau auf dem '
        + 'schwarzen Kabel des Funkgeräts.' }) },
  'lh-beam': { width: 1200, height: 800, safeArea: { x: 0.15, y: 0.01, width: 0.25, height: 0.3 },
    anchors: [{ id: 'maya', x: 0.235, y: 0.15,
      face: { x: 0.21, y: 0.11, width: 0.05, height: 0.07 } },
      { id: 'tomas', x: 0.3, y: 0.145, face: { x: 0.28, y: 0.11, width: 0.04, height: 0.06 } }],
    avoid: [{ x: 0.79, y: 0.55, width: 0.08, height: 0.09 }],
    alt: t({ en: 'Night: the beam sweeps over a dark sea; Maya and her grandfather stand on the '
      + 'lantern gallery and a fishing boat shows its lights far out.',
      es: 'De noche, el haz barre un mar oscuro; Maya y su abuelo están en la galería de la '
        + 'linterna y a lo lejos se ven las luces de un pesquero.',
      ca: 'De nit, el feix escombra un mar fosc; la Maya i el seu avi són a la galeria de la '
        + 'llanterna i lluny es veuen els llums d’un pesquer.',
      zh: '夜里,灯塔的光束扫过漆黑的海面;玛雅和外公站在灯室外的回廊上,远处一艘渔船亮着灯。',
      ar: 'ليلًا يمسح الشعاع بحرًا مظلمًا، ومايا وجدّها واقفان على شرفة الفانوس، وفي البعيد قارب '
        + 'صيد بأضوائه.',
      ja: '夜。光の帯が暗い海をなでる。マヤと祖父は灯室の回廊に立ち、沖には漁船の明かりが見える。',
      pt: 'À noite, o facho varre um mar escuro; Maya e o avô estão na galeria da lanterna e, ao '
        + 'longe, aparecem as luzes de um barco de pesca.',
      fr: 'La nuit, le faisceau balaie une mer sombre ; Maya et son grand-père se tiennent sur '
        + 'la galerie de la lanterne et, au large, un bateau de pêche montre ses feux.',
      de: 'Nacht: Der Lichtstrahl streicht über ein dunkles Meer; Maya und ihr Großvater stehen '
        + 'auf der Galerie der Laterne, und weit draußen zeigt ein Fischerboot seine Lichter.',
      it: 'Di notte il fascio di luce spazza un mare scuro; Maya e suo nonno sono sulla balconata '
        + 'della lanterna e, al largo, si vedono le luci di un peschereccio.' }) },
};

絵は一度だけ描き、入るコマを埋めるように切り抜かれます。セーフエリアは、どの切り抜きでも欠けずに残る部分です(コマと絵)。ラジオの絵のセーフエリアは灯台守だけで幅の24%なので、C案の幅26 mmのコマでは帽子から長靴まで彼が見え、ラジオは外れます。A案とB案の横長のコマでは両方が見えます。コマの形にセーフエリアが収まらないときは、絵の上下か左右に余白が出て、組版時に警告が出ます(comicPanelLetterbox)。アンカーは各人物の口と顔を同じ比率で示すので、どの切り抜きでも吹き出しのしっぽは話者に届きます。

#3 · コマの上にコマを重ねる

C案の割り方では、五コマに対してセルが四つしかありません。猫はinset="50 50 46 46"で入れます。直前のコマ(マヤのコマ)の幅と高さの46%の大きさで、その50%、50%の位置に置く小ゴマです。小ゴマはセルを使わないので後のコマの位置は変わらず、重なっているコマのすぐ後に読まれます。

#4 · 一つのレイアウトで十の版を写植する

script.js · 35〜44行コード全体で見る
// The lettering and sound-effect faces of each edition: the engine's defaults, but for Chinese
// two ZCOOL faces drawn for cartoons instead of Noto Sans SC. content.<lang>.md holds the words
// of each edition under the same speaker ids; Japanese balloons are set vertically, and the
// Japanese and Arabic editions, read right to left, mirror the order of the panels in every row.
const [LETTERING, SFX] = t({
  en: ['Comic Neue', 'Bangers'], es: ['Comic Neue', 'Bangers'], ca: ['Comic Neue', 'Bangers'],
  ja: ['Zen Antique', 'Dela Gothic One'], zh: ['ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou'],
  ar: ['Playpen Sans Arabic', 'Lalezar'], pt: ['Comic Neue', 'Bangers'],
  fr: ['Comic Neue', 'Bangers'], de: ['Comic Neue', 'Bangers'], it: ['Comic Neue', 'Bangers'],
});

割り方、絵、切り抜き、アンカーはどの言語でも同じです。content.<lang>.mdには言葉だけを、同じ話者ID(maya、tomas)で書きます。日本語版は吹き出しを縦組みにし、一行八字までで、文末の「。」を取ります。日本語版もアラビア語版も右から左へ読むので、各段のコマの並びが左右逆になりますが、絵そのものは反転しません。写植の文字サイズはどの版も8 ptです。せりふが長ければ吹き出しが大きくなり、文字が小さくなることはありません(写植)。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 144 · One set of panels, three page splits ═══════════════
// https://postext.dev/en/cookbook/comic-page-splitters
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Comic Neue, Bangers and the faces of five editions (OFL) · Needs postext ≥ 1.25.0
//
// A layout proof for one page of a comic: the same five pictures and the same lines of
// dialogue laid out under three `split` trees. Each picture carries a safe area, so its subject
// stays in view whether its cell is wide, tall or square, and the lettering is placed again
// around the speakers' anchors on every page and in every language.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage, loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'ja'; // @lang: 'en' | 'es' | 'ca' | 'zh' | 'ar' | 'ja' | 'pt' | 'fr' | 'de' | 'it'
const RECIPE = 'comic-page-splitters';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the night sea, the lighthouse red and the yellow of the captions
const palette = {
  ink: '#1b2430', // panel borders, lettering and text: a blue-black
  accent: '#b8322a', // the lighthouse red: the proof's labels
  caption: '#f4e7bf', // caption boxes, an old-paper yellow
  muted: '#5f6873', // folios and the imprint
  paper: '#fdfbf6',
};
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: one comic, six editions, each lettered in faces for its script
// The lettering and sound-effect faces of each edition: the engine's defaults, but for Chinese
// two ZCOOL faces drawn for cartoons instead of Noto Sans SC. content.<lang>.md holds the words
// of each edition under the same speaker ids; Japanese balloons are set vertically, and the
// Japanese and Arabic editions, read right to left, mirror the order of the panels in every row.
const [LETTERING, SFX] = t({
  en: ['Comic Neue', 'Bangers'], es: ['Comic Neue', 'Bangers'], ca: ['Comic Neue', 'Bangers'],
  ja: ['Zen Antique', 'Dela Gothic One'], zh: ['ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou'],
  ar: ['Playpen Sans Arabic', 'Lalezar'], pt: ['Comic Neue', 'Bangers'],
  fr: ['Comic Neue', 'Bangers'], de: ['Comic Neue', 'Bangers'], it: ['Comic Neue', 'Bangers'],
});
// #endregion

// #region answer: the comic: a frame, gutters, a panel border, and a page per split
// Every :::page fills the type area; its split attribute cuts it into cells and its ::panel

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

アレンジ

#中段を斜めに割る

30~40と書いた数値は、そのコマの終わりの間白を一端の30%から他端の40%まで斜めに引きます。斜めのコマは角が丸くなりません。

-:::page{split="30 / 35 [* | * | *] / *"}
+:::page{split="30 / 35 [30~40 | * | *] / *"}

#右から左へ読む版で絵を反転する

絵は初期設定では向きを変えません。文字も時計も描かれていない漫画なら、読む向きに合わせて反転できます。

 const comics = {
+  mirrorArt: true, // 右から左の版では絵を反転する
   gutter: { horizontal: mm(4), vertical: mm(3) },

よくあるつまずき

  • ページ幅の五分の一のコマには、8 ptで一行に英単語四つほどしか入りません。C案の灯台守は顔がコマの真ん中にあり、嵐を告げる二つの吹き出しは顔の上にも下にも収まりません。そこでC案だけ、二行のうち最初の行にbreakを付けています(tomas{break}:)。二つの吹き出しは枠を越えて隣のマヤのコマへ入ってもよく、エンジンは二つ目を一つ目の後に置き、ページの余白へは出しません。breakがなければビルドはcomicBalloonOverflowを警告します。
  • セーフエリアを狭くすると多くのコマできれいに切り抜けますが、外側にあるものは欠けることがあります。A案の上段の長靴、C案のラジオがそうです。

クレジット

レシピ
Ignacio Ferro
本文
書き下ろしの文章, CC BY 4.0
画像
  • Panel picture: Maya arrives at the lighthouse · Generated With Diffusion Models · オリジナル
  • Panel picture: Tomás at the radio · Generated With Diffusion Models · オリジナル
  • Panel picture: Maya finds the problem · Generated With Diffusion Models · オリジナル
  • Panel picture: Biscuit asleep on the cable · Generated With Diffusion Models · オリジナル
  • Panel picture: the lamp lit at night · Generated With Diffusion Models · オリジナル
フォント
Comic Neue (SIL OFL 1.1) · Bangers (SIL OFL 1.1) · Zen Antique (SIL OFL 1.1) · Dela Gothic One (SIL OFL 1.1) · ZCOOL KuaiLe (SIL OFL 1.1) · ZCOOL QingKe HuangYou (SIL OFL 1.1) · Playpen Sans Arabic (SIL OFL 1.1) · Lalezar (SIL OFL 1.1)
SandboxPDF