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

    • Internal

      Parameters

      • OptionalexistingPtr: number

        Wrap an existing buffer pointer.

      Returns Buffer

    Properties

    ptr: number

    Methods

    • Appends a character with the Unicode value of codePoint to the buffer, and gives it the initial cluster value of cluster. Clusters can be any thing the client wants, they are usually used to refer to the index of the character in the input text stream and are output in the cluster field of GlyphInfo.

      This function does not check the validity of codePoint, it is up to the caller to ensure it is a valid Unicode code point.

      Parameters

      • codePoint: number

        A Unicode code point.

      • cluster: number

        The cluster value of codePoint.

      Returns void

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

      • OptionalitemLength: number

        The number of code points to add to the buffer, or omit 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.

      • OptionalitemLength: number

        The number of characters to add to the buffer, or omit 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

      • options: { end?: number; flags?: number; font?: Font; format?: number; start?: number } = {}

        Serialization options:

        • font: the font to use for serialization;
        • start: the starting index of the glyphs (default 0);
        • end: the ending index of the glyphs (default end of buffer);
        • format: a BufferSerializeFormat value (default TEXT);
        • flags: a combination of BufferSerializeFlag values (default 0).

      Returns string

      The serialized buffer contents.

    • 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