Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ma12155506 opened this issue Apr 22, 2024 · 3 comments

Comments

@ma12155506
Copy link

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

@yanzexuan1
Copy link
Collaborator

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

@ma12155506
Copy link
Author

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

@yanzexuan1
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants