/** * Lightweight TrueType glyph rasterizer for chart PNG text rendering. * * Parses the minimal set of TTF tables (cmap, hmtx, loca, glyf, head, hhea, * maxp) needed to extract glyph outlines, then rasterizes them via scan-line * fill. No dependencies outside this module except `@utils/fs`. * * Supports: * - Simple glyphs (positive numberOfContours) * - Composite glyphs (negative numberOfContours, recursive component assembly) * - Quadratic B-spline outlines (on-curve / off-curve points, implicit * on-curve midpoints between consecutive off-curve points) * * Does NOT support: hinting, kerning, OpenType features, vertical layout. * This is intentional — the goal is readable chart labels, not DTP. */ interface GlyphPoint { x: number; y: number; onCurve: boolean; } interface GlyphOutline { contours: GlyphPoint[][]; advanceWidth: number; } export interface RasterFont { unitsPerEm: number; ascent: number; descent: number; getOutline(codePoint: number): GlyphOutline | undefined; } /** * Parse a TTF font file into a RasterFont that can render glyphs to pixels. */ export declare function parseRasterFont(data: Uint8Array): RasterFont; /** * Rasterize a single glyph into an alpha bitmap with 4x supersampled * anti-aliasing for smooth edges. * * @param outline - Glyph outline from RasterFont.getOutline() * @param fontSize - Target font size in pixels * @param unitsPerEm - Font's unitsPerEm * @returns { width, height, offsetX, offsetY, pixels } * offsetX/offsetY are pixel offsets from the pen position (left of baseline) * to the top-left of the bitmap. pixels values are 0–255 (coverage). */ export declare function rasterizeGlyph(outline: GlyphOutline, fontSize: number, unitsPerEm: number): { width: number; height: number; offsetX: number; offsetY: number; pixels: Uint8Array; }; /** * Load a system font for text rasterization. * Returns null in browser environments or if no font is found. * Results are cached — only loads once. */ export declare function loadSystemFont(): RasterFont | null; /** Reset cached font (for testing). */ export declare function resetCachedFont(): void; export {};