import { ShxFontData } from './fontData'; import { ShxShape } from './shape'; /** * Scaling options for shape parsing */ export interface ScalingOptions { /** Scale by a uniform factor */ factor?: number; /** Scale by specific height and width */ height?: number; width?: number; } /** * Parses SHX font data into shapes on demand. To improve performance, the shape is parsed on demand by * character code and font size. Parsed shapes are cached. */ export declare class ShxShapeParser { /** Font data of the font file */ private readonly fontData; /** Cached top-level shapes (flush trailing pen-down strokes at shape end). */ private shapeCache; /** Cached subshape primitives (no end flush; parent may continue the stroke). */ private subshapeCache; /** Shapes data. Key is the char code */ private shapeData; constructor(fontData: ShxFontData); /** * Releases parsed shapes and cached shapes */ release(): void; /** * Parses a character's shape with the given font size. * @param code - The character code * @param size - The font size * @returns The parsed shape or undefined if the character is not found */ getCharShape(code: number, size: number): ShxShape | undefined; /** * Parses a character's shape with scaling options * @param code - The character code * @param options - Scaling options (factor or height/width) * @returns The parsed shape or undefined if the character is not found */ private parseAndScale; /** * Scales a shape according to the given scale factor * @param shape - The shape to scale * @param factor - The scale factor * @returns The scaled shape */ private scaleShapeByFactor; /** * Scales a shape according to the given height and width * @param shape - The shape to scale * @param height - The target height * @param width - The target width * @returns The scaled shape */ private scaleShapeByHeightAndWidth; /** * Parses the shape of a character. * @param data - The data of the character * @param options - Optional parse settings * @returns The parsed shape */ private parseShape; /** * Please refer to special codes reference in the following link for more information. * https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-06832147-16BE-4A66-A6D0-3ADF98DC8228 * @param command - The command byte * @param data - The data of the character * @param index - The index of the command byte * @param state - The state of the parser * @returns The index of the next command byte */ private handleSpecialCommand; private handleVectorCommand; /** * Get the vector for the given direction code. Please refer to the following link for more information. * https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-0A8E12A1-F4AB-44AD-8A9B-2140E0D5FD23 * @param dir - The direction code of the vector * @returns Returns the vector for the given direction code */ private getVectorForDirection; private handleSubshapeCommand; private handleXYDisplacement; private handleMultipleXYDisplacements; private handleOctantArc; private handleFractionalArc; private handleBulgeArc; private handleMultipleBulgeArcs; private skipCode; private getScaledSubshapeAtInsertPoint; /** * Handles drawing an arc segment with the given vector and bulge * @param currentPoint The starting point of the arc * @param vec The displacement vector * @param bulge The bulge value (will be normalized by 127.0) * @param scale The current scale factor * @param isPenDown Whether the pen is currently down (drawing) * @param currentPolyline The current polyline being built * @returns The new current point after the arc */ private handleArcSegment; }