import type { Font } from "../font/font.ts"; import { Direction, type GlyphId, type GlyphInfo, type GlyphPosition } from "../types.ts"; /** * Output buffer containing shaped glyphs. * Result of the shaping process. */ export declare class GlyphBuffer { /** Direction used during shaping */ direction: Direction; /** Script used during shaping */ script: string; /** Language used during shaping */ language: string | null; /** Glyph information array */ infos: GlyphInfo[]; /** Glyph position array */ positions: GlyphPosition[]; /** Deleted glyph markers for deferred removal */ private _deleted; /** Count of deleted glyphs pending compaction */ private _deletedCount; /** Pre-allocated info pool for reuse */ private _infoPool; /** Pre-allocated position pool for reuse */ private _posPool; /** Pre-allocated capacity hint */ private _capacity; /** Create buffer with pre-allocated capacity (lazy object creation) */ static withCapacity(capacity: number): GlyphBuffer; /** Number of glyphs */ get length(): number; /** Reset buffer for reuse - reuses existing object pool */ reset(): void; /** Initialize from codepoints, reusing pooled objects when possible */ initFromCodepoints(codepoints: ArrayLike, clusters: ArrayLike, getGlyphId: (codepoint: number) => number): void; /** * Initialize from codepoints with direct font access (no closure). * This is faster than initFromCodepoints for hot paths. */ initFromCodepointsWithFont(codepoints: ArrayLike, clusters: ArrayLike, font: Font): void; /** Initialize from glyph infos (positions zeroed) */ initFromInfos(infos: GlyphInfo[]): void; /** Set advance width for a glyph */ setAdvance(index: number, xAdvance: number, yAdvance?: number): void; /** Add offset to a glyph position */ addOffset(index: number, xOffset: number, yOffset: number): void; /** Replace glyph at index */ replaceGlyph(index: number, glyphId: GlyphId): void; /** Insert glyph at index */ insertGlyph(index: number, info: GlyphInfo, position: GlyphPosition): void; /** Remove glyphs in range [start, end) */ removeRange(start: number, end: number): void; /** * Mark a glyph for deferred deletion. Much faster than removeRange for * multiple deletions - call compact() once at end of GSUB phase. */ markDeleted(index: number): void; /** Check if a glyph is marked for deletion */ isDeleted(index: number): boolean; /** Returns true if there are pending deletions */ hasPendingDeletions(): boolean; /** * Compact buffer by removing all marked-for-deletion glyphs in a single O(n) pass. * Call this after GSUB phase. */ compact(): void; /** Merge clusters from start to end (inclusive) */ mergeClusters(start: number, end: number): void; /** Reverse glyph order (for RTL) */ reverse(): void; /** Reverse range [start, end) */ reverseRange(start: number, end: number): void; /** Get total advance width */ getTotalAdvance(): { x: number; y: number; }; /** Serialize to HarfBuzz-compatible format */ serialize(): string; /** Get glyph IDs as array */ glyphIds(): GlyphId[]; /** Get clusters as array */ clusters(): number[]; /** Iterator for glyph info/position pairs */ [Symbol.iterator](): Iterator<{ info: GlyphInfo; position: GlyphPosition; }>; }