Коротко
Страница комикса о спасении в шторм, где есть все виды облачков, и таблица стилей, из которой видно, как каждое записано в сценарии.
Что получится
Страница 7 комикса The Porthcove Light о штормовой ночи на маяке, а перед ней таблица стилей летерера. У траулера глохнет двигатель, смотритель ведёт его по рации, Майя ждёт с котом, а утром шкипер благодарит обоих. На странице есть все виды облачков, которые рисует Postext: речь, соединённая речь, мысль, шёпот, крик, рация, подписи рассказчика, внутренний голос, заметка редактора, звукоподражание, голос за кадром и закреплённое облачко. Обрезной формат как у американского комикса, 168 × 259 мм, языковых версий десять.
Рецепт отвечает на вопросы
- Как показать облачка мысли, шёпота, крика и радио?
- Как направить хвостик облачка на говорящего персонажа?
- Как сделать леттеринг звукоподражаний поверх рисунка?
- Как писать речевые облачка в Markdown?
Короткий ответ
// A script line is `speaker{kind}: text`. The kinds are balloon styles: the engine ships
// speech, thought, whisper, shout, radio, caption, inner, note and sfx, and a style of the
// same id here changes only what it names. `caption`, `note` and `sfx` are reserved speakers.
const balloonStyles = [
{ id: 'speech', stroke: col('ink') }, // an oval, a curved tail to the mouth
{ id: 'thought', stroke: col('ink') }, // a cloud, bubbles to the head
{ id: 'whisper', stroke: col('ink') }, // a dashed outline, 0.9 × the type
{ id: 'shout', stroke: col('ink'), burstPoints: 16 }, // a burst, bold, 1.15 × the type
{ id: 'radio', stroke: col('ink') }, // a zig-zag outline and tail: a voice through a set
{ id: 'caption', fill: col('caption'), stroke: col('ink') }, // narration, butted to a corner
{ id: 'inner', fill: col('inner'), stroke: col('ink') }, // no tail, italic where it can be
{ id: 'note', fill: col('paper'), stroke: col('ink') }, // the editor's note, 0.8 × the type
{ id: 'sfx', fontFamily: SFX, color: col('accent'), haloColor: col('paper') }, // no balloon
];
const comics = {
gutter: { horizontal: mm(4), vertical: mm(3) },
panel: { borderWidth: pt(1), borderColor: col('ink'), background: col('paper') },
lettering: { fontFamily: LETTERING, fontSize: pt(7.5), color: col('ink'), inset: mm(1) },
balloonStyles,
// A speaker's own style: every `skipper:` line comes through the radio unless it says not.
cast: [{ id: 'skipper', balloonStyle: 'radio', name: t({ en: 'The skipper', es: 'El patrón',
ca: 'El patró', zh: '船长', ar: 'الربّان', ja: '船長', pt: 'O capitão', fr: 'Le patron',
de: 'Der Kapitän',
it: 'Il capitano' }) }],
runningHeads: true, // a comic page has no running head unless asked: here, its folio
};
Ингредиенты
- Возможности
- Стили облачковЗвукоподражанияПерсонажи и якоряРазбиение на кадрыРисунок кадра и кадрированиеСтраницы комиксовЛеттеринг комиксовЛеттеринг на других языкахСемантическая палитраСтраницы на холстеЭкспорт в PDF
- Также применяет
- Плашки в строкеРамки кадров и промежуткиЦвет бумагиСтили абзацевШрифты, встроенные в PDFРисунки и таблицы как ресурсы
- Шрифты
- Comic Neue, Bangers, Zen Antique, Dela Gothic One, ZCOOL KuaiLe, ZCOOL QingKe HuangYou, Playpen Sans Arabic, Lalezar (SIL OFL 1.1)
- Материалы
bk-morning.jpgbk-sea.jpgbk-shout.jpgbk-storm.jpgbk-whisper.jpgbk-window.jpg- Panel picture: the storm in the lamp room (Generated With Diffusion Models, оригинал)
- Panel picture: Maya and the cat under the desk (Generated With Diffusion Models, оригинал)
- Panel picture: the keeper shouting into the microphone (Generated With Diffusion Models, оригинал)
- Panel picture: the trawler in the storm (Generated With Diffusion Models, оригинал)
- Panel picture: Maya at the window (Generated With Diffusion Models, оригинал)
- Panel picture: the next morning on the rocks (Generated With Diffusion Models, оригинал)
Порядок работы
#1 · Назовите вид в строке сценария
Код приведён выше, в разделе «Короткий ответ». Строка сценария имеет вид speaker{kind}: text, где вид — идентификатор стиля облачка. Девять встроенных стилей покрывают обычные случаи: овал с изогнутым хвостиком для речи, облако с пузырьками для мысли, пунктирный контур для шёпота, взрыв с клиновидным хвостиком для крика, зубчатый контур с зигзагообразным хвостиком для голоса по рации (стили облачков). Стиль в конфигурации с тем же идентификатором меняет только то, что называет: здесь это цвет обводки, жёлтый цвет подписи и 16 лучей взрыва. caption, note и sfx — зарезервированные говорящие: прямоугольники рассказчика, прижатые к углу, заметка редактора кеглем 0,8 и акцидентные буквы без облачка.

#2 · Направьте каждый хвостик к говорящему
// From the art manifest; fractions of each picture, the same in every language. `skipper` in
// the storm picture is the radio set, the voice's source; in the sea picture, his boat.
const ART = {
'bk-storm': { width: 1100, height: 733, safeArea: { x: 0.05, y: 0.26, width: 0.52, height: 0.36 },
anchors: [{ id: 'tomas', x: 0.3, y: 0.44, head: { x: 0.32, y: 0.33 },
face: { x: 0.26, y: 0.29, width: 0.13, height: 0.21 } },
{ id: 'maya', x: 0.475, y: 0.47, head: { x: 0.48, y: 0.38 },
face: { x: 0.43, y: 0.35, width: 0.09, height: 0.16 } },
{ id: 'skipper', x: 0.08, y: 0.52 }],
avoid: [{ x: 0, y: 0.38, width: 0.18, height: 0.28 }],
alt: t({ en: 'Storm at night in the lamp room: the keeper speaks into the radio microphone '
+ 'while Maya, wrapped in a blanket, listens.',
es: 'Noche de tormenta en la sala de la linterna: el farero habla por el micrófono de la '
+ 'radio y Maya, envuelta en una manta, escucha.',
ca: 'Nit de tempesta a la sala de la llanterna: el faroner parla pel micròfon de la ràdio i '
+ 'la Maya, embolicada amb una manta, escolta.',
zh: '暴风雨之夜的灯室里,守塔人对着收音机的话筒说话,裹着毯子的玛雅在一旁听着。',
ar: 'ليلة عاصفة في غرفة الفانوس: الحارس يتكلم في ميكروفون المذياع، ومايا الملتفّة ببطانية '
+ 'تصغي.',
ja: '嵐の夜の灯室。灯台守が無線のマイクに話しかけ、毛布にくるまったマヤが耳をすます。',
pt: 'Noite de tempestade na sala da lanterna: o faroleiro fala ao microfone do rádio e '
+ 'Maya, enrolada num cobertor, escuta.',
fr: 'Nuit de tempête dans la chambre de la lanterne : le gardien parle dans le micro de '
+ 'la radio pendant que Maya, emmitouflée dans une couverture, écoute.',
de: 'Sturmnacht im Laternenraum: Der Wärter spricht ins Mikrofon des Funkgeräts, während '
+ 'Maya, in eine Decke gewickelt, zuhört.',
it: 'Notte di tempesta nella stanza della lanterna: il guardiano parla al microfono della '
+ 'radio e Maya, avvolta in una coperta, ascolta.' }) },
'bk-whisper': { width: 1152, height: 1152,
safeArea: { x: 0.36, y: 0.26, width: 0.44, height: 0.48 },
anchors: [{ id: 'maya', x: 0.53, y: 0.47, head: { x: 0.52, y: 0.33 },
face: { x: 0.41, y: 0.3, width: 0.19, height: 0.22 } },
{ id: 'biscuit', x: 0.625, y: 0.635, head: { x: 0.66, y: 0.57 },
face: { x: 0.55, y: 0.5, width: 0.25, height: 0.22 } }],
avoid: [],
alt: t({ en: 'Under the desk, Maya whispers behind her hand to the frightened orange cat.',
es: 'Bajo la mesa, Maya le susurra tapándose la boca al gato naranja asustado.',
ca: 'Sota la taula, la Maya xiuxiueja tapant-se la boca al gat taronja espantat.',
zh: '桌子底下,玛雅用手挡着嘴,对受惊的橘猫说悄悄话。',
ar: 'تحت المكتب تهمس مايا من وراء يدها للقط البرتقالي الخائف.',
ja: '机の下で、マヤが手で口をかくして、おびえたオレンジ色の猫にささやく。',
pt: 'Debaixo da mesa, Maya cobre a boca com a mão e sussurra para o gato laranja '
+ 'assustado.',
fr: 'Sous le bureau, Maya chuchote derrière sa main au chat roux effrayé.',
de: 'Unter dem Schreibtisch flüstert Maya hinter vorgehaltener Hand der verängstigten '
+ 'roten Katze zu.',
it: 'Sotto la scrivania, Maya sussurra dietro la mano al gatto rosso spaventato.' }) },
'bk-shout': { width: 880, height: 1100, safeArea: { x: 0.22, y: 0.26, width: 0.46, height: 0.42 },
anchors: [{ id: 'tomas', x: 0.48, y: 0.47, head: { x: 0.42, y: 0.33 },
face: { x: 0.25, y: 0.28, width: 0.37, height: 0.32 } }],
avoid: [{ x: 0.53, y: 0.43, width: 0.17, height: 0.27 }],
alt: t({ en: 'Close-up of the keeper shouting into the microphone, lit from below by the '
+ 'radio dials.',
es: 'Primer plano del farero gritando al micrófono, iluminado desde abajo por los diales de '
+ 'la radio.',
ca: 'Primer pla del faroner cridant al micròfon, il·luminat des de baix pels dials de la '
+ 'ràdio.',
zh: '守塔人对着话筒大喊的特写,收音机的刻度盘从下方照亮他的脸。',
ar: 'لقطة قريبة للحارس يصرخ في الميكروفون، وأضواء لوحة المذياع تنيره من أسفل.',
ja: 'マイクに向かって叫ぶ灯台守のアップ。無線機の目盛りの光が下から顔を照らす。',
pt: 'Close do faroleiro gritando ao microfone, iluminado de baixo pelos mostradores do '
+ 'rádio.',
fr: 'Gros plan sur le gardien qui crie dans le micro, éclairé par en dessous par les '
+ 'cadrans de la radio.',
de: 'Nahaufnahme des Wärters, der ins Mikrofon schreit, von unten von den Skalen des '
+ 'Funkgeräts beleuchtet.',
it: 'Primo piano del guardiano che grida nel microfono, illuminato dal basso dai '
+ 'quadranti della radio.' }) },
'bk-sea': { width: 1200, height: 800, safeArea: { x: 0.1, y: 0.19, width: 0.37, height: 0.57 },
anchors: [{ id: 'skipper', x: 0.28, y: 0.63 }, { id: 'sfx', x: 0.16, y: 0.36 }],
avoid: [{ x: 0.13, y: 0.52, width: 0.24, height: 0.23 },
{ x: 0.85, y: 0.19, width: 0.08, height: 0.26 }],
alt: t({ en: 'A small blue trawler heaves on storm waves at night; lightning on the left, the '
+ 'lighthouse beam on the right.',
es: 'Un pesquero azul cabecea entre las olas de la tormenta; un rayo a la izquierda, el haz '
+ 'del faro a la derecha.',
ca: 'Un pesquer blau capcineja entre les onades de la tempesta; un llamp a l’esquerra, el '
+ 'feix del far a la dreta.',
zh: '夜里,一艘蓝色小渔船在暴风雨的浪头上颠簸;左边是闪电,右边是灯塔的光束。',
ar: 'قارب صيد أزرق صغير يتقاذفه موج العاصفة ليلًا؛ برق على اليسار وشعاع المنارة على اليمين.',
ja: '夜の嵐の波にもまれる青い小さな漁船。左に稲妻、右に灯台の光。',
pt: 'Um pequeno barco pesqueiro azul jogado pelas ondas da tempestade à noite; um raio à '
+ 'esquerda, o facho do farol à direita.',
fr: 'Un petit chalutier bleu tangue la nuit sur les vagues de la tempête ; un éclair à '
+ 'gauche, le faisceau du phare à droite.',
de: 'Ein kleiner blauer Kutter schlingert nachts in den Wellen des Sturms; links ein '
+ 'Blitz, rechts der Strahl des Leuchtturms.',
it: 'Un piccolo peschereccio blu sballottato di notte dalle onde della tempesta; un lampo a '
+ 'sinistra, il fascio del faro a destra.' }) },
'bk-window': { width: 1000, height: 1000,
safeArea: { x: 0.36, y: 0.27, width: 0.28, height: 0.33 },
anchors: [{ id: 'maya', x: 0.49, y: 0.41, head: { x: 0.42, y: 0.3 },
face: { x: 0.41, y: 0.33, width: 0.1, height: 0.13 } }],
avoid: [{ x: 0.5, y: 0.33, width: 0.1, height: 0.17 },
{ x: 0.83, y: 0.45, width: 0.06, height: 0.08 }],
alt: t({ en: 'Maya presses her hands and nose to the rainy window, staring out at the storm.',
es: 'Maya pega las manos y la nariz al cristal mojado y mira la tormenta.',
ca: 'La Maya enganxa les mans i el nas al vidre mullat i mira la tempesta.',
zh: '玛雅把双手和鼻子贴在满是雨水的窗户上,望着外面的暴风雨。',
ar: 'تلصق مايا يديها وأنفها بالزجاج المبلل وتحدّق في العاصفة.',
ja: 'マヤが雨の窓に両手と鼻を押しつけ、嵐を見つめる。',
pt: 'Maya cola as mãos e o nariz no vidro molhado e olha a tempestade.',
fr: 'Maya colle les mains et le nez contre la vitre mouillée et regarde la tempête.',
de: 'Maya drückt Hände und Nase gegen das regennasse Fenster und starrt hinaus in den '
+ 'Sturm.',
it: 'Maya preme le mani e il naso contro il vetro bagnato e guarda la tempesta.' }) },
'bk-morning': { width: 1000, height: 667,
safeArea: { x: 0.33, y: 0.06, width: 0.42, height: 0.59 },
anchors: [{ id: 'tomas', x: 0.565, y: 0.25, head: { x: 0.56, y: 0.15 },
face: { x: 0.51, y: 0.13, width: 0.1, height: 0.17 } },
{ id: 'maya', x: 0.465, y: 0.29, head: { x: 0.45, y: 0.24 },
face: { x: 0.41, y: 0.19, width: 0.09, height: 0.14 } },
{ id: 'biscuit', x: 0.685, y: 0.58, head: { x: 0.69, y: 0.55 },
face: { x: 0.64, y: 0.51, width: 0.09, height: 0.11 } }],
avoid: [{ x: 0.66, y: 0.08, width: 0.08, height: 0.12 },
{ x: 0.34, y: 0.14, width: 0.06, height: 0.08 }],
alt: t({ en: 'Next morning on the sunny rocks, Maya, the keeper and the cat wave; the '
+ 'lighthouse stands behind them.',
es: 'A la mañana siguiente, en las rocas al sol, Maya, el farero y el gato saludan; detrás '
+ 'está el faro.',
ca: 'L’endemà al matí, a les roques al sol, la Maya, el faroner i el gat saluden; darrere '
+ 'hi ha el far.',
zh: '第二天早上,阳光照着礁石,玛雅、守塔人和猫在挥手;灯塔立在他们身后。',
ar: 'في الصباح التالي على الصخور المشمسة يلوّح مايا والحارس والقط، والمنارة خلفهم.',
ja: '翌朝、日の当たる岩の上でマヤと灯台守と猫が手を振る。後ろに灯台が立つ。',
pt: 'Na manhã seguinte, nas pedras ao sol, Maya, o faroleiro e o gato acenam; atrás deles '
+ 'está o farol.',
fr: 'Le lendemain matin, sur les rochers au soleil, Maya, le gardien et le chat font signe '
+ 'de la main ; le phare se dresse derrière eux.',
de: 'Am nächsten Morgen winken Maya, der Wärter und die Katze auf den sonnigen Felsen; '
+ 'hinter ihnen steht der Leuchtturm.',
it: 'La mattina dopo, sugli scogli al sole, Maya, il guardiano e il gatto salutano con la '
+ 'mano; alle loro spalle si alza il faro.' }) },
};
У каждого изображения есть якоря в долях изображения: рот, на который смотрит хвостик речи, голова, на которую смотрит мысль, лицо, которое не может закрыть ни одно облачко (говорящие и якоря). Шкипера нигде не рисуют: на картинке шторма его якорь — приёмник, на морской — его лодка. Если говорящего нет в кадре, tail=right (или left, top, bottom) ведёт хвостик к этому краю, а at="44% 22%" закрепляет центр облачка в точке изображения, и оно остаётся там при любой обрезке. Две реплики подряд от одного говорящего соединяются в один контур с одним хвостиком. left и right — стороны изображения, поэтому все десять версий пишут одну и ту же строку смотрителя в морском кадре, где его свет стоит справа на изображении: tail=right, при чтении слева направо и справа налево. start и end следуют направлению чтения страницы.
#3 · Дайте персонажу собственный голос
Действующие лица в коротком ответе дают каждой строке skipper: стиль рации, поэтому сценарий не повторяет {radio}. Строка может сказать иначе: в утреннем кадре шкипер кричит с лодки, skipper{speech tail=bottom}:, в обычном облачке, хвостик которого уходит за низ кадра.
#4 · Набирайте каждую версию своими шрифтами
// The engine's default lettering and sound-effect faces, but for Chinese two ZCOOL faces drawn
// for cartoons. content.<lang>.md holds the words under the same speaker ids.
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 только слова. Японские облачка набраны вертикально шрифтом Zen Antique, а звукоподражания Dela Gothic One; арабские — Playpen Sans Arabic, а гром Lalezar. Курсив и полужирное действуют там, где они есть у шрифта: внутренний голос в английском курсивный, в японском прямой (леттеринг).
Рецепт целиком
// ═══ Postext Cookbook · Nº 145 · Every kind of balloon on a lighthouse page ═════════
// https://postext.dev/en/cookbook/balloon-kinds
// 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.28.0
//
// One comic page that uses every kind of balloon the engine draws, with a letterer's style
// sheet in front of it. Each line of the script names its speaker and, when it is not plain
// speech, its kind; the shape, the tail and the type follow from the balloon style.
import {
buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage, loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: 'en' | 'es' | 'ca' | 'zh' | 'ar' | 'ja' | 'pt' | 'fr' | 'de' | 'it'
const RECIPE = 'balloon-kinds';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a storm at night, and the yellow of the captions
const palette = {
ink: '#18202b', // panel borders, lettering and text: a blue-black
accent: '#c2412d', // sound effects and the style sheet's labels
caption: '#f3e3a8', // narration boxes
inner: '#e4e8ee', // the inner voice: a cold grey-blue
muted: '#5c6672', // 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: six editions, each lettered in faces for its script
// The engine's default lettering and sound-effect faces, but for Chinese two ZCOOL faces drawn
// for cartoons. content.<lang>.md holds the words under the same speaker ids.
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: one balloon style per kind, and a cast that gives the skipper his radio
// A script line is `speaker{kind}: text`. The kinds are balloon styles: the engine ships
// speech, thought, whisper, shout, radio, caption, inner, note and sfx, and a style of the
// same id here changes only what it names. `caption`, `note` and `sfx` are reserved speakers.
Собранный script.js работает как есть: вставьте его в модульный скрипт любой страницы или откройте рецепт на CodePen. Папка рецепта на GitHub ↗ (открывается в новой вкладке)
Варианты
#Волнистое облачко для больного или слабого голоса
Любой другой идентификатор становится собственным стилем, наложенным на облачко речи.
const balloonStyles = [
+ { id: 'weak', shape: 'wavy', stroke: col('ink'), fontScale: 0.9 }, // maya{weak}: …
{ id: 'speech', stroke: col('ink') },#Соедините две реплики перемычкой
- lettering: { fontFamily: LETTERING, fontSize: pt(7.5), color: col('ink'), inset: mm(1) },
+ lettering: { fontFamily: LETTERING, fontSize: pt(7.5), color: col('ink'), inset: mm(1),
+ joinSameSpeaker: 'connector' },Частые ошибки
- Закреплённая точка — это точка изображения, она сохраняется при любой обрезке. Звукоподражание, закреплённое так близко к краю, что вышло бы из кадра (KRA-KOOM при
at="16% 28%"), сдвигается обратно внутрь и может стоять чуть в стороне от записанной точки. - Голос за кадром стоит у той границы, на которую смотрит его хвостик: благодарность шкипера,
tail=bottom, стоит внизу утреннего кадра, хотя в кадре она первая. Направьте хвостик на верхнюю границу, если такая реплика должна читаться первой.
Источники и лицензии
- Рецепт
- Ignacio Ferro
- Текст
- Оригинальный текст, CC BY 4.0
- Изображения
- Panel picture: the storm in the lamp room · Generated With Diffusion Models · оригинал
- Panel picture: Maya and the cat under the desk · Generated With Diffusion Models · оригинал
- Panel picture: the keeper shouting into the microphone · Generated With Diffusion Models · оригинал
- Panel picture: the trawler in the storm · Generated With Diffusion Models · оригинал
- Panel picture: Maya at the window · Generated With Diffusion Models · оригинал
- Panel picture: the next morning on the rocks · 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)
Изменить описание рецепта ↗ (открывается в новой вкладке)Папка рецепта на GitHub ↗ (открывается в новой вкладке)


