harfbuzzjs
    Preparing search index...

    Class Font

    An object representing a HarfBuzz font. A font represents a face at a specific size and with certain other parameters (pixels-per-em, variation settings) specified. Fonts are the primary input to the shaping process.

    Index

    Constructors

    Properties

    ptr: number

    Methods

    • Fetches the glyph ID for a Unicode code point in the specified font, with an optional variation selector.

      If variationSelector is 0, it is equivalent to Font.nominalGlyph; otherwise it is equivalent to Font.variationGlyph.

      Parameters

      • unicode: number

        The Unicode code point to query.

      • variationSelector: number = 0

        A variation-selector code point.

      Returns number | undefined

      The glyph ID, or undefined if not found.

    • Return glyph extents.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns GlyphExtents | undefined

      An object with xBearing, yBearing, width, and height, or undefined.

    • Return glyph ID from name.

      Parameters

      • name: string

        Name of the requested glyph in the font.

      Returns number | undefined

      The glyph ID, or undefined if not found.

    • Return glyph horizontal advance.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns number

      The horizontal advance width.

    • Return glyph horizontal origin.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns [number, number] | undefined

      [x, y] origin coordinates, or undefined if not available.

    • Return glyph name.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns string

      The glyph name string.

    • Return a glyph as an SVG path string.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns string

      SVG path data string.

    • Return glyph vertical advance.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns number

      The vertical advance height.

    • Return glyph vertical origin.

      Parameters

      • glyphId: number

        ID of the requested glyph in the font.

      Returns [number, number] | undefined

      [x, y] origin coordinates, or undefined if not available.

    • Fetches the nominal glyph ID for a Unicode code point in the specified font.

      This version of the function should not be used to fetch glyph IDs for code points modified by variation selectors. For variation-selector support, use Font.variationGlyph or Font.glyph.

      Parameters

      • unicode: number

        The Unicode code point to query.

      Returns number | undefined

      The glyph ID, or undefined if not found.

    • Set the font's scale factor, affecting the position values returned from shaping.

      Parameters

      • xScale: number

        Units to scale in the X dimension.

      • yScale: number

        Units to scale in the Y dimension.

      Returns void

    • Applies a list of font-variation settings to a font.

      Note that this overrides all existing variations set on the font. Axes not included in variations will be effectively set to their default values.

      Parameters

      • variations: Variation[]

        Array of variation settings to apply.

      Returns void

    • Create a sub font that inherits this font's properties.

      Returns Font

      A new Font object representing the sub font.

    • Fetches the glyph ID for a Unicode code point when followed by by the specified variation-selector code point, in the specified font.

      Parameters

      • unicode: number

        The Unicode code point to query.

      • variationSelector: number

        The variation-selector code point to query.

      Returns number | undefined

      The glyph ID, or undefined if not found.