import type { Reader } from "../../font/binary/reader.ts"; import type { GlyphId, uint16 } from "../../types.ts"; /** Class range record for Format 2 */ interface ClassRangeRecord { startGlyphId: GlyphId; endGlyphId: GlyphId; classValue: uint16; } /** * Class Definition table - maps glyph IDs to class values. * * IMPORTANT: This is a unified class (not interface + implementations) to ensure * monomorphic call sites in V8. Polymorphic calls can be 7-8x slower! */ export declare class ClassDef { private readonly startGlyphId; private readonly classValueArray; private readonly ranges; private readonly glyphMap; private readonly isEmpty; private constructor(); /** * Create an empty ClassDef * @returns Empty ClassDef instance where all glyphs return class 0 */ static empty(): ClassDef; /** * Create Format 1 ClassDef (array of class values) * @param startGlyphId - First glyph ID in the range * @param classValueArray - Array of class values indexed by (glyphId - startGlyphId) * @returns ClassDef instance using array lookup */ static format1(startGlyphId: GlyphId, classValueArray: Uint16Array): ClassDef; /** * Create Format 2 ClassDef (ranges) * @param ranges - Array of range records mapping glyph ranges to class values * @returns ClassDef instance using hash map (for small tables) or binary search (for large tables) */ static format2(ranges: ClassRangeRecord[]): ClassDef; /** * Get class for a glyph ID * @param glyphId - The glyph ID to look up * @returns Class value for the glyph, or 0 if not defined */ get(glyphId: GlyphId): number; /** * Get all glyphs in a specific class * @param classValue - The class value to search for * @returns Array of all glyph IDs assigned to this class */ glyphsInClass(classValue: number): GlyphId[]; } /** Singleton empty ClassDef for external use */ export declare const EMPTY_CLASS_DEF: ClassDef; /** * Parse a Class Definition table from binary data * @param reader - Binary reader positioned at class definition table start * @returns Parsed ClassDef instance (Format 1 or Format 2) */ export declare function parseClassDef(reader: Reader): ClassDef; /** * Parse ClassDef from offset, or return empty if offset is 0 * @param reader - Binary reader positioned at parent table * @param offset - Offset from reader's current position to class definition table * @returns Parsed ClassDef instance, or empty ClassDef if offset is 0 */ export declare function parseClassDefAt(reader: Reader, offset: number): ClassDef; export {};