import type { VDTLineSegment } from '../vdt.js'; /** One styled run of a word set as one shaped run (`VDTLineSegment.runs`). */ export type WordRun = NonNullable[number]; /** * Paint the text of a segment set word by word with `paint` (the caller's * `fillText`), as the canvas paints any segment. A right-to-left segment * (`rtl`, bidi level odd) is painted as a right-to-left run: the context's * `direction` is `rtl` for it, so the browser shapes it right to left and * mirrors its brackets, and its `textAlign` is `left`, so the run's left * edge is at `x` (the page paints with `ltr`, which every other run * keeps). And two rules for words of a joining script (Arabic…): * - no letter-spacing: the line's or the block's `tracking` (the context's * `letterSpacing` on entry) is lifted while the word is painted, since * spacing its letters apart breaks the joins (the measurer left such a * word untracked, `measure/joining.ts`); * - a word set in several styles (`runs`, `كتا**ب**`) is painted whole in * the segment's style, then once more in each other run's style, clipped * to that run's stretch of the word ({@link paintWordRuns}). * * A word of a tracked line that the browser would shape without its * ligatures under letter-spacing is painted with them, as it was measured * (`fillTrackedWord`, #663): in pieces, which a mirrored page turns back * as one run (#685). A right-to-left word of a script that does not join * (Hebrew) too, its pieces from the right end of its box (#703). A word of * a joining script and a word set in several styles are never painted in * pieces. * * A word with no letter that the layout gave a script * (`VDTLineSegment.scriptContext`, #725) is painted in it, beside a mark * of the script that is clipped away (`fillScriptWord`), whole: where it * could also be painted in pieces (a face that ligates `!=`), the script * takes it. In the Arabic script it is painted with no letter-spacing, as * it was measured (`scriptContextUntracked`). */ export declare function fillSegmentWord(ctx: CanvasRenderingContext2D, seg: VDTLineSegment, x: number, y: number, tracking: number, paint: (text: string, x: number, y: number) => void, runStyle: (run: WordRun) => { font: string; fill: string; }): void; /** * Run `paint`, which paints the text of `seg`, with the context in the * segment's language when it names one (`:ltr[…]{lang=en}`): a word of * such a run is painted in it, as it was measured (#764), and the context * gets the document's back. The language holds through the saves inside * (a word's clip, a mirrored page's turn: `saveContext`). Any other * segment, and every segment of a document shaped in the host's language, * is painted as the context is. */ export declare function inSegmentLanguage(ctx: CanvasRenderingContext2D, seg: VDTLineSegment, paint: () => void): void; /** Paint the segments that name a language in it from now on (`on`), or * in the page's as up to postext 1.28: the page painter says which for * the document it paints (`bodyText.shapingLanguage`). The same * documents have the ligatures of their tracked words take the tracking * of each letter (`setLetterTracking`, #770). */ export declare function setSegmentLanguages(on: boolean): void; /** Whether a segment that names its language is painted on its own. */ export declare function paintsSegmentLanguage(seg: VDTLineSegment): boolean; /** * The runs of a word set in several styles, each painted over the whole * word (already painted in the segment's style, the context's font) in its * own font and colour, clipped to the stretch of the word its letters * occupy. * * The canvas has no way to ask where a cluster of a shaped word lies, so * the stretch is estimated from widths of the word's two ends: the letters * before a run (in reading order) occupy about the width of the whole word * less the width of the word from the run on, and the letters after it * likewise. Measured in pieces an Arabic word's letters at the cut take * other forms, so the bounds can be off by part of a letter; the clip * then cuts a letter in two colours. A run of vowel signs alone (a * coloured fatha) advances nothing: it is widened to its letter, which * takes the run's colour with it. A run in another weight is painted * scaled to the word's width, so its letters stay over the others. On a * mirrored page (`mirrorFrame.ts`) each run is turned back about the * word's box as it is painted, so the letters of a stretch land at the * other end of the box: the clip is turned with them. The * PDF shapes the word with HarfBuzz and colours exact clusters. */ export declare function paintWordRuns(ctx: CanvasRenderingContext2D, seg: VDTLineSegment, x: number, y: number, paint: (text: string, x: number, y: number) => void, runStyle: (run: WordRun) => { font: string; fill: string; }): void; //# sourceMappingURL=wordRuns.d.ts.map