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

    Accessors

    Methods

    • Fetches a list of the caret positions defined for a ligature glyph in the GDEF table of the font.

      Note that a ligature that is formed from n characters will have n-1 caret positions. The first character is not represented in the array, since its caret position is the glyph position.

      The positions returned by this function are 'unshaped', and will have to be fixed up for kerning that may be applied to the ligature glyph.

      Parameters

      • direction: Direction

        The text direction to use.

      • glyph: number

        The glyph to query.

      Returns number[]

      An array of caret positions.

    • Fetches the optical bound of a glyph positioned at the margin of text. The direction identifies which edge of the glyph to query.

      Parameters

      • lookupIndex: number

        Index of the feature lookup to query.

      • direction: Direction

        Edge of the glyph to query.

      • glyph: number

        A glyph id.

      Returns number

      Adjustment value. Negative values mean the glyph will stick out of the margin.

    • Fetches metrics value corresponding to metricsTag from the font.

      Parameters

      • metricsTag: number

        MetricsTag of metrics value you like to fetch.

      Returns number | undefined

      The metrics value, or undefined if not found in the font.

    • Fetches metrics value corresponding to metricsTag from the font, and synthesizes a value if the value is missing in the font.

      Parameters

      • metricsTag: number

        MetricsTag of metrics value you like to fetch.

      Returns number

      The metrics value.

    • Fetches metrics value corresponding to metricsTag from the font with the current font variation settings applied.

      Parameters

      • metricsTag: number

        MetricsTag of metrics value you like to fetch.

      Returns number

      The requested metric value.

    • Fetches horizontal metrics value corresponding to metricsTag from the font with the current font variation settings applied.

      Parameters

      • metricsTag: number

        MetricsTag of metrics value you like to fetch.

      Returns number

      The requested metric value.

    • Fetches vertical metrics value corresponding to metricsTag from the font with the current font variation settings applied.

      Parameters

      • metricsTag: number

        MetricsTag of metrics value you like to fetch.

      Returns number

      The requested metric value.

    • 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.