MLightCAD
    Preparing search index...

    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.

    Index

    Constructors

    • Creates a new ShxFont instance.

      Parameters

      • data: ArrayBuffer | ShxFontData

        Either raw binary data of the SHX font file (ArrayBuffer) or pre-parsed font data (ShxFontData)

      Returns ShxParserFont

      If the font data is invalid or cannot be parsed

    Properties

    fontData: ShxFontData

    The parsed font data containing header and content information

    Methods

    • Gets the scaled shape geometry for a character code.

      Returns the glyph as encoded in the SHX file, scaled to size. Vertical placement and mixed-font baseline alignment are the responsibility of the text renderer; see the textLayout module and ShxFont.getFontMetrics.

      Parameters

      • code: number

        The character code to get the shape for

      • size: number

        The desired font size

      Returns ShxShape | undefined

      The shape data for the character, or undefined if the character is not found in the font

    • Returns scaled font metrics for a target render size.

      Parameters

      • size: number

        Target font size in drawing units

      Returns ShxFontMetrics

    • Returns a layout-ready glyph: scaled geometry with baseline alignment applied.

      Prefer this over ShxFont.getCharShape when placing text for display.

      Parameters

      • code: number

        The character code to get the shape for

      • size: number

        The desired font size

      • OptionaladvanceStrategy: ShxAdvanceWidthStrategy

      Returns ShxShape | undefined

    • Gets the shape data for a named shape at a given font size. Shape names are matched case-insensitively.

      Parameters

      • name: string

        The shape name to get the shape for

      • size: number

        The desired font size

      Returns ShxShape | undefined

      The shape data for the named shape, or undefined if it is not found in the font

    • Gets the character code for a named shape.

      Parameters

      • name: string

        The shape name to look up

      Returns number | undefined

      The character code, or undefined if the shape is not found

    • Gets the shape name for a character code, if one is defined.

      Parameters

      • code: number

        The character code to look up

      Returns string | undefined

      The shape name, or undefined if the code has no name

    • Return true if this font contains glyph of the specified character. Otherwise, return false.

      Parameters

      • code: number

      Returns boolean

      True if this font contains glyph of the specified character. Otherwise, return false.

    • Return true if this font contains a shape with the specified name. Otherwise, return false. Shape names are matched case-insensitively.

      Parameters

      • name: string

        The shape name to check (for example, "GRS")

      Returns boolean

      True if this font contains the named shape. Otherwise, return false.

    • Releases resources used by the font. This should be called when the font is no longer needed to free up memory.

      Returns void