pattern-x / gemini-viewer-examples

Examples and demos for gemini-viewer sdk, which is a WebGL based BIM model viewer, built on three.js. It is used to view dwg/dxf, gltf, obj, ifc models, etc.
205 stars 43 forks source link

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

Open ma12155506 opened 7 months ago

ma12155506 commented 7 months ago

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

yanzexuan1 commented 6 months ago

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

ma12155506 commented 6 months ago

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

yanzexuan1 commented 6 months ago

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;
}