/** * The character grid (`cjk.grid`, 字格 / 版心; clreq §7.1.1): a Chinese type * area is authored as the body size × characters per line × lines per page, * plus the line gap and, with two columns, the gutter — not as margins. * * A pre-pass (`applyCjkGrid`, run by `resolveAllConfig` before anything is * resolved) rewrites the config so that every consumer reads ordinary * values: each column is `charsPerLine` ems of the body size wide, the * gutter of a two-column page a whole number of ems (the one written, * rounded, at least one), the type area `linesPerPage` lines of the body's * line height tall; and the page margins are set so the type area sits in * the middle of the area the configured margins leave, which act as * minimums (a mirrored book keeps its inner and outer margins apart, each * grown by the same amount). A grid larger than that area is reduced to * what fits and reported (`cjkGridClamped`); unset numbers take what fits. * * The computation runs on logical axes: along the line (the inline axis: * the page's width in horizontal text, its height in vertical text, * `layout.writingMode: 'vertical-rl'`) and across lines (the block axis). * In a `oneAndHalf` layout `charsPerLine` is the main column's; the side * column takes the whole number of ems nearest the width its * `sideColumnPercent` gives it inside the configured margins (at least * one), and `sideColumnPercent` is rewritten so both columns come out in * whole ems. */ import type { PostextConfig, Dimension } from '../types.js'; /** The grid of a config as the pre-pass sets it (px at the page's dpi). */ export interface CjkGridGeometry { /** Characters per line and lines per column in use. */ charsPerLine: number; linesPerPage: number; /** The numbers as written, when the grid had to reduce them. */ clamped: { charsPerLine?: number; linesPerPage?: number; }; columns: number; /** Characters per line of a `oneAndHalf` layout's side column; 0 for * the other layouts. */ sideChars: number; /** The body size (one character) and the line pitch, px. */ em: number; pitch: number; /** The gutter between two columns, in ems. */ gutterEm: number; /** The type area, px: along the line and across lines. */ inline: number; block: number; /** The margins the grid sets, px (`left`/`right` are inner/outer when * the margins are mirrored). */ margins: { top: number; bottom: number; left: number; right: number; }; /** The text runs down the page. */ vertical: boolean; dpi: number; } /** * The grid a config asks for, or undefined when `cjk.grid.enabled` is not * set. Pure: reads the config, resolves what it needs. */ export declare function cjkGridGeometry(config: PostextConfig | undefined): CjkGridGeometry | undefined; /** * The config with the character grid applied (see the module comment): * `page.margins`, `layout.gutterWidth` (two or more columns) and the grid's numbers * in use, written in px. The same object when the grid is off. */ export declare function applyCjkGrid(config: PostextConfig | undefined): PostextConfig | undefined; /** The colour of the character-grid overlay: a light grey on any paper. */ export declare const CHARACTER_GRID_COLOR = "rgba(128, 128, 128, 0.45)"; /** The cells of the character grid on a page, for the overlay * (`cjk.grid.show`): each column's left edge and characters, the cell size * (one em of the body size) and the top of each row's cells. A row's cell * is the character's em box on the line: from 0.88 em above the line's * baseline (set 0.8 of the line pitch down) to 0.12 em below it; on a * vertical page, half an em either side of the middle of the line's * pitch, where the body's characters stand (`lineBaselineOffset`). Undefined * when the grid is off or hidden. The geometry is the page's content area, * in the frame its blocks are laid out in (the flow frame of a vertical * page, where a column is a tier and a row a line down the page). */ export interface CjkGridCells { cell: number; /** Characters per line (of the main column in a oneAndHalf layout). */ chars: number; columns: number[]; /** The characters of each column in `columns`. */ columnChars: number[]; rows: number[]; } /** * `pageColumns`, the page's columns (`VDTPage.columns`), place the cells: * one set per column edge (a column under a page-wide band shares the edge * of the one above it), as many characters as the column holds whole ems — * so a oneAndHalf page gets its side column on the side the page's parity * puts it. Without them the columns are cut from the content area. */ export declare function cjkGridCells(resolved: { cjk?: { grid?: { show?: boolean; charsPerLine?: number; linesPerPage?: number; }; }; bodyText: { fontSize: Dimension; fontFamily?: string; }; layout: { layoutType: string; columnCount?: number; gutterWidth: Dimension; }; page: { dpi: number; }; }, contentArea: { x: number; y: number; }, pitch: number, pageColumns?: readonly { bbox: { x: number; width: number; }; kind?: string; }[], /** The page's flow frame (`VDTPage.flow`): the cells stand on the * central axis on a vertical page. */ pageFlow?: { writingMode: string; }): CjkGridCells | undefined; //# sourceMappingURL=cjkGrid.d.ts.map