/** * Lay out a comic page (`:::page`, #555–#557): its frame, the cells of its * split, each panel's border, background and cropped picture, and the split * lines the Sandbox drags. The lettering (balloons) is set by * {@link letterPanels}. * * Everything is on the sheet (page px), whatever the document's writing * mode or direction; the reading direction of the panels comes from * `comics.readingDirection` (or the page's `direction`). */ import type { ColorPaletteEntry, ComicCastMember, Dimension, Resource, ResolvedBalloonStyleConfig, ResolvedComicsConfig } from '../types.js'; import type { BoundingBox, ContentWarning, ResolvedConfig, VDTComicBalloon, VDTComicPage, VDTComicPanel, VDTPage } from '../vdt.js'; import type { LetteringStyle } from './lettering/types.js'; import type { ComicPageSource, ComicPanelSource, ComicScriptItem } from './types.js'; /** What the build hands the comic page layout. */ export interface ComicPageContext { resolved: ResolvedConfig; /** The page the comic owns (its content area is the default frame). */ page: VDTPage; /** The trim and bleed boxes of the sheet (physical). */ trimBox: BoundingBox; bleedBox: BoundingBox; resources: ReadonlyMap; /** Added to every source offset of `source` (the frontmatter's length: * VDT offsets are in the whole Markdown). */ sourceOffset?: number; /** The comic fence's ordinal among the comic fences of its chapter * (#885): the stable ids of the comic, its frames and balloons. */ fenceIndex?: number; /** Whether this page swaps mirrored margins (a verso of a left-bound * book), for `comics.frame.margins` with `mirror`. */ mirrorMargins?: boolean; /** The content area on the sheet, when it is not the page's (a leaf of * its own, `comics.viewerLeaf`). */ contentBox?: BoundingBox; } /** The leaf a comic page is laid out on when the page is not one * (`comics.viewerLeaf`): its box on the page — the print leaf scaled to * `fitWidth` px wide (no taller than `fitHeight`), at the top of the * trim, centred across it —, its content area, and the dpi that scale * resolves every length of the comic page at. Undefined without one. */ export declare function comicViewerLeaf(comics: ResolvedComicsConfig, resolved: ResolvedConfig, trim: BoundingBox): { box: BoundingBox; content: BoundingBox; dpi: number; } | undefined; /** A Dimension written in an attribute (`4mm`, `0.5cm`, `6pt`, `12px`, a * bare number in mm), or undefined. */ export declare function parseComicDimension(value: string | undefined): Dimension | undefined; /** The reading direction of a page: its `direction` attribute, else the * document's ({@link comicReadingDirection}): `'auto'` is `'rtl'` in a * right-to-left document (an Arabic edition mirrors its pages), in a * vertical one and in a Japanese or Traditional Chinese one (a localized * edition of a Western comic reads in its language's direction), and the * direction the art was drawn for otherwise (`comics.artDirection`: a * manga stays right to left in any language). Every comic of the * document — pages, spreads, strips, their lettering order and the * guided views — reads in the direction this returns. */ export declare function comicPageDirection(source: Pick, comics: ResolvedComicsConfig, resolved: ResolvedConfig): 'ltr' | 'rtl'; /** A panel's `pad` (CSS-like, one to four values: top, end, bottom, * start; each a Dimension or a percentage of the cell, `pad="0 12%"`) as * px insets of a cell `cell` wide and high on a page read in * `direction`. Undefined when unset or unreadable. */ export declare function comicPanelPadding(value: string | undefined, cell: Pick, direction: 'ltr' | 'rtl', dpi: number): { top: number; right: number; bottom: number; left: number; } | undefined; /** The frame of a page: the content area on the sheet, or the trim inset * by `comics.frame.margins`. */ export declare function comicPageFrame(ctx: Pick, comics?: ResolvedComicsConfig): BoundingBox; /** The warnings the layout of a comic page found (`comicPanelLetterbox`, * `comicBalloonOverflow`). */ export declare function comicPageLayoutWarnings(comic: VDTComicPage): readonly ContentWarning[]; /** The source of each panel of a comic laid out by {@link layoutComicFrame} * (undefined for an empty cell), in panel order. Internal to the comics * modules. */ export declare function comicPanelSources(comic: VDTComicPage): readonly (ComicPanelSource | undefined)[]; /** The panel sources of a comic laid out whole, given to a part of it (a * half of a spread) or a copy moved elsewhere (a strip on the sheet): the * sources stay indexed by the panels' `index`. Internal to the comics * modules. */ export declare function copyComicPanelSources(from: VDTComicPage, to: VDTComicPage): void; /** Set the layout warnings of a comic laid out in parts (each page of a * spread gets those of its panels). Internal to the comics modules. */ export declare function setComicLayoutWarnings(comic: VDTComicPage, warnings: readonly ContentWarning[]): void; /** The document language the lettering is set in (as * {@link resolvedComics} reads it). */ export declare function comicLetteringLocale(resolved: ResolvedConfig): string; /** Whether balloons are set vertically: `lettering.writingMode`, `auto` * meaning vertical for Japanese and Traditional Chinese (the comics of * both are lettered in columns) and in a vertical document. */ export declare function comicLetteringVertical(comics: ResolvedComicsConfig, resolved: ResolvedConfig, locale: string): boolean; /** * A balloon style of the config resolved to the lettering's px style * (SPEC D4 → D3): the style over the book's lettering, the speaker's cast * entry and the line's own `color` / `font` over both. One lettering size * per book: `fontScale` is the only factor (a sound effect's `size=` scales * the item, not the style). */ export declare function comicLetteringStyle(input: { style: ResolvedBalloonStyleConfig; comics: ResolvedComicsConfig; cast?: ComicCastMember; item?: Pick; locale: string; vertical: boolean; dpi: number; palette?: readonly ColorPaletteEntry[]; }): LetteringStyle; /** What {@link letterPanels} needs. */ export interface LetterPanelsInput { source: ComicPageSource; panels: readonly VDTComicPanel[]; /** The script of each laid-out panel (undefined for an empty cell). */ panelSources: readonly (ComicPanelSource | undefined)[]; comics: ResolvedComicsConfig; resolved: ResolvedConfig; resources: ReadonlyMap; direction: 'ltr' | 'rtl'; sourceOffset: number; pageIndex?: number; /** Regions of the frame no lettering may cover (the spine of a spread): * kept out at every fallback, pins included. */ avoid?: readonly BoundingBox[]; /** The comic's frame (the page's live area): lettering keeps inside it * unless it breaks a border on purpose. */ frame?: BoundingBox; /** The trim of the sheet (default: the frame) and the bleed box: no * lettering runs off the trim; a sound effect breaking its border may * run into the bleed beside a panel that bleeds. */ trim?: BoundingBox; bleedBox?: BoundingBox; } /** * The lettering of a page's panels (#559–#561): balloons, captions and * sound effects, in reading order (panel order, then script order), and the * `comicBalloonOverflow` warnings of the balloons that could not be placed * cleanly. */ export declare function letterPanels(input: LetterPanelsInput): { balloons: VDTComicBalloon[]; warnings: ContentWarning[]; }; /** What {@link layoutComicFrame} needs: the box the panels are cut from * and the box bleeding panels run out to, in the coordinates the comic is * laid out in (a page's sheet, a strip's own box, a spread's two sheets * side by side). */ export interface ComicFrameContext { resolved: ResolvedConfig; frame: BoundingBox; bleedBox: BoundingBox; resources: ReadonlyMap; /** Added to every source offset of `source` (see * {@link ComicPageContext.sourceOffset}). */ sourceOffset?: number; /** See {@link ComicPageContext.fenceIndex}. */ fenceIndex?: number; /** The page the warnings are reported on. */ pageIndex: number; /** Regions no balloon should cover, besides those of the pictures (the * spine of a spread), in the frame's coordinates. */ avoid?: readonly BoundingBox[]; /** The trim of the sheet(s), in the frame's coordinates: no lettering * runs off it. Default: the frame. */ trimBox?: BoundingBox; } /** Lay out a comic page. */ export declare function layoutComicPage(source: ComicPageSource, given: ComicPageContext): VDTComicPage; /** Lay out a comic (a page, a strip, a spread) in a given frame: its * cells, panels, split lines and lettering, in the frame's coordinates. */ export declare function layoutComicFrame(source: ComicPageSource, ctx: ComicFrameContext): VDTComicPage; //# sourceMappingURL=layoutPage.d.ts.map