简单来说
一页漫画只画一次,排成三种版式。同样的五幅画面和同样的对白填进三种不同的分格,每幅画面都按新的格子重新裁切。
成品一览
一份漫画单页的版式校样,作品是《珀斯科夫灯塔》:一张封面,加上同一页的三种方案,供作者挑选。五幅画面(玛雅爬上灯塔、外公守着不响的收音机、玛雅指着地板、猫睡在电线上、夜里点亮的灯)和六句嵌字始终不变,变的只是每个 :::page 的 split。每幅画面都按所在的格子重新裁切,每个对话框都重新放到说话人旁边。开本是美式漫画书的 168 × 259 mm,校样有十个版本,各用自己的语言嵌字。
这道食谱解答
- 怎样把一页分成漫画格?
- 格子裁切画面时,怎样让人物的脸留在画内?
- 怎样把漫画用另一种语言重新嵌字?
简短回答
// 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.jpglh-beam.jpglh-biscuit.jpglh-maya.jpglh-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 行按阅读顺序填格:行从上到下,栏从起始一侧开始。

#2 · 给每幅画面设安全区
// 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 · 一个版式,十个语言版本
// 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 只放文字,人物标识保持不变(maya、tomas)。日文版的对话框竖排,每列八个字,并去掉句末的“。”;日文版和阿拉伯文版都从右往左读,所以每一行的格子顺序左右对调,画面本身不翻转。各版的嵌字字号都是 8 pt:句子长了,对话框就变大,字永远不缩小(嵌字)。
完整食谱
// ═══ 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 = 'zh'; // @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里的收音机。
致谢
- 文本
- 原创文字, 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)


