Module harfbuzz

Lua bindings to Harfbuzz.

Info:

Functions

version () Wraps hb_version
shape (font, buffer[, options]) Wraps hb_shape.

Class Blob

Blob.new (data) Wraps hb_blob_create.
Blob:get_length () Wraps hb_blob_get_length.

Class Face

Face.new_from_blob (blob[, font_index=0]) Wraps hb_face_create.
Face.new (file[, font_index=0]) Create a new Face from a file.
Face:get_upem () Wraps hb_face_get_upem.

Class Font

Font:scale (face) Wraps hb_font_create, and sets up some defaults for scale and shaping functions.
Font:get_scale () Wraps hb_font_get_scale.
Font:set_scale (x_scale, y_scale) Wraps hb_font_set_scale.

Class Buffer

Buffer.new () Wraps hb_buffer_create.
Buffer:add_utf8 (text[, item_offset=0[, item_length=-1]]) Wraps hb_buffer_add_utf8.
Buffer:add_codepoints (text[, item_offset=0[, item_length=-1]]) Wraps hb_buffer_add_codepoints.
Buffer:set_direction (dir) Wraps hb_buffer_set_direction.
Buffer:get_direction () Wraps hb_buffer_get_direction.
Buffer:set_script (script) Wraps hb_buffer_set_script.
Buffer:get_script () Wraps hb_buffer_get_script.
Buffer:set_language (lang) Wraps hb_buffer_set_language.
Buffer:get_language () Wraps hb_buffer_get_language.
Buffer:reverse () Wraps hb_buffer_reverse.
Buffer:get_length () Wraps hb_buffer_get_length.
Buffer:get_cluster_level () Wraps hb_buffer_get_cluster_level.
Buffer:set_cluster_level (level) Wraps hb_buffer_set_cluster_level.
Buffer:guess_segment_properties () Wraps hb_buffer_guess_segment_properties.
Buffer:get_glyphs_and_positions () Helper method to get shaped glyph data.

Class Feature

Feature.new (feature_string) Wraps hb_feature_from_string
Feature:__tostring () Wraps hb_feature_to_string.

Cluster Levels

Buffer.HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
Buffer.HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS.
Buffer.HB_BUFFER_CLUSTER_LEVEL_CHARACTERS Wraps HB_BUFFER_CLUSTER_LEVEL_CHARACTERS.
Buffer.HB_BUFFER_CLUSTER_LEVEL_DEFAULT Wraps HB_BUFFER_CLUSTER_LEVEL_DEFAULT.


Functions

version ()
Wraps hb_version
shape (font, buffer[, options])
Wraps hb_shape.

Parameters:

  • font Font to use for shaping
  • buffer Buffer to shape
  • options

    table containing one or more supported options:

    (optional)

Class Blob

Lua wrapper for hb_blob_t type
Blob.new (data)
Wraps hb_blob_create. Initializes a new hb_blob_t.

Parameters:

  • data lua string containing binary or character data.
Blob:get_length ()
Wraps hb_blob_get_length.

Class Face

Lua wrapper for hb_face_t type
Face.new_from_blob (blob[, font_index=0])
Wraps hb_face_create. Initializes a new hb_face_t from a Blob object.

Parameters:

  • blob Blob to read the font from.
  • font_index index of font to read. (default 0)
Face.new (file[, font_index=0])
Create a new Face from a file. Makes a call to Face:new_from_blob after creating a Blob from the file contents.

Parameters:

  • file path to font file.
  • font_index index of font to read. (default 0)
Face:get_upem ()
Wraps hb_face_get_upem.

Class Font

Lua wrapper for hb_font_t type
Font:scale (face)
Wraps hb_font_create, and sets up some defaults for scale and shaping functions. Initializes a new hb_font_t from a Face object. Sets the default scale to the face’s upem value, and sets the font shaping functions by calling hb_ot_font_set_funcs on it.

Parameters:

  • face Face object. Wraps hb_font_get_scale
Font:get_scale ()
Wraps hb_font_get_scale.

Returns:

    two values for the x-scale and y-scale of the font.
Font:set_scale (x_scale, y_scale)
Wraps hb_font_set_scale.

Parameters:

  • x_scale desired x-scale of font.
  • y_scale desired y-scale of font.

Class Buffer

Lua wrapper for hb_buffer_t type.
Buffer.new ()
Wraps hb_buffer_create.
Buffer:add_utf8 (text[, item_offset=0[, item_length=-1]])
Wraps hb_buffer_add_utf8.

Parameters:

  • text UTF8 encoded string.
  • item_offset 0-indexed offset in text, from where to start adding. (default 0)
  • item_length length to add from item_offset. -1 adds till end of text. (default -1)
Buffer:add_codepoints (text[, item_offset=0[, item_length=-1]])
Wraps hb_buffer_add_codepoints.

Parameters:

  • text table with codepoints as lua numbers.
  • item_offset 0-indexed offset in text, from where to start adding. (default 0)
  • item_length length to add from item_offset. -1 adds till end of text. (default -1)
Buffer:set_direction (dir)
Wraps hb_buffer_set_direction.

Parameters:

  • dir one of rtl, ltr, ttb or btt.
Buffer:get_direction ()
Wraps hb_buffer_get_direction.
Buffer:set_script (script)
Wraps hb_buffer_set_script.

Parameters:

Buffer:get_script ()
Wraps hb_buffer_get_script.
Buffer:set_language (lang)
Wraps hb_buffer_set_language.

Parameters:

Buffer:get_language ()
Wraps hb_buffer_get_language.
Buffer:reverse ()
Wraps hb_buffer_reverse.
Buffer:get_length ()
Wraps hb_buffer_get_length.
Buffer:get_cluster_level ()
Wraps hb_buffer_get_cluster_level.

Returns:

    see Cluster Levels
Buffer:set_cluster_level (level)
Wraps hb_buffer_set_cluster_level.

Parameters:

Buffer:guess_segment_properties ()
Wraps hb_buffer_guess_segment_properties.
Buffer:get_glyphs_and_positions ()
Helper method to get shaped glyph data. Calls hb_buffer_get_glyph_infos and hb_buffer_get_glyph_positions and assembles the data into a Lua table.

Returns:

    table containing data for each glyph, in a nested table. Each nested table contains the following:

    • x_advance: horizontal advance.
    • y_advance: vertical advance.
    • x_offset: horizontal displacement.
    • y_offset: vertical displacement.
    • cluster: glyph cluster index within input.
    • codepoint: glyph index inside the font (this field name is a bit misleading, but that’s what Harfbuzz uses).

Class Feature

Lua wrapper for hb_feature_t type
Feature.new (feature_string)
Wraps hb_feature_from_string

Parameters:

Feature:__tostring ()
Wraps hb_feature_to_string. Enables nice output with tostring(…).

Cluster Levels

Buffer.HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES
Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
Buffer.HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS
Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS.
Buffer.HB_BUFFER_CLUSTER_LEVEL_CHARACTERS
Wraps HB_BUFFER_CLUSTER_LEVEL_CHARACTERS.
Buffer.HB_BUFFER_CLUSTER_LEVEL_DEFAULT
Wraps HB_BUFFER_CLUSTER_LEVEL_DEFAULT.
generated by LDoc 1.4.5 Last updated 2016-10-16 08:43:09