/** * Font - PDF font handling * * This module provides 100% API compatibility with MicroPDF's font operations. * Handles font loading, glyph encoding, metrics, and rendering. */ import { Rect, type RectLike } from './geometry.js'; import { Path } from './path.js'; /** * Font flags */ export declare enum FontFlags { Bold = 1, Italic = 2, Serif = 4, Monospaced = 8, Embedded = 16 } /** * A PDF font */ export declare class Font { private _ctx?; private _font?; private _name; private _flags; private _bbox; private _ascender; private _descender; private _refCount; private _glyphs; private _encoding; constructor(name: string | null, flags?: number); /** * @internal Check if FFI bindings are available */ get hasNativeHandle(): boolean; /** * Create a new font */ static create(name: string, flags?: number): Font; /** * Create font from memory buffer using FFI * @throws Error when native bindings are not available */ static createFromMemory(name: string, data: Uint8Array): Font; /** * Create font from file using FFI * @throws Error when native bindings are not available */ static createFromFile(path: string): Font; keep(): this; drop(): void; /** * Clone this font */ clone(): Font; get name(): string; /** * Get font name (method alias for name property) */ getName(): string; /** * Check if font is bold */ isBold(): boolean; /** * Check if font is italic */ isItalic(): boolean; /** * Check if font is serif */ isSerif(): boolean; /** * Check if font is monospaced */ isMonospaced(): boolean; /** * Check if font is embedded */ isEmbedded(): boolean; /** * Get font flags */ get flags(): number; /** * Get font bounding box */ getBBox(): Rect; /** * Set font bounding box */ setBBox(bbox: RectLike): void; /** * Get font ascender (distance above baseline) */ getAscender(): number; /** * Set font ascender */ setAscender(ascender: number): void; /** * Get font descender (distance below baseline) */ getDescender(): number; /** * Set font descender */ setDescender(descender: number): void; /** * Get font bounding box (alias for getBBox) */ bbox(): Rect; /** * Get font ascender (alias for getAscender) */ ascender(): number; /** * Get font descender (alias for getDescender) */ descender(): number; /** * Encode a Unicode character to a glyph ID */ encodeCharacter(unicode: number): number; /** * Encode character with fallback */ encodeCharacterWithFallback(unicode: number, fallback?: number, _script?: number): number; /** * Set character encoding */ setEncoding(unicode: number, glyph: number): void; /** * Get glyph advance width */ advanceGlyph(glyph: number, wmode?: number | boolean): number; /** * Get glyph bounding box */ boundGlyph(glyph: number, _matrix?: unknown): Rect; /** * Get glyph outline as a path */ outlineGlyph(glyph: number, _matrix?: unknown): Path | null; /** * Get glyph name */ glyphName(glyph: number): string; /** * Add glyph info */ addGlyph(glyph: number, info: GlyphInfo): void; /** * Get glyph info */ getGlyphInfo(glyph: number): GlyphInfo | undefined; /** * Check if font is valid */ isValid(): boolean; /** * Measure text width */ measureText(text: string, size?: number): number; /** * Get text bounding box */ measureTextBounds(text: string, size?: number): Rect; } /** * Glyph information */ export interface GlyphInfo { name: string; advanceX: number; advanceY: number; bbox: Rect; outline?: Path; } /** * Font manager for loading and caching fonts */ export declare class FontManager { private _fonts; private _defaultFont; constructor(); /** * Get the singleton instance */ private static _instance; static getInstance(): FontManager; /** * Load a font by name */ loadFont(name: string): Font | null; /** * Register a font */ registerFont(name: string, font: Font): void; /** * Get default font */ getDefaultFont(): Font; /** * Set default font */ setDefaultFont(font: Font): void; /** * Get all registered font names */ getFontNames(): string[]; /** * Clear all fonts */ clear(): void; } /** * Standard PDF font names */ export declare const StandardFonts: { readonly TimesRoman: "Times-Roman"; readonly TimesBold: "Times-Bold"; readonly TimesItalic: "Times-Italic"; readonly TimesBoldItalic: "Times-BoldItalic"; readonly Helvetica: "Helvetica"; readonly HelveticaBold: "Helvetica-Bold"; readonly HelveticaOblique: "Helvetica-Oblique"; readonly HelveticaBoldOblique: "Helvetica-BoldOblique"; readonly Courier: "Courier"; readonly CourierBold: "Courier-Bold"; readonly CourierOblique: "Courier-Oblique"; readonly CourierBoldOblique: "Courier-BoldOblique"; readonly Symbol: "Symbol"; readonly ZapfDingbats: "ZapfDingbats"; }; //# sourceMappingURL=font.d.ts.map