/** * Tab stops in body text (#622). * * A tab (`:tab`, or a tab character in a paragraph whose style sets stops) * is a `space` token of the rich line breaker whose width depends on where * its line has got to, so it is resolved while the line is filled * ({@link placeTab}), never once per paragraph. A paragraph that holds a * tab is set line by line (Knuth–Plass sums its items' widths per candidate * line, which a width that depends on the line's start would break), as * word processors and InDesign set tabbed text. * * - A tab goes to the first stop past the text before it, among the stops * after the one the line's previous tab took. `'start'`: the text after * the tab starts at the stop; `'end'`: the text up to the next tab (or the * paragraph's end) ends there; `'center'`: it is centred on it; * `'decimal'`: its first decimal separator stands on it (a run with none * ends there). * - Past the last stop, `tabInterval` sets default stops every interval * from the start of the measure; without one, a tab past the last stop is * a word space. * - Overrun: when the text before a tab has passed every remaining stop of * its line, an `'end'`, `'center'` or `'decimal'` stop takes the last word * before the tab to the next line with it (the text before the stop sets * narrower, as a contents row narrows its title for its page number), and * a `'start'` stop breaks the line before the tab, so the text after it * starts the next line at its stop. A tab that opens its line and still * finds no stop for the text after it takes no room. * - A leader fills the room before the text at the stop, flush with its * end (see `measure/leader.ts`), `gapPx` clear of the text on each side. */ import type { TabStopAlign } from '../types.js'; /** A tab stop with its lengths in px (see `TabStop`). `at` is px from the * start edge of the measure, `'end'` that line's end edge, or a share of * the measure. */ export interface TabStopPx { at: number | 'end' | { percent: number; }; align: TabStopAlign; /** The leader's text, or `'rule'`; absent: none. */ leader?: string; /** Room between the text and the leader, and the leader and the stop's * text (px). */ gapPx: number; decimalChar: string; } /** The tab stops of a paragraph (`MeasureBlockOptions.tabs`). */ export interface TabSettings { stops: readonly TabStopPx[]; /** Default stops every this many px past the last of {@link stops}. */ intervalPx?: number; } /** The text a tab sends to its stop: from after the tab to the next tab or * the paragraph's end, its width and the width before its first decimal * separator (`undefined` when it holds none). */ export interface TabRun { width: number; decimalWidth: (char: string) => number | undefined; } /** The line a tab is placed on: where its text starts (the line's indent) * and ends (its measure), from the start edge of the measure; the * paragraph's measure (for `%` stops); and the stop the line's previous * tab took (`-Infinity` for none). */ export interface TabLine { start: number; end: number; measure: number; usedPos: number; } /** A leader set before a stop: its text (empty for a rule) and width, and * where it ends from the tab's start. */ export interface TabLeaderPlacement { text: string; width: number; rule?: true; end: number; } export type TabPlacement = { kind: 'stop'; width: number; pos: number; align: TabStopAlign; leader?: TabLeaderPlacement; } | { kind: 'space'; } | { kind: 'overrun'; align: TabStopAlign; }; /** Where a stop stands on a line. */ export declare function tabStopPos(stop: TabStopPx, line: Pick): number; /** * Place a tab whose line has got to `x` (see the module comment): the * tab's width and leader, a word space, or an overrun the breaker resolves. * `oneOff`: the stop of `:tab{at=…}`, the only one such a tab goes to. * `leaderWidth` measures a run of leader text as it is painted. */ export declare function placeTab(x: number, run: TabRun, line: TabLine, settings: TabSettings | undefined, oneOff: TabStopPx | undefined, leaderWidth: (text: string) => number): TabPlacement; /** The decimal separator of numbers in `locale` (Western digits): `.` in * English, Chinese, Japanese and Arabic text, `,` in Spanish, Catalan, * Portuguese, French, German… */ export declare function defaultDecimalChar(locale: string | undefined): string; //# sourceMappingURL=tabs.d.ts.map