import type { GlyphId, uint16, uint32 } from "../../types.ts"; import type { Reader } from "../binary/reader.ts"; /** * Extended Glyph Metamorphosis table (morx) * Apple Advanced Typography substitution */ export interface MorxTable { version: number; chains: MorxChain[]; } /** * Feature chain in morx */ export interface MorxChain { defaultFlags: uint32; features: MorxFeature[]; subtables: MorxSubtable[]; } /** * Feature entry */ export interface MorxFeature { featureType: uint16; featureSetting: uint16; enableFlags: uint32; disableFlags: uint32; } /** * Subtable types */ export declare enum MorxSubtableType { Rearrangement = 0, Contextual = 1, Ligature = 2, NonContextual = 4, Insertion = 5 } /** * Base subtable */ export interface MorxSubtableBase { type: MorxSubtableType; coverage: MorxCoverage; subFeatureFlags: uint32; } export interface MorxCoverage { vertical: boolean; descending: boolean; logical: boolean; } export type MorxSubtable = MorxRearrangementSubtable | MorxContextualSubtable | MorxLigatureSubtable | MorxNonContextualSubtable | MorxInsertionSubtable; /** * Type 0: Rearrangement (reorders glyphs) */ export interface MorxRearrangementSubtable extends MorxSubtableBase { type: MorxSubtableType.Rearrangement; stateTable: StateTable; } export interface RearrangementEntry { newState: uint16; flags: uint16; } /** * Type 1: Contextual substitution */ export interface MorxContextualSubtable extends MorxSubtableBase { type: MorxSubtableType.Contextual; stateTable: StateTable; substitutionTable: Map[]; } export interface ContextualEntry { newState: uint16; flags: uint16; markIndex: uint16; currentIndex: uint16; } /** * Type 2: Ligature */ export interface MorxLigatureSubtable extends MorxSubtableBase { type: MorxSubtableType.Ligature; stateTable: StateTable; ligatureActions: uint32[]; components: uint16[]; ligatures: GlyphId[]; } export interface LigatureEntry { newState: uint16; flags: uint16; ligActionIndex: uint16; } /** * Type 4: Non-contextual (simple substitution) */ export interface MorxNonContextualSubtable extends MorxSubtableBase { type: MorxSubtableType.NonContextual; lookupTable: LookupTable; } /** * Type 5: Insertion */ export interface MorxInsertionSubtable extends MorxSubtableBase { type: MorxSubtableType.Insertion; stateTable: StateTable; insertionGlyphs: GlyphId[]; } export interface InsertionEntry { newState: uint16; flags: uint16; currentInsertIndex: uint16; markedInsertIndex: uint16; } /** * State table for state machine processing */ export interface StateTable { nClasses: uint32; classTable: ClassTable; stateArray: E[][]; } /** * Class lookup table */ export interface ClassTable { format: number; classArray: number[]; } /** * Lookup table for substitutions */ export interface LookupTable { format: number; mapping: Map; } /** * Parse morx table */ export declare function parseMorx(reader: Reader): MorxTable; /** * Apply non-contextual substitution */ export declare function applyNonContextual(subtable: MorxNonContextualSubtable, glyphId: GlyphId): GlyphId | null;