gemini-viewer-examples icon indicating copy to clipboard operation
gemini-viewer-examples copied to clipboard

How does the dxf shx font file handle display? Do you have any tips or codes related to this

Open ma12155506 opened this issue 1 year ago • 3 comments

How does the dxf shx font file handle display? Do you have any tips or codes related to this

ma12155506 avatar Apr 22 '24 02:04 ma12155506

Shx font file will be parsed to line segments then display. Is this what you want to know?

yanzexuan1 avatar Apr 26 '24 00:04 yanzexuan1

I want to use the shx parse library or code ...

ma12155506 avatar Apr 26 '24 04:04 ma12155506

The viewer sets font files like this:

const fontFiles = ["libs/fonts/simplex.shx", "libs/fonts/hztxt.shx"];
await viewer.setFont(fontFiles);

You can find some code from https://www.npmjs.com/package/@pattern-x/gemini-viewer-threejs?activeTab=code

image

export declare class ShxFont extends BaseFont {
    isExtend: boolean;
    isUniCode: boolean;
    isEmbedded: boolean;
    static DEFAULT_SIZE: number;
    fontType: ShxFontType;
    private textShapesCache;
    private graphicData;
    constructor(fileName: string, fileData: ArrayBuffer | FontDataTableRecord);
    generateShapes(text: string, size: number): TextShape[];
    /**
     * Gets TextShape by a char
     */
    getCharShape(char: string, size: number): TextShape | undefined;
    /**
     * Gets TextShape by a char code
     */
    getGraphicDataByCode(code: number, size: number): TextShape | undefined;
    /**
     * Gets TextShape by char's code, font size and offset
     */
    getGraphicDataByCodeWithOffset(code: number, size: number, translate: THREE.Vector2): TextShape | undefined;
    private parseBigFont;
    private parseUniFont;
    private parseShapeFont;
    /**
     * For an unsupported char, use "?" as a replacement.
     */
    getNotFoundTextShape(size: number): TextShape | undefined;
    protected getFontFile(): {
        fontType: ShxFontType;
        order: number;
        data: any;
        info: string;
        orientation: import("./shx/Shx.constants").Orientation;
        baseUp: number;
        baseDown: number;
        fileName: string;
        fileHeader: string;
        fileVersion: string;
    };
    setFontFile(data: FontDataTableRecord): void;
    releaseFontData(): void;
}

yanzexuan1 avatar Apr 26 '24 09:04 yanzexuan1