import { ParsedTtf } from './ttf-parser.js'; /** * Text measurement and glyph encoding derived purely from a parsed font (no PDF * involved). Layout measures with these, and the PDF emitter reuses the same * functions, so emit encodes exactly what layout measured. CIDs are GIDs * (Identity ordering), so the hex encoding is writer-agnostic glyph addressing. */ export interface FontMeasure { /** Glyph advance width in 1000-unit PDF text space, for a glyph id. */ readonly pdfWidthForGid: (gid: number) => number; /** Shaped width of `text` at `fontSize`, in points. */ readonly textWidthPt: (text: string, fontSize: number) => number; /** * How far this text's INK actually reaches from its baseline, in points: * `above` up to its highest glyph edge, `below` down to its lowest. Not the * font's line box — "HHH" reaches a cap height and no further, and only a * string carrying a descender reaches under the baseline at all. WordArt * stretches the ink it draws to fill its shape (§20.1.9.10), so it is the * ink and not the line box that has to be measured. */ readonly textInkPt: (text: string, fontSize: number) => { above: number; below: number; }; /** Encode `text` as a hex string of 4-digit glyph ids (Identity-H addressing). */ readonly encodeTextAsCidHex: (text: string) => string; /** * The complete PDF text-showing operator for `text` — ` Tj`, or a * `[…] TJ` array when shaping moved a glyph off its own advance. */ readonly showText: (text: string) => string; } /** * Build a {@link FontMeasure} over a parsed font. * * @param parsed The parsed TTF/OTF. * @param kern Whether to apply pair kerning to measured advances (E-PARITY * FP4). The default keeps it; the `'word'` layout profile turns it * off (Word leaves font kerning off by default, and Ream's `Tj` * output is un-kerned anyway). Glyph identity is kern-independent, * so only the widths change. * @returns The measurement / encoding closures. */ export declare function createFontMeasure(parsed: ParsedTtf, kern?: boolean): FontMeasure;