/** * Adapter between the bold/italic/math-aware "rich token" stream produced * by the measure pipeline and the Knuth-Plass item stream, plus * reconstruction of VDT lines from the optimal breakpoint sequence. */ import type { VDTAnnotationRun, VDTChip, VDTLine, VDTSegmentMarks, VDTSwatch } from '../vdt.js'; import type { TextAlign } from '../types.js'; import type { KPItem } from './types.js'; interface RichBreakPoint { charIndex: number; widthBefore: number; /** A hard hyphen the word carries: the line ends as it is, no hyphen added. */ bare?: boolean; /** No hyphenation point (between ideographs): nothing added, no penalty. */ free?: boolean; /** For the greedy breaker only (after a dash): not a break here. */ greedyOnly?: boolean; /** A soft hyphen typed in the text: never held back by a hyphenation * zone. */ author?: boolean; /** A free break next to a CJK character: the line is not hyphenated. */ cjk?: boolean; /** Inside a Catalan `l·l`: the hyphen replaces the middle dot, this wide. */ replacesWidth?: number; /** What the rest of the word, opening the next line as a text of its * own, is wider than the pieces after this break (#770, see * `measure/rich.ts`). */ restShift?: number; } interface RichToken { text: string; bold: boolean; italic: boolean; /** A space inside inline code: no stretch, no shrink (see * `measure/rich.ts`). */ fixedGlue?: true; script?: 'sup' | 'sub'; scriptFont?: string; baselineShift?: number; /** An inline footnote marker's own font (see `measure/rich.ts`). */ markerFont?: string; /** A footnote marker in the line gap, and the shift of one flush right of * a vertical line (see `measure/rich.ts`). */ sideRuns?: VDTAnnotationRun[]; markerShift?: number; /** The unslanted face of Arabic words in a slanted style (see * `measure/rich.ts`). */ faceFont?: string; /** One of a subscript and a superscript set over each other (see * `stackedScriptPairs` in `measure/rich.ts`): the `first` has width 0, * the `second` the pair's advance. */ stacked?: 'first' | 'second'; /** Small capitals: flagged on the segment, which the measurer splits into * capital runs once the lines are built (see `measure/rich.ts`). */ smallCaps?: boolean; kind: 'text' | 'space'; width: number; breakPoints?: RichBreakPoint[]; hyphenWidth?: number; mathRender?: import('../math/types.js').MathRender; refResourceId?: string; refAnchor?: true; refPageIndex?: number; /** A later piece of a reference label that breaks at its spaces (#702, * see `measure/rich.ts`). */ refContinues?: true; footnoteId?: string; /** A bibliography label's space (#290, see `measure/rich.ts`). */ labelTab?: 'lead' | 'gap'; /** An inline colour swatch (atomic square; see `measure/rich.ts`). */ swatch?: VDTSwatch; /** An inline chip (atomic box; see `measure/rich.ts`). */ chip?: VDTChip; /** Chinese marks on the token's text (#193). */ cjkMarks?: VDTSegmentMarks; /** Characters the layout added (a book title's 《》). */ inserted?: boolean; /** Bare break points (URL joints): no hyphen is appended at the break. */ bareBreaks?: boolean; /** Ends on a closed dash the next, touching token follows: a free break * after it (see `markDashJoins` in `measure/rich.ts`). */ dashJoin?: boolean; /** Vertical text: a `:tcy[…]` cell, a `:upright[…]` or `:sideways[…]` * run (see `measure/rich.ts`). */ tcy?: true; orientation?: 'upright' | 'sideways'; /** Styled runs of one word of a joining script (see `measure/rich.ts`). */ runs?: { text: string; bold?: boolean; italic?: boolean; }[]; /** How far kashidas may widen this word, px (`measure/kashida.ts`). */ kashida?: number; /** The script a word with no letter is shaped in (#725, see * `measure/rich.ts`). */ scriptContext?: import('../measure/script.js').ScriptContext; /** A word with a letter that may be set in pieces with none: the script * in force where it starts (see `measure/rich.ts`). */ wordScript?: import('../measure/script.js').ScriptContext; } export declare function richTokensToItems(tokens: RichToken[], normalSpaceWidth: number, maxStretchRatio: number, minShrinkRatio: number, /** A break after a compound's hyphen opens the next line with a hyphen * too (`MeasureBlockOptions.repeatHyphen`): its penalty carries that * hyphen as post-break width. */ repeatHyphen?: boolean): KPItem[]; export declare function reconstructRichLines(items: KPItem[], breaks: number[], tokens: RichToken[], lineHeightPx: number, lineWidthFn: (lineIndex: number) => number, lineIndentFn: (lineIndex: number) => number, normalSpaceWidth: number, textAlign: TextAlign, /** `KPOptions.trackingPerChar` the breaks were found with: each line * takes the tracking the breaker counted on (`VDTLine.letterSpacing`). */ trackingPerChar?: number, /** How far below its top each line has its baseline * (`lineBaselineOffset`); 0.8 of the line height by default. */ baselineOffsetPx?: number, /** A document shaped in its own language (#770): the widths of the * pieces a line opens with when it starts inside a word, measured as * the text painted. The rest of token `tokenIndex` from its character * `from`, `lead` (the repeated hyphen of a compound, or nothing) * before it, cut at `cuts` (offsets into the token, ascending): each * piece as that text grew by it. Asked only after a break whose penalty * carries `postShift`, so the pieces add up to what the breaker counted. */ restPieces?: (tokenIndex: number, from: number, cuts: readonly number[], lead: string) => number[]): VDTLine[]; export {}; //# sourceMappingURL=richAdapter.d.ts.map