/** * Where a kashida may go in an Arabic word, and how good a place it is: a * port of raqim-kashida (Khaled Hosny, aliftype, MIT licence, * https://github.com/aliftype/raqim-kashida, at e217f98c), its pattern * language and its built-in sets. * * A pattern set scores the connections of a word's joined runs (letters * that connect to each other: `المبتعث` is the run ا and the run لمبتعث). A * pattern is a row of tokens (a letter, a joining group `@Beh` that folds * the letters sharing its skeleton in a given position, a set `{…}`, `*` * any joining letter, `.` the run's edge) with a priority digit 0–9, or * `!` (forbidden), in the gaps between them; `9\6` drops by one per letter * the run is longer than the guard's floor (`[4:]`) or, with `[:4:]`, away * from it either way. The last rule that speaks at a connection wins. A * point is only ever a real connection: never after a right-joining letter * (ا د ذ ر ز و ة), never at a run's edge, never across a ZWNJ. * * The sets: * - `naskh` — Benatia, Elyaakoubi & Lazrek's matrix (TUGboat 27(2), 2006) * overridden by Fawzi Salim Afifi's calligraphy manual: nothing after kāf * or lām (so never inside lām-alif), nothing before ṣād, ʿayn, wāw, ḥāʾ * or a final fāʾ/qāf/yāʾ, 4-letter runs best, a final pronoun hāʾ best * stretched just before it. For Amiri, Noto Naskh, Scheherazade… * - `simple` — the Microsoft priorities (IE 5.5's `text-kashida`): after * an initial or medial sīn/ṣād, before a final hāʾ/dāl, alif/ṭāʾ/lām/ * kāf, wāw/ʿayn/qāf/fāʾ, before any other final letter; never inside * lām-alif. * - `nastaliq` — naskh tailored after Afifi's Persian volume. * * Indices: the points are given as UTF-16 offsets in the word where a * tatweel (U+0640) goes: after the whole cluster of the letter before the * connection (its harakat included) and after a tatweel that seats a mark. * A tatweel the author typed is a letter of its run like any other. */ /** A place a kashida may go. */ export interface KashidaPoint { /** UTF-16 offset in the word where the tatweel is inserted. */ offset: number; /** Index of the grapheme cluster the tatweel goes after (raqim's index). */ index: number; /** 0–9, higher is better. */ priority: number; } /** The built-in pattern sets. */ export type KashidaPatternSetName = 'naskh' | 'simple' | 'nastaliq'; type Token = { kind: 'group'; group: string; } | { kind: 'exact'; group: string; } | { kind: 'set'; members: Token[]; } | { kind: 'notSet'; members: Token[]; } | { kind: 'literal'; cp: number; } | { kind: 'any'; }; type Weight = { base: number; min: number; } | 'suppress'; type Guard = { kind: 'exact'; n: number; } | { kind: 'min'; n: number; } | { kind: 'range'; lo: number; hi: number; } | { kind: 'open'; n: number; }; interface Pattern { guard?: Guard; tokens: Token[]; /** `weights[k]`: the gap before token k; the last, the gap after the * last token. */ weights: (Weight | undefined)[]; leading: boolean; trailing: boolean; } /** A compiled pattern set. */ export interface KashidaPatternSet { readonly patterns: readonly Pattern[]; } /** A pattern line that does not compile: `line` is 1-based. */ export declare class KashidaPatternError extends Error { readonly line: number; constructor(message: string, line: number); } /** Compile pattern text (raqim's language; `use ` splices a built-in * set in, `naskh` / `simple` / `nastaliq` or raqim's `arabic-…` names). */ export declare function compileKashidaPatterns(text: string): KashidaPatternSet; /** The kashida points of `word` under `set`, in logical order. Text that * is not Arabic-like (no joining letter) has none. */ export declare function findKashidaPoints(word: string, set: KashidaPatternSet): KashidaPoint[]; /** A built-in pattern set, compiled on first use. */ export declare function kashidaPatternSet(name: KashidaPatternSetName): KashidaPatternSet; export {}; //# sourceMappingURL=kashidaPatterns.d.ts.map