import { type Coverage } from "../../layout/structures/coverage.ts"; import { type DeviceOrVariationIndex } from "../../layout/structures/device.ts"; import type { GlyphId, int16, uint16 } from "../../types.ts"; import type { Reader } from "../binary/reader.ts"; /** * MATH table - Mathematical typesetting data * Provides metrics and glyph information for math layout */ /** MathValueRecord - value with optional device correction */ export interface MathValueRecord { value: int16; device: DeviceOrVariationIndex | null; } /** MathConstants - global math constants */ export interface MathConstants { scriptPercentScaleDown: int16; scriptScriptPercentScaleDown: int16; delimitedSubFormulaMinHeight: uint16; displayOperatorMinHeight: uint16; mathLeading: MathValueRecord; axisHeight: MathValueRecord; accentBaseHeight: MathValueRecord; flattenedAccentBaseHeight: MathValueRecord; subscriptShiftDown: MathValueRecord; subscriptTopMax: MathValueRecord; subscriptBaselineDropMin: MathValueRecord; superscriptShiftUp: MathValueRecord; superscriptShiftUpCramped: MathValueRecord; superscriptBottomMin: MathValueRecord; superscriptBaselineDropMax: MathValueRecord; subSuperscriptGapMin: MathValueRecord; superscriptBottomMaxWithSubscript: MathValueRecord; spaceAfterScript: MathValueRecord; upperLimitGapMin: MathValueRecord; upperLimitBaselineRiseMin: MathValueRecord; lowerLimitGapMin: MathValueRecord; lowerLimitBaselineDropMin: MathValueRecord; stackTopShiftUp: MathValueRecord; stackTopDisplayStyleShiftUp: MathValueRecord; stackBottomShiftDown: MathValueRecord; stackBottomDisplayStyleShiftDown: MathValueRecord; stackGapMin: MathValueRecord; stackDisplayStyleGapMin: MathValueRecord; stretchStackTopShiftUp: MathValueRecord; stretchStackBottomShiftDown: MathValueRecord; stretchStackGapAboveMin: MathValueRecord; stretchStackGapBelowMin: MathValueRecord; fractionNumeratorShiftUp: MathValueRecord; fractionNumeratorDisplayStyleShiftUp: MathValueRecord; fractionDenominatorShiftDown: MathValueRecord; fractionDenominatorDisplayStyleShiftDown: MathValueRecord; fractionNumeratorGapMin: MathValueRecord; fractionNumDisplayStyleGapMin: MathValueRecord; fractionRuleThickness: MathValueRecord; fractionDenominatorGapMin: MathValueRecord; fractionDenomDisplayStyleGapMin: MathValueRecord; skewedFractionHorizontalGap: MathValueRecord; skewedFractionVerticalGap: MathValueRecord; overbarVerticalGap: MathValueRecord; overbarRuleThickness: MathValueRecord; overbarExtraAscender: MathValueRecord; underbarVerticalGap: MathValueRecord; underbarRuleThickness: MathValueRecord; underbarExtraDescender: MathValueRecord; radicalVerticalGap: MathValueRecord; radicalDisplayStyleVerticalGap: MathValueRecord; radicalRuleThickness: MathValueRecord; radicalExtraAscender: MathValueRecord; radicalKernBeforeDegree: MathValueRecord; radicalKernAfterDegree: MathValueRecord; radicalDegreeBottomRaisePercent: int16; } /** Italic correction info */ export interface MathItalicsCorrection { coverage: Coverage; values: MathValueRecord[]; } /** Top accent attachment */ export interface MathTopAccentAttachment { coverage: Coverage; values: MathValueRecord[]; } /** Extended shape coverage */ export interface ExtendedShapeCoverage { coverage: Coverage; } /** Math kern record for corner kerns */ export interface MathKernRecord { correctionHeights: MathValueRecord[]; kernValues: MathValueRecord[]; } /** Math kern info for a glyph */ export interface MathKernInfo { topRight: MathKernRecord | null; topLeft: MathKernRecord | null; bottomRight: MathKernRecord | null; bottomLeft: MathKernRecord | null; } /** Math kern info table */ export interface MathKernInfoTable { coverage: Coverage; kernInfo: MathKernInfo[]; } /** MathGlyphInfo - per-glyph math info */ export interface MathGlyphInfo { italicsCorrection: MathItalicsCorrection | null; topAccentAttachment: MathTopAccentAttachment | null; extendedShapeCoverage: ExtendedShapeCoverage | null; kernInfo: MathKernInfoTable | null; } /** Glyph part record for assembly */ export interface GlyphPartRecord { glyphId: GlyphId; startConnectorLength: uint16; endConnectorLength: uint16; fullAdvance: uint16; partFlags: uint16; } /** Glyph assembly */ export interface GlyphAssembly { italicsCorrection: MathValueRecord; parts: GlyphPartRecord[]; } /** Math glyph construction */ export interface MathGlyphConstruction { glyphAssembly: GlyphAssembly | null; variants: Array<{ variantGlyph: GlyphId; advanceMeasurement: uint16; }>; } /** MathVariants - glyph variants and construction */ export interface MathVariants { minConnectorOverlap: uint16; vertGlyphCoverage: Coverage | null; horizGlyphCoverage: Coverage | null; vertGlyphConstruction: MathGlyphConstruction[]; horizGlyphConstruction: MathGlyphConstruction[]; } /** MATH table */ export interface MathTable { majorVersion: uint16; minorVersion: uint16; constants: MathConstants | null; glyphInfo: MathGlyphInfo | null; variants: MathVariants | null; } export declare function parseMath(reader: Reader): MathTable; /** Get italic correction for a glyph */ export declare function getItalicsCorrection(math: MathTable, glyphId: GlyphId): MathValueRecord | null; /** Get top accent attachment for a glyph */ export declare function getTopAccentAttachment(math: MathTable, glyphId: GlyphId): MathValueRecord | null; /** Check if glyph is an extended shape */ export declare function isExtendedShape(math: MathTable, glyphId: GlyphId): boolean; /** Get vertical glyph variants */ export declare function getVerticalVariants(math: MathTable, glyphId: GlyphId): Array<{ variantGlyph: GlyphId; advanceMeasurement: uint16; }> | null; /** Get horizontal glyph variants */ export declare function getHorizontalVariants(math: MathTable, glyphId: GlyphId): Array<{ variantGlyph: GlyphId; advanceMeasurement: uint16; }> | null; /** Get vertical glyph assembly */ export declare function getVerticalAssembly(math: MathTable, glyphId: GlyphId): GlyphAssembly | null; /** Get horizontal glyph assembly */ export declare function getHorizontalAssembly(math: MathTable, glyphId: GlyphId): GlyphAssembly | null;