class HbBuffer
The main structure holding the input text and its properties before shaping, and output glyphs and their information after shaping.
Lua wrapper for hb_buffer_t
type.
Reference:
- Corresponding C source code: luaharfbuzz.h#L15
- HarfBuzz online documentation: hb_buffer_t
😱 Types incomplete or incorrect? 🙏 Please contribute!
methods
HbBuffer.new
function HbBuffer.new() -> HbBuffer {
CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0,
CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1,
CLUSTER_LEVEL_CHARACTERS = 2,
CLUSTER_LEVEL_DEFAULT = 0,
GLYPH_FLAG_UNSAFE_TO_BREAK = 1,
GLYPH_FLAG_DEFINED = 3,
new = function,
add_utf8 = function,
add_codepoints = function,
set_direction = function,
get_direction = function,
set_script = function,
...(+9)
}
Create a new Buffer
object with all properties to defaults.
Wraps hb_buffer_create
.
Reference:
- Corresponding C source code: buffer.c#L3-L12
- HarfBuzz online documentation: hb_buffer_create
HbBuffer.add_utf8
@param
text
- UTF8 encoded string.
@param item_offset
- The offset of the first character to add to the buffer
.
@param item_length
- The number of characters to add to the buffer , or -1
for the end of text.
😱 Types incomplete or incorrect? 🙏 Please contribute!
Replace invalid UTF-8 characters with the buffer replacement code point.
Wraps hb_buffer_add_utf8
.
Reference:
- Corresponding C source code: buffer.c#L178-L191
- HarfBuzz online documentation: hb_buffer_add_utf8
HbBuffer.add_codepoints
@param
text
- with codepoints as lua numbers.
@param item_offset
- The offset of the first character to add to the buffer
.
@param item_length
- The number of characters to add to the buffer , or -1
for the end of text.
😱 Types incomplete or incorrect? 🙏 Please contribute!
Appends characters from text array to buffer .
The item_offset
is the position of the first character from text that will be appended, and item_length
is the number of character. When shaping part of a larger text (e.g. a run of text from a paragraph), instead of passing just the substring corresponding to the run, it is preferable to pass the whole paragraph and specify the run start and length as item_offset
and item_length
, respectively, to give HarfBuzz the full context to be able, for example, to do cross-run Arabic shaping or properly handle combining marks at stat of run.
This function does not check the validity of text
, it is up to the caller to ensure it contains a valid Unicode scalar values. In contrast, Buffer:add_utf8()
can be used that takes similar input but performs sanity-check on the input.
Wraps hb_buffer_add_codepoints
.
Reference:
- Corresponding C source code: buffer.c#L137-L162
- HarfBuzz online documentation: hb_buffer_add_codepoints
@see HbBuffer.add_utf8
HbBuffer.set_direction
function HbBuffer.set_direction(dir: HbDirection {
LTR = integer?,
RTL = integer?,
TTB = integer?,
BTT = integer?,
new = function,
__to_string = function,
__eq = function,
is_valid = function,
is_horizontal = function,
is_vertical = function,
is_forward = function,
is_backward = function,
...(+0)
})
dir
- A Direction
object.
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_set_direction
.
Reference:
- Corresponding C source code: buffer.c#L32-L38
- HarfBuzz online documentation: hb_buffer_set_direction
HbBuffer.get_direction
function HbBuffer.get_direction() -> HbDirection {
LTR = integer?,
RTL = integer?,
TTB = integer?,
BTT = integer?,
new = function,
__to_string = function,
__eq = function,
is_valid = function,
is_horizontal = function,
is_vertical = function,
is_forward = function,
is_backward = function,
...(+0)
}
@return - A Direction
object.
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_get_direction
.
Reference:
- Corresponding C source code: buffer.c#L21-L30
- HarfBuzz online documentation: hb_buffer_get_direction
HbBuffer.set_script
function HbBuffer.set_script(script: HbScript {
COMMON = string,
INHERITED = string,
UNKNOWN = string,
INVALID = string,
new = function,
from_iso15924_tag = function,
to_iso15924_tag = function,
__to_string = function,
__eq = function,
})
script
- A Script
object.
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_set_script
.
Reference:
- Corresponding C source code: buffer.c#L86-L92
- HarfBuzz online documentation: hb_buffer_set_script
HbBuffer.get_script
function HbBuffer.get_script() -> HbScript {
COMMON = string,
INHERITED = string,
UNKNOWN = string,
INVALID = string,
new = function,
from_iso15924_tag = function,
to_iso15924_tag = function,
__to_string = function,
__eq = function,
}
@return - A Script
object.
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_get_script
.
Reference:
- Corresponding C source code: buffer.c#L75-L84
- HarfBuzz online documentation: hb_buffer_get_script
HbBuffer.set_language
function HbBuffer.set_language(lang: HbLanguage {
INVALID = HbLanguage,
new = function,
__tostring = function,
__eq = function,
})
lang
- A Language
object
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_set_language
.
Reference:
- Corresponding C source code: buffer.c#L67-L73
- HarfBuzz online documentation: hb_buffer_set_language
HbBuffer.get_language
function HbBuffer.get_language() -> HbLanguage {
INVALID = HbLanguage,
new = function,
__tostring = function,
__eq = function,
}
@return - A Language
object
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_get_language
.
Reference:
- Corresponding C source code: buffer.c#L56-L65
- HarfBuzz online documentation: hb_buffer_get_language
HbBuffer.reverse
Wraps hb_buffer_reverse
.
Reference:
- Corresponding C source code: buffer.c#L247-L252
- HarfBuzz online documentation: hb_buffer_reverse
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.get_length
Wraps hb_buffer_get_length
.
Reference:
- Corresponding C source code: buffer.c#L254-L259
- HarfBuzz online documentation: hb_buffer_get_length
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.get_cluster_level
@return level
- see Cluster Levels
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_get_cluster_level
.
Reference:
- Corresponding C source code: buffer.c#L261-L266
- HarfBuzz online documentation: hb_buffer_get_cluster_level
HbBuffer.set_cluster_level
@param
level
- see Cluster Levels
😱 Types incomplete or incorrect? 🙏 Please contribute!
Wraps hb_buffer_set_cluster_level
.
Reference:
- Corresponding C source code: buffer.c#L268-L275
- HarfBuzz online documentation: hb_buffer_set_cluster_level
HbBuffer.guess_segment_properties
Wraps hb_buffer_guess_segment_properties
.
Reference:
- Corresponding C source code: buffer.c#L14-L19
- HarfBuzz online documentation: hb_buffer_guess_segment_properties
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.get_glyphs
Helper method to get shaped glyph data.
Calls hb_buffer_get_glyph_infos
, hb_buffer_get_glyph_positions
and
hb_glyph_info_get_glyph_flags
, and assembles the data into a Lua table.
Reference:
- HarfBuzz online documentation: hb_buffer_get_glyph_infos
fields
HbBuffer.CLUSTER_LEVEL_MONOTONE_GRAPHEMES
Cluster Levels. See Harfbuzz docs for more details about what each of these levels mean.
Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES
.
Reference:
- HarfBuzz online documentation: hb_buffer_cluster_level_t
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.CLUSTER_LEVEL_MONOTONE_CHARACTERS
Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS
.
Reference:
- HarfBuzz online documentation: hb_buffer_cluster_level_t
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.CLUSTER_LEVEL_CHARACTERS
Wraps HB_BUFFER_CLUSTER_LEVEL_CHARACTERS
.
Reference:
- HarfBuzz online documentation: hb_buffer_cluster_level_t
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.CLUSTER_LEVEL_DEFAULT
Wraps HB_BUFFER_CLUSTER_LEVEL_DEFAULT
.
Reference:
- HarfBuzz online documentation: hb_buffer_cluster_level_t
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.GLYPH_FLAG_UNSAFE_TO_BREAK
Wraps HB_GLYPH_FLAG_UNSAFE_TO_BREAK
.
Reference:
- HarfBuzz online documentation: hb_glyph_flags_t
😱 Types incomplete or incorrect? 🙏 Please contribute!
HbBuffer.GLYPH_FLAG_DEFINED
Wraps HB_GLYPH_FLAG_DEFINED
.
Reference:
- HarfBuzz online documentation: hb_glyph_flags_t
😱 Types incomplete or incorrect? 🙏 Please contribute!