@mlightcad/shx-parser
Version:
A TypeScript library for parsing AutoCAD SHX font files
31 lines (30 loc) • 1.36 kB
TypeScript
import { ShxFontData } from './fontData';
/**
* Represents a SHX font and provides methods to parse and render its characters.
* This class handles the loading and parsing of SHX font files, and provides
* methods to extract character shapes for rendering.
*/
export declare class ShxFont {
/** The parsed font data containing header and content information */
readonly fontData: ShxFontData;
/** Parser for converting character codes to shapes */
private readonly shapeParser;
/**
* Creates a new ShxFont instance.
* @param data - Either raw binary data of the SHX font file (ArrayBuffer) or pre-parsed font data (ShxFontData)
* @throws {Error} If the font data is invalid or cannot be parsed
*/
constructor(data: ShxFontData | ArrayBuffer);
/**
* Gets the shape data for a specific character at a given size.
* @param code - The character code to get the shape for
* @param size - The desired size of the character in drawing units
* @returns The shape data for the character, or undefined if the character is not found in the font
*/
getCharShape(code: number, size: number): import("./shape").ShxShape | undefined;
/**
* Releases resources used by the font.
* This should be called when the font is no longer needed to free up memory.
*/
release(): void;
}