Module harfbuzz
Lua bindings to Harfbuzz.
Info:
- Copyright: 2016
- License: MIT
- Author: Deepak Jois <deepak.jois@gmail.com>
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:
direction
: one ofrtl
,ltr
,ttb
orbtt
.script
: four-letter script tag.language
: three-letter language tag.features
: features to enable, specified as either of the following.- comma-separated list of features. See feature string syntax reference
- table of
Feature
objects
- font
Class Blob
Lua wrapper for
hb_blob_t
type
- Blob.new (data)
-
Wraps
hb_blob_create
. Initializes a newhb_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 newhb_face_t
from aBlob
object.Parameters:
- blob
Blob
to read the font from. - font_index index of font to read. (default 0)
- blob
- Face.new (file[, font_index=0])
-
Create a new
Face
from a file. Makes a call toFace:new_from_blob
after creating aBlob
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 newhb_font_t
from aFace
object. Sets the default scale to the face’s upem value, and sets the font shaping functions by callinghb_ot_font_set_funcs
on it.Parameters:
- face
Face
object. Wrapshb_font_get_scale
- face
- 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 oftext
. (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 oftext
. (default -1)
- Buffer:set_direction (dir)
-
Wraps
hb_buffer_set_direction
.Parameters:
- dir
one of
rtl
,ltr
,ttb
orbtt
.
- dir
one of
- Buffer:get_direction ()
-
Wraps
hb_buffer_get_direction
. - Buffer:set_script (script)
-
Wraps
hb_buffer_set_script
.Parameters:
- script four-letter script tag.
- 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:
- level see Cluster Levels
- 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
andhb_buffer_get_glyph_positions
and assembles the data into a Lua table.Returns:
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).
table containing data for each glyph, in a nested table. Each nested table contains the following:
Class Feature
Lua wrapper for
hb_feature_t
type
- Feature.new (feature_string)
-
Wraps
hb_feature_from_string
Parameters:
- feature_string See feature string syntax reference
- Feature:__tostring ()
-
Wraps
hb_feature_to_string
. Enables nice output withtostring(…)
.
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
.