import type { GlyphId, uint16, uint32 } from "../../types.ts"; import type { Reader } from "../binary/reader.ts"; /** Platform IDs */ export declare enum PlatformId { Unicode = 0, Macintosh = 1, ISO = 2,// deprecated Windows = 3, Custom = 4 } /** Encoding record in cmap header */ export interface EncodingRecord { platformId: uint16; encodingId: uint16; offset: uint32; } /** Base interface for cmap subtables */ interface CmapSubtableBase { format: number; lookup(codepoint: number): GlyphId | undefined; } /** Format 0: Byte encoding table (legacy, 256 entries) */ interface CmapFormat0 extends CmapSubtableBase { format: 0; glyphIdArray: Uint8Array; } /** Format 4: Segment mapping to delta values (BMP characters) */ interface CmapFormat4 extends CmapSubtableBase { format: 4; segCount: number; endCodes: Uint16Array; startCodes: Uint16Array; idDeltas: Int16Array; idRangeOffsets: Uint16Array; glyphIdArray: Uint16Array; } /** Format 12: Segmented coverage (full Unicode) */ interface CmapFormat12 extends CmapSubtableBase { format: 12; groups: Array<{ startCharCode: uint32; endCharCode: uint32; startGlyphId: uint32; }>; } /** Variation selector record */ interface VariationSelectorRecord { varSelector: number; defaultUVS: Array<{ startUnicodeValue: number; additionalCount: number; }> | null; nonDefaultUVS: Array<{ unicodeValue: number; glyphId: GlyphId; }> | null; } /** Format 14: Unicode Variation Sequences */ interface CmapFormat14 extends CmapSubtableBase { format: 14; varSelectorRecords: VariationSelectorRecord[]; lookupVariation(codepoint: number, variationSelector: number): GlyphId | undefined | "default"; } export type CmapSubtable = CmapFormat0 | CmapFormat4 | CmapFormat12 | CmapFormat14; /** Character to glyph index mapping table */ export interface CmapTable { version: uint16; numTables: uint16; encodingRecords: EncodingRecord[]; subtables: Map; /** Best subtable for Unicode lookup */ bestSubtable: CmapSubtable | null; } export declare function parseCmap(reader: Reader, tableLength: number): CmapTable; /** Get glyph ID for a codepoint using the best subtable */ export declare function getGlyphId(cmap: CmapTable, codepoint: number): GlyphId; /** Get glyph ID for a variation sequence (base + variation selector) */ export declare function getVariationGlyphId(cmap: CmapTable, codepoint: number, variationSelector: number): GlyphId | undefined; /** Check if a codepoint is a variation selector */ export declare function isVariationSelector(codepoint: number): boolean; export {};