UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

288 lines (287 loc) 7.46 kB
/** * Arabic shaping engine that converts base Arabic code points into their * contextual presentation forms (isolated/initial/medial/final), handles * marks (shadda/hamza/madda/tanween), and common ligatures. * * @private */ export declare class _ArabicShapeRenderer { /** * Arabic presentation forms for letters in isolated, initial, medial, and final shapes. * * @private */ _arabicCharTable: string[][]; /** * Arabic letter Alef. * * @private */ _alef: string; /** * Arabic letter Alef with Hamza above. * * @private */ _alefHamza: string; /** * Arabic letter Alef with Hamza below. * * @private */ _alefHamzaBelow: string; /** * Arabic letter Alef with Madda above. * * @private */ _alefMadda: string; /** * Arabic letter Lam. * * @private */ _lam: string; /** * Arabic letter Lam. * * @private */ _hamza: string; /** * Zero Width Joiner character used in shaping. * * @private */ _zeroWidthJoiner: string; /** * Arabic combining Hamza above mark. * * @private */ _hamzaAbove: string; /** * Arabic combining Hamza below mark. * * @private */ _hamzaBelow: string; /** * Arabic letter Waw with Hamza above. * * @private */ _wawHamza: string; /** * Arabic letter Yeh with Hamza above. * * @private */ _yehHamza: string; /** * Arabic letter waw. * * @private */ _waw: string; /** * Arabic letter Alef Maqsura Yeh without dots. * * @private */ _alefsura: string; /** * Arabic letter Yeh. * * @private */ _yeh: string; /** * Farsi Yeh character. * * @private */ _farsiYeh: string; /** * Arabic Shadda combining mark. * * @private */ _shadda: string; /** * Arabic Madda combining mark. * * @private */ _madda: string; /** * Ligature LAM-ALEF with small alef above (isolated/final). * * @private */ _lwa: string; /** * Ligature LAM with WAW and Hamza above (isolated). * * @private */ _lwawh: string; /** * Ligature LAM with WAW and Hamza below (isolated). * * @private */ _lwawhb: string; /** * Ligature LAM-ALEF with Madda above (isolated). * * @private */ _lwawm: string; /** * Urdu Heh with Yeh above (ligature part). * * @private */ _bwhb: string; /** * Arabic Fathatan diacritic. * * @private */ _fathatan: string; /** * Arabic superscript alef. * * @private */ _superalef: string; /** * Bitmask flag used to mark vowel/diacritic characters. * * @private */ _vowel: number; /** * Map of base Arabic characters to their contextual shape forms. * * @private */ _arabicMapTable: Map<string, string[]>; /** * Creates an instance of the 'ArabicShapeRenderer' class. * * @private */ constructor(); /** * Resolves the contextual presentation form for a given base Arabic character * by index 0 = isolated, 1 = final, 2 = initial, 3 = medial based on table layout. * Returns the input unchanged when outside the shaping range or when presentation * form is not applicable. * * @private * @param {string} input The base character to shape. * @param {number} index The contextual form index offset (added to table base). * @returns {string} The presentation form for the specified index, or the input if not applicable. */ _getCharacterShape(input: string, index: number): string; /** * Shapes a mixed text string by detecting Arabic spans, * running shaping on those spans, and concatenating with untouched non Arabic text. * * @private * @param {string} text The input text (may contain mixed scripts). * @returns {string} The shaped text with Arabic spans converted to presentation forms. */ _shape(text: string): string; /** * Performs contextual shaping over a pure Arabic span: applies joining logic, * marks (shadda/hamza/madda/tanween), and ligatures, producing * properly ordered presentation forms. * * @private * @param {string} input The Arabic substring to shape. * @param {number} level Bitfield flags affecting shaping (e.g., `_vowel`). * @returns {string} The shaped Arabic substring. */ _doShape(input: string, level: number): string; /** * Appends a shaped unit to the output builder in this order: * 1) base presentation form, 2) optional diacritic type, 3) optional vowel, * conditioned by the supplied `level` flags. * * @private * @param {string} builder The current output string. * @param {_ArabicShape} shape The shaped unit (base + marks) to append. * @param {number} level Bitfield flags controlling which components to emit. * @returns {string} The updated output string. */ _append(builder: string, shape: _ArabicShape, level: number): string; /** * Processes combining marks and ligatures for the current shape context: * - Combines shadda/hamza/madda/tanween into the current shape as type/vowel. * - Folds lam+alef variants to precomposed lam alef presentation forms. * * Returns: * 0 → no ligation/mark applied, * 1 → a mark consumed, * 2 → mark caused a base replacement, * 3 → lam alef ligature formed. * * @private * @param {string} value The next code point to attempt combining/ligation with. * @param {_ArabicShape} shape The current shape context. * @returns {number} The action code describing the change. */ _ligature(value: string, shape: _ArabicShape): number; /** * Returns the number of contextual presentation forms available for a character: * typically 1 (non joining), 2 (right joining/final/isolate), or 4 (dual joining), * and 4 for Zero Width Joiner logic. Defaults to 1 for non Arabic or marks. * * @private * @param {string} shape The character to evaluate. * @returns {number} The number of available contextual forms (1, 2, or 4). */ _getShapeCount(shape: string): number; } /** * Mutable shaping state for a single Arabic unit, tracking the selected * presentation form, optional diacritic marks, ligature count, * and how many contextual forms the character supports. * * @private */ export declare class _ArabicShape { /** * Holds the shaped character value for the current position. * * @private */ _shapeValue: string; /** * Describes the shaping type (isolated, initial, medial, final). * * @private */ _shapeType: string; /** * Stores any vowel or combining marks applied during shaping. * * @private */ _shapeVowel: string; /** * Indicates the ligature code or kind if applied. * * @private */ _shapeLigature: number; /** * Number of glyphs produced by shaping the current code point. * * @private */ _shapes: number; }