import { _fontTables } from './font-tables'; import { _PdfCrossReference, _PdfDictionary, PdfFontStyle } from '@syncfusion/ej2-pdf'; /** * Represents the font structure containing metrics, encodings and glyph mappings * used during text extraction. * * @private */ export declare class _FontStructure { /** Font ascent value. * * @private */ _ascent: number; /** Font bounding box array. * * @private */ _boundingBox: number[]; /** Character map. * * @private */ _characterMap: any; /** Font style flags. * * @private */ _fontStyle: PdfFontStyle; /** Built in encoding map. * * @private */ _builtInEncoding: any; /** Unicode fallback mapping. * * @private */ _fallBackToUnicodeMap: any; /** Capital height. * * @private */ _capHeight: number; /** encoding name. * * @private */ _encoding: string; /** True if composite font. * * @private */ _composite: boolean; /** CSS font info. * * @private */ _cssFontInfo: any; /** Raw font data streams. * * @private */ _data: Uint8Array[]; /** default encoding values. * * @private */ _defaultEncoding: any[]; /** Default glyph width. * * @private */ _defaultWidth: number; /** Font descent. * * @private */ _descent: number; /** Differences array for type1 encodings * * @private */ _differences: any[]; /** True to disable. * * @private */ _disableFontFace: boolean; /** CIDSystemInfo for CID fonts. * * @private */ _characterSystemInfo: any; /** Font matrix transform array. * * @private */ _fontMatrix: number[]; /** Character cache. * * @private */ _charsCache: any; /** Glyph cache. * * @private */ _glyphCache: any; /** Width of array glyphs. * * @private */ _widths: number[]; /** True if vertical writing mode. * * @private */ _vertical: boolean; /** Font type string. * * @private */ _type: string; /** toUnicode Map objec. * * @private */ _toUnicode: any; /** Mapping from font char codes to Unicode or font glyph indices. * * @private */ _toFontChar: any; /** True when the font is considered a serif face. * * @private */ _isSerifFont: boolean; /** True when the font is symbolic (Symbol/ZapfDingbats-like). * * @private */ _isSymbolicFont: boolean; /** True when the font represents Type3 glyphs. * * @private */ _isType3Font: boolean; /** True when the font was loaded from an internal/embedded resource. * * @private */ _isInternalFont: boolean; /** Computed line height for the font in font units. * * @private */ _lineHeight: number; /** MIME type string for detected embedded font data. * * @private */ _mimeType: any; /** True when the original font file is missing. * * @private */ _missingFile: boolean; /** Resolved font name. * * @private */ _name: string; /** Internal font flags bitfield. * * @private */ _flags: number; /** PostScript name if available. * * @private */ _psName: string; /** Font subtype string (e.g., 'Type1C'). * * @private */ _subtype: string; /** System font metadata object when available. * * @private */ _systemFontInfo: any; /** Original PDF font dictionary. * * @private */ _dictionary: _PdfDictionary; /** Cross reference table for indirect object resolution. * * @private */ _crossReference: _PdfCrossReference; /** True when underlying font file is OpenType/TTF. * * @private */ _isOpenType: boolean; /** Line gap metric extracted from font tables. * * @private */ _lineGap: any; /** Internal markers used for fallback/format heuristics (bold/italic). * * @private */ _bold: any; _italic: any; _black: any; /** Length fields from embedded font streams (Type1/CFF). * * @private */ _length1: number; _length2: number; _length3: number; constructor(); constructor(dictionary: _PdfDictionary, crossReference: _PdfCrossReference); /** * Initialize internal structures and pre-evaluate font information. * * @private * @returns {void} nothing. */ _initialize(): void; /** * Convert a sequence of characters into glyph objects for this font. * * @param {string} chars - String containing one or more characters to convert. * @returns {_Glyph} Array of `_Glyph` instances representing the characters. * @private */ _charsToGlyphs(chars: string): _Glyph[]; } /** * Helper that parses font dictionaries, reads font files and resolves glyph * and encoding information required by `_FontStructure`. * * @private */ export declare class _FontHelper { /** Parent `_FontStructure` instance being populated. * * @private */ _fontStructure: _FontStructure; /** Optional per-glyph scale factors read from font tables. * * @private */ _scaleFactors: any; /** True when a ToUnicode map was included in the font resources. * * @private */ _hasIncludedToUnicodeMap: boolean; /** Cross-reference table used for indirect object resolution. * * @private */ _crossReference: _PdfCrossReference; /** First character code used by widths arrays. * * @private */ _firstChar: number; /** Last character code used by widths arrays. * * @private */ _lastChar: number; /** Local font table helper instance. * * @private */ _table: _fontTables; /** Flag indicating whether re-measurement of fallback metrics is required. * * @private */ _remeasure: any; /** Standard character overrides map (used for accented character heuristics). * * @private */ _standardCharacter: any; /** Raw font file bytes or stream data. * * @private */ _data: any; /** Internal flags bitfield. * * @private */ _flags: number; /** True when font writing direction is vertical. * * @private */ _vertical: boolean; /** Underlying file-like object for embedded font data. * * @private */ _file: any; /** Detected font file type string. * * @private */ _fileType: string; /** Detected font file subtype (e.g., 'Type1C'). * * @private */ _fileSubtype: string; /** Italic angle metric extracted from font descriptor. * * @private */ _italicAngle: number; /** x-height metric for the font. * * @private */ _xHeight: number; /** Name of base encoding declared in the font dictionary. * * @private */ _baseEncodingName: any; /** Identity transform used when normalizing font units. * * @private */ _fontIdentityMatrix: number[]; /** Fallback mapping used when building ToUnicode maps. * * @private */ _fallBackToUnicodeMap: any; /** Mapping from character id to glyph id when present. * * @private */ _characterIdToGlyphMap: any; /** True when an explicit encoding is present on the font dictionary. * * @private */ _hasEncoding: any; /** True when the underlying file indicates OpenType-specific layouts. * * @private */ _isOpenType: boolean; /** Cache for standard font binary blobs. * * @private */ _standardFontDataCache: Map; /** Internal table of font flag constants. * * @private */ _fontFlags: any; /** List of TrueType/OpenType tables we accept and parse. * * @private */ _validTables: any; /** * @private */ _ttOpsStackDeltas: number[]; constructor(fontStructure: _FontStructure, crossReference: _PdfCrossReference); /** * Pre-evaluate the PDF font dictionary and prepare font properties. * * @private * @param {_PdfDictionary} dictionary - The PDF font dictionary to inspect. * @returns {any} internal parsing result (implementation specific). */ _preEvaluateFont(dictionary: _PdfDictionary): any; /** * Determine the font style (bold/italic) from the font dictionary. * * @private * @param {_PdfDictionary} dictionary - The PDF font dictionary. * @returns {PdfFontStyle} Computed `PdfFontStyle` flags. */ _getFontStyle(dictionary: _PdfDictionary): PdfFontStyle; /** * Translate and extract font-related structures from font descriptor and * dictionaries into the `_FontStructure`. * * @private * @param {any} descriptor - Font descriptor dictionary. * @param {any} dictionary - The font dictionary used for parsing. * @param {any} baseDictionary - Base dictionary that may contain overrides. * @param {number} firstChar - First character code in widths array. * @param {number} lastChar - Last character code in widths array. * @param {any} unicode - Optional ToUnicode mapping or stream. * @returns {any} Implementation specific result. */ _translateFont(descriptor: any, dictionary: any, baseDictionary: any, firstChar: number, lastChar: number, unicode: any): any; /** * Build a mapping from character codes to glyph widths. * * @private * @param {any} widthsByGlyphName - Mapping of glyph names to widths. * @returns {any} Map of character code -> width. */ _buildCharCodeToWidth(widthsByGlyphName: any): any; /** * Fetch embedded standard font data by name, if available. * * @private * @param {string} name - Standard font name. * @returns {any} A `_PdfStream` containing font bytes or null when not found. */ _fetchStandardFontData(name: string): any; /** * Inspect font file data and initialize internal font tables and encodings. * * @private * @returns {any} Implementation specific result. */ _setFontData(): any; /** * Check whether the provided file is a TrueType font. * * @private * @param {any} file - File-like object with `peekBytes`. * @returns {boolean} True when the file header matches a TrueType signature. */ _isTrueTypeFile(file: any): boolean; /** * Read a big-endian unsigned 32-bit integer from a byte array. * * @private * @param {any} data - Source byte array. * @param {any} offset - Offset within `data`. * @returns {any} The unsigned 32-bit integer value. */ _readUnsignedInt32(data: any, offset: any): any; /** * Check whether the file is an OpenType font . * * @private * @param {any} file - File-like object with `peekBytes`. * @returns {boolean} True when header equals 'OTTO'. */ _isOpenTypeFile(file: any): boolean; /** * Check whether the file appears to be a Type1 font. * * @private * @param {any} file - File-like object with `peekBytes`. * @returns {boolean} True when known Type1 signatures are found. */ _isType1File(file: any): boolean; /** * Determine whether the file represents a Compact Font Format. * * @private * @param {any} file - File-like object with `peekBytes`. * @returns {boolean} True for CFF-like headers. */ _isCompactFontFile(file: any): boolean; /** * Determine the font file type (TrueType, OpenType, Type1, etc.) and * set internal fileType/fileSubtype accordingly. * * @private * @returns {void} nothing. */ _getFontFileType(): void; /** * Extract glyph widths and vertical metrics from font descriptor and * populate internal width tables. * * @private * @param {_PdfDictionary} descriptor - Font descriptor dictionary. * @param {number} flags - Font flags controlling symbolic/monospace behavior. * @param {number} firstChar - First character code. * @param {_PdfDictionary} dictionary - Font dictionary used when extracting widths. * @returns {void} nothing. */ _extractWidths(descriptor: _PdfDictionary, flags: number, firstChar: number, dictionary: _PdfDictionary): void; /** * Normalize rectangle coordinates so that left <= right and top <= bottom. * * @private * @param {number} rect - Rectangle array [left, top, right, bottom]. * @returns {number} Normalized rectangle array. */ _normalizeRect(rect: number[]): number[]; /** * Check whether a value is a numeric array of an expected length. * * @private * @param {any} arr - Value to test. * @param {number} len - Required length or `null` to ignore length. * @returns {boolean} True when `arr` is an array of numbers matching `len`. */ private _isNumberArray; /** * Return `arr` when it is a 6-element numeric matrix, otherwise the fallback. * * @private * @param {any} arr - Candidate matrix. * @param {number} fallBack - Fallback matrix. * @returns {any} Either `arr` or `fallBack`. */ _lookupMatrix(arr: any, fallBack: number[]): any; /** * Return `arr` when it is a 4-element numeric rect, otherwise the fallback. * * @private * @param {any} arr - Candidate rect. * @param {number} fallBack - Fallback rect. * @returns {any} Either `arr` or `fallBack`. */ _lookupRect(arr: any, fallBack: number[]): any; /** * Return a normalized rect when `arr` is a numeric rect, otherwise the fallback. * * @private * @param {any} arr - Candidate rect. * @param {number} fallBack - Fallback rect. * @returns {any} Normalized rect or fallback. */ _lookupNormalRect(arr: any, fallBack: number[]): any; /** * Extract encoding, differences and ToUnicode mappings from the font * dictionary into the `_FontStructure`. * * @private * @param {_PdfDictionary} dictionary - PDF font dictionary. * @param {any} unicode - Optional ToUnicode mapping or stream. * @returns {void} nothing. */ _extractDataStructures(dictionary: _PdfDictionary, unicode?: any): void; /** * Convert a PDF string to a JavaScript string. * * @private * @param {any} text - Input PDF string buffer. * @returns {any} Decoded JavaScript string. */ _stringToPdfString(text: any): any; /** * Read and build a to-unicode map from a CMap name or stream. * * @private * @param {any} cmapObj - CMap name or stream object. * @returns {any} A unicode mapping object or null. */ _readToUnicode(cmapObj: any): any; /** * Build a ToUnicode mapping taking into account base encodings and CMaps. * * @private * @param {any} baseEncodingName - Name of the base encoding if present. * @param {boolean} isEncoding - True when an explicit encoding is present. * @param {any} toUnicode - Existing toUnicode structure if any. * @returns {any} A mapping object representing character -> unicode. */ _buildToUnicode(baseEncodingName: any, isEncoding: boolean, toUnicode: any): any; /** * Build a simple ToUnicode map for non-composite fonts using a base encoding. * * @private * @param {any} baseEncodingName - Base encoding name to use. * @param {boolean} forceGlyphs - When true forces glyph numeric parsing. * @returns {void} Array mapping character codes to unicode strings. */ _simpleFontToUnicode(baseEncodingName: any, forceGlyphs?: boolean): void; /** * Convert a 32-bit integer to a 4-character string. * * @private * @param {any} value - 32-bit integer value. * @returns {any} The 4-character string representation. */ _string32(value: any): string; /** * Build mapping from character codes to font character unicode values. * * @private * @param {any} encoding - Encoding array. * @param {any} glyphsUnicodeMap - Glyph-to-unicode lookup map. * @param {any} differences - Differences array from encoding. * @returns {any} Mapping array from charCode to unicode. */ _buildToFontChar(encoding: any, glyphsUnicodeMap: any, differences: any): any; /** * Resolve a glyph name into a unicode code point using known mapping rules. * * @private * @param {any} name - Glyph name (e.g. 'A', 'uniXXXX', 'uXXXX'). * @param {any} glyphsUnicodeMap - Known glyph->unicode mapping table. * @returns {any} Unicode code point or -1 when unknown. */ _getUnicodeForGlyph(name: any, glyphsUnicodeMap: any): any; /** * Write an unsigned 32-bit value into a byte array. * * @private * @param {number} bytes - Destination byte array. * @param {number} index - Starting index in `bytes`. * @param {number} value - Unsigned 32-bit value to write. * @returns {void} nothing. */ _writeUnSignedInt32(bytes: number[], index: number, value: number): void; /** * Convert a JavaScript string to a `Uint8Array` of character codes. * * @private * @param {any} value - Input string. * @returns {Uint8Array} The resulting `Uint8Array`. */ _stringToBytes(value: any): Uint8Array; /** * Write a signed 16-bit integer into a byte array. * * @private * @param {number} bytes - Destination byte array. * @param {number} index - Index to write to. * @param {number} value - Signed 16-bit integer value. * @returns {void} nothing. */ _writeSignedInt16(bytes: number[], index: number, value: number): void; /** * Combine two bytes into a signed 16-bit integer. * * @private * @param {number} b0 - High byte. * @param {number} b1 - Low byte. * @returns {number} Signed 16-bit integer. */ _signedInt16(b0: number, b1: number): number; /** * Determine whether the font name is considered a serif font. * * @private * @param {string} baseFontName - Base font name to check. * @returns {boolean} True when font is a serif font. */ _isSerifFont(baseFontName: string): boolean; /** * Adjust stored glyph widths according to the font matrix scale. * * @private * @returns {any} nothing. */ _adjustWidths(): any; /** * Retrieve basic font metrics for a given base font name. * * @private * @param {string} name - Font name to query. * @returns {any} Object containing `defaultWidth`, `monospace` and `widths`. */ _getBaseFontMetrics(name: string): any; /** * Return the list of supported standard font names used for metric lookup. * * @private * @returns {any} Array of standard font names. */ _getMetrics(): any; /** * Normalize and map an input font name to a standard font key where possible. * * @private * @param {name} name - Input font name. * @returns {any} Standard font key or undefined when not found. */ _getStandardFontName(name: string): any; /** * Normalize a font name by replacing commas/underscores and removing spaces. * * @private * @param {string} name - Font name to normalize. * @returns {string} Normalized font name. */ _normalizeFontName(name: string): string; /** * Amend the font's ToUnicode map with fallback mappings when necessary. * * @private * @param {any} properties - Helper properties containing fallback maps. * @returns {void} nothing. */ _amendFallBackToUnicodeMap(properties: any): void; /** * Apply a standard glyph map to an existing mapping array. * * @private * @param {any} map - Destination map to modify. * @param {any} glyphMap - Source glyph mapping object. * @returns {any} nothing. */ _applyStandardFontGlyphMap(map: any, glyphMap: any): any; /** * Set a fallback system font and populate default metrics when a font * file is missing or unsupported. * * @private * @param {any} properties - Helper properties used during fallback. * @returns {any} nothing. */ _setFallBackSystemFont(properties: any): any; /** * Compute a reasonable width to use for the space character when the * actual space glyph is missing. * * @private * @returns {number} Width in font units for the space glyph. */ readonly _spaceWidth: number; /** * Convert a single character code into a `_Glyph` object. * * @private * @param {any} charCode - Character or CID code to convert. * @param {boolean} isSpace - True when the character should be treated as whitespace. * @returns {_Glyph} A `_Glyph` instance representing the input code. */ _charToGlyph(charCode: any, isSpace?: boolean): _Glyph; /** * Convert a character identifier string (CID) into a numeric code. * * @private * @param {any} characterCode - Original character code. * @param {any} characterIdentifier - CID string to convert. * @param {boolean} shouldThrow - When true throw on unsupported formats. * @returns {any} Numeric code or the original identifier on unsupported lengths. */ _convertCidString(characterCode: any, characterIdentifier: any, shouldThrow?: boolean): any; /** * Check whether the file is a TrueType Collection (ttcf). * * @private * @param {any} file - File-like object with `peekBytes`. * @returns {any} True when tag equals 'ttcf'. */ _isTrueTypeCollectionFile(file: any): boolean; /** * Read the header of a TrueType Collection. * * @private * @param {any} data - File-like data object positioned at the TTC header. * @returns {any} Parsed TTC header object. */ _readTrueTypeCollectionHeader(data: any): any; /** * Read a string of given length from a file-like object. * * @private * @param {number} length - Number of bytes to read. * @param {any} file - File-like object with `getBytes`. * @returns {any} The decoded string. */ _getString(length: number, file: any): string; /** * Read an OpenType/TrueType header from a font file. * * @private * @param {any} ttf - File-like object positioned at the header. * @returns {any} Header fields including `version` and `numTables`. */ _readOpenTypeHeader(ttf: any): { version: string; numTables: any; searchRange: any; entrySelector: any; rangeShift: any; }; /** * Read font table directory entries and collect supported tables. * * @private * @param {any} file - File-like object to read from. * @param {any} numberOfTables - Number of table entries in the header. * @returns {any} Object with discovered table entries. */ _readTables(file: any, numberOfTables: any): any; /** * Read a single font table entry and extract its data bytes. * * @private * @param {any} file - File-like object positioned at the table entry. * @returns {any} Object describing the table (tag, checksum, offset, length, data). */ _readTableEntry(file: any): { tag: string; checksum: number; length: number; offset: number; data: any; }; /** * Determine whether a name table record represents a Mac name record. * * @private * @param {any} r - Name table record. * @returns {boolean} True when the record is a Mac name record. */ _isMacNameRecord(r: any): boolean; /** * Determine whether a name table record represents a Windows name record. * * @private * @param {any} r - Name table record. * @returns {any} returns whether record represents window name record. */ _isWinNameRecord(r: any): boolean; /** * Read the 'name' table and extract localized name strings. * * @private * @param {any} nameTable - Table descriptor for the name table. * @param {any} font - File-like font object. * @returns {any} returns the name string. */ _readNameTable(nameTable: any, font: any): any[]; /** * Read and locate font data inside a TrueType Collection for the requested * font name. * * @private * @param {any} data - TTC data object. * @param {any} fontName - Font name to locate. * @param {any} font - File-like object representing the TTC. * @returns {void} nothing. */ _readTrueTypeCollectionData(data: any, fontName: any, font: any): { header: any; tables: any; }; /** * Combine two bytes into a 16-bit integer. * * @private * @param {any} b0 - High byte. * @param {any} b1 - Low byte. * @returns {any} 16-bit integer value. */ _int16(b0: any, b1: any): any; /** * Check font tables and attempt repair/normalization for known issues. * * @private * @param {any} font - File-like font object to inspect and possibly repair. * @returns {void} nothing. */ _checkAndRepair(font: any): void; /** * Adjust the ToUnicode map for Type1 fonts using built-in encodings. * * @private * @returns {void} nothing. */ _adjustType1ToUnicode(): void; /** * Attempt to build a ToUnicode map for TrueType symbolic fonts using name * table heuristics. * * @private * @param {any} properties - Font properties used to build the map. * @param {any} isSymbolicFont - True when font is symbolic. * @param {any} nameRecords - Parsed name table records. * @returns {any} nothing . */ _adjustTrueTypeToUnicode(properties: any, isSymbolicFont: any, nameRecords: any): void; } export declare class _Glyph { /** Unicode character (string) represented by this glyph. * * @private */ _unicode: string; /** Accent information used for composed characters (if any). * * @private */ _accent: number; /** Advance width of the glyph in font units. * * @private */ _width: number; /** Original font character (single character string) when available. * * @private */ _fontCharacter: string; /** Vertical metrics (vmtx) for the glyph when available. * * @private */ _verticalMetrics: any; /** True when this glyph should be treated as whitespace. * * @private */ _isSpace: boolean; /** True when the glyph is known to be present in the font file. * * @private */ _isInFont: boolean; constructor(unicode: string, accent: any, width: number, _verticalMetrics: any, //eslint-disable-line isSpace: boolean, isInFont: boolean); }