harfbuzzjs
    Preparing search index...

    Class Buffer

    An object representing a HarfBuzz buffer. A buffer holds the input text and its properties before shaping, and the output glyphs and their information after shaping.

    Index

    Constructors

    Properties

    ptr: number

    Methods

    • Add code points to the buffer.

      Parameters

      • codePoints: number[]

        Array of code points to be added to the buffer.

      • itemOffset: number = 0

        The offset of the first code point to add to the buffer.

      • itemLength: number | null = null

        The number of code points to add to the buffer, or null for the end of the array.

      Returns void

    • Add text to the buffer.

      Parameters

      • text: string

        Text to be added to the buffer.

      • itemOffset: number = 0

        The offset of the first character to add to the buffer.

      • itemLength: number | null = null

        The number of characters to add to the buffer, or null for the end of text.

      Returns void

    • Similar to reset(), but does not clear the Unicode functions and the replacement code point.

      Returns void

    • Get the glyph information and positions from the buffer.

      Returns (GlyphInfo & Partial<GlyphPosition>)[]

      The glyph information and positions.

      The glyph information is returned as an array of objects with the properties from getGlyphInfos and getGlyphPositions combined.

    • Get the the number of items in the buffer.

      Returns number

      The buffer length.

    • Set buffer script, language and direction.

      This needs to be done before shaping.

      Returns void

    • Reset the buffer to its initial status.

      Returns void

    • Serialize the buffer contents to a string.

      Parameters

      • Optionalfont: Font | null

        The font to use for serialization.

      • start: number = 0

        The starting index of the glyphs to serialize.

      • Optionalend: number | null

        The ending index of the glyphs to serialize.

      • format: BufferSerializeFormat = BufferSerializeFormat.TEXT

        The BufferSerializeFormat to serialize the buffer contents to.

      • flags: number = 0

        A combination of BufferSerializeFlag values (OR them together).

      Returns string

      The serialized buffer contents.

    • Set the HarfBuzz clustering level.

      Affects the cluster values returned from shaping.

      Parameters

      • level: number

        Clustering level. See the HarfBuzz manual chapter on Clusters.

      Returns void

    • Set buffer flags explicitly.

      Parameters

      • flags: number

        A combination of BufferFlag values (OR them together).

      Returns void

    • Set buffer language explicitly.

      Parameters

      • language: string

        The buffer language

      Returns void

    • Set message func.

      Parameters

      • func: (buffer: Buffer, font: Font, message: string) => boolean

        The function to set. It receives the buffer, font, and message string as arguments. Returning false will skip this shaping step and move to the next one.

      Returns void

    • Set buffer script explicitly.

      Parameters

      • script: string

        The buffer script

      Returns void

    • Update the glyph positions in the buffer. WARNING: Do not use unless you know what you are doing.

      Parameters

      Returns void