/** * Right-to-left lines (UAX #9 on the measurer's output, #369). * * The line breakers work on the logical text and know nothing of * direction: a line is a run of the paragraph, and its `segments` stay in * logical order (copied text, links, source maps, the hyphen at the end of * a line and every other engine rule read them as written). Once a * paragraph is broken, {@link applyLineDirections} resolves its embedding * levels once (`resolveParagraph`, with the inline `:rtl[…]` / `:ltr[…]` * isolates) and, line by line, applies rule L1 to the line's characters, * cuts each text segment where its level changes, marks the right-to-left * ones (`VDTLineSegment.rtl`, and `level` past 1) and works out the order * the renderers advance through the segments in (`VDTLine.order`, rule L2 * on the segments' levels): the visual order, left to right, whatever the * frame; the build turns it around on a mirrored page (#370). * * A cut at a level change never falls inside a word of a joining script: * Arabic letters next to each other have one level, and a cut between a * letter and a digit or a Latin letter leaves both sides measured as they * are painted. The pieces of a segment share its width in proportion to * their own widths, so a line keeps the width it was broken with and no * break changes. * * Only a paragraph that needs it pays for it: one set right to left, or * one holding a right-to-left letter or control (`needsBidi`). Every other * line is left exactly as it was, with none of these fields. */ import type { VDTLine, VDTLineSegment } from '../vdt.js'; import { type BidiParagraph } from '../bidi.js'; import { type LineInsetStep, type LineWidthStep } from './types.js'; /** Set the base direction a paragraph is measured with when nothing sets * its own (`MeasureBlockOptions.direction`): the document's * (`resolvedDirection`). The build does, and puts back what it found when * it is done; left to right outside a build. */ export declare function setMeasureDirection(direction: 'ltr' | 'rtl'): void; /** See {@link setMeasureDirection}. */ export declare function getMeasureDirection(): 'ltr' | 'rtl'; /** Whether paragraphs are measured as those of a right-to-left document * written in the Arabic script (`arabicNumbersOf`), where European digits * that open a right-to-left run read as Arabic numbers * (`BidiOptions.arabicNumbers`, #665). The build sets it with the * direction and puts back what it found; off outside a build. */ export declare function setMeasureArabicNumbers(on: boolean): void; /** See {@link setMeasureArabicNumbers}. */ export declare function getMeasureArabicNumbers(): boolean; /** * Resolve the directions of a paragraph's lines (see the module comment): * `par` is the paragraph's levels (`resolveParagraph` on the text the lines * were cut from, the spans' texts joined, with its base direction and its * inline `:rtl[…]` / `:ltr[…]` isolates); `widthOf` measures a piece of a * segment in that segment's font, to share its width. The lines are * changed in place. */ export declare function applyLineDirections(lines: VDTLine[], par: BidiParagraph, widthOf: (seg: VDTLineSegment, piece: string) => number): void; /** * The lines of a paragraph whose direction opposes its frame's: an Arabic * quotation in an English book, or an English one in an Arabic book (whose * pages are mirrored, #370, so that the flow's right is the sheet's left). * Its start side is the frame's right. The breaker set each line's indent * on the left (`bbox.x`); the line now fills the span from the block's left * edge to its right edge less that indent (`VDTLine.measure`), so a * first-line or hanging indent falls on the right, and its line box starts * at the span's left edge. Renderers align the line in that span from its * start side: a ragged line, or the last line of a justified paragraph, * ends flush right (see `VDTLine.measure`). `maxWidthPx` and `restWidths` * are the measures the lines were broken at, from the block's left edge; * `insets`, the lines set short beside a wrapped picture (#627). */ export declare function mirrorLineSpans(lines: VDTLine[], maxWidthPx: number, restWidths?: readonly LineWidthStep[], insets?: readonly LineInsetStep[]): void; /** Move a line along x by `dx`, its {@link VDTLine.measure} with it. The * measure is replaced, never changed in place: a cached measurement may * share it. */ export declare function shiftLineX(line: VDTLine, dx: number): void; /** A stretch of a paragraph's text in a language the author named on an * inline isolate (`:ltr[…]{lang=en}`): `[start, end)` in the joined text. */ export interface LanguageRange { start: number; end: number; lang: string; } /** * The stretches of a paragraph's spans in a language their isolate names * (`InlineSpan.direction.lang`, the innermost isolate that names one), as * ranges of the joined text; empty when none does. */ export declare function spanLanguages(spans: readonly { text: string; direction?: { lang?: string; outer?: unknown; }; }[]): LanguageRange[]; /** * Stamps `VDTLineSegment.lang` on the segments of a paragraph's lines whose * text lies in one of `ranges` (#379, see {@link spanLanguages}): a segment * takes the language of its first character read from the paragraph text * (`text`). Segments of a cut line are replaced, never changed in place. */ export declare function applySegmentLanguages(lines: VDTLine[], text: string, ranges: readonly LanguageRange[]): void; //# sourceMappingURL=bidiLines.d.ts.map