diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index aed9ee8..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Deepak Jois - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/README.md b/README.md deleted file mode 100644 index 18fd0f5..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# luaharfbuzz -Harfbuzz bindings for Lua diff --git a/examples/core_types.lua.html b/examples/core_types.lua.html new file mode 100644 index 0000000..cca3b9e --- /dev/null +++ b/examples/core_types.lua.html @@ -0,0 +1,113 @@ + + + + + luaharfbuzz Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

core_types.lua

+
+local harfbuzz = require('harfbuzz')
+local serpent  = require('serpent') -- luarocks install serpent
+
+-- Harfbuzz API Version
+print("Harfbuzz API version", harfbuzz.version())
+
+-- Shapers available
+print("Shapers:", serpent.line({ harfbuzz.shapers() }, {comment = false}))
+
+-- harfbuzz.Face
+local face = harfbuzz.Face.new('../fonts/notonastaliq.ttf')
+print('\nFace upem = '..face:get_upem())
+
+-- harfbuzz.Font
+local font = harfbuzz.Font.new(face)
+local xs, xy = font:get_scale()
+print("\nDefault font scale = X: "..xs..", Y: "..xy)
+
+-- harfbuzz.Buffer
+local text = "یہ" -- U+06CC U+06C1
+local buf = harfbuzz.Buffer.new()
+buf:add_utf8(text)
+
+-- harfbuzz.shape (Shapes text)
+print("\nShaping '"..text.."' set with Noto Nastaliq Urdu")
+harfbuzz.shape(font, buf, { language = harfbuzz.Language.new("urd"), script = harfbuzz.Script.new("Arab"), direction = harfbuzz.Direction.RTL})
+
+local glyphs = buf:get_glyphs()
+print("No. of glyphs", #glyphs)
+print(serpent.line(glyphs, {comment = false}))
+
+local opts = { language = harfbuzz.Language.new("eng"), script = harfbuzz.Script.new("Latn"), direction = harfbuzz.Direction.LTR }
+local amiri_face = harfbuzz.Face.new('../fonts/amiri-regular.ttf')
+local amiri_font = harfbuzz.Font.new(amiri_face)
+
+-- shaping '123' w/o features
+print("\nShaping '123' set with Amiri Regular and no features")
+buf= harfbuzz.Buffer.new()
+buf:add_utf8("123")
+harfbuzz.shape(amiri_font, buf, opts)
+glyphs = buf:get_glyphs()
+print(serpent.line(glyphs, {comment = false}))
+
+-- shaping '123' with '+numr' (numerators)
+print("\nShaping '123' set with Amiri Regular with 'numr' feature turned on")
+buf= harfbuzz.Buffer.new()
+buf:add_utf8("123")
+opts.features = "+numr"
+harfbuzz.shape(amiri_font, buf, opts)
+glyphs = buf:get_glyphs()
+print(serpent.line(glyphs, {comment = false}))
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2026-06-23 14:19:38 +
+
+ + diff --git a/index.html b/index.html new file mode 100644 index 0000000..6850802 --- /dev/null +++ b/index.html @@ -0,0 +1,78 @@ + + + + + luaharfbuzz Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ + +

Lua bindings to Harfbuzz

+

The documentation is available at https://github.com/harfbuzz/luaharfbuzz/wiki

+ +

Modules

+ + + + + + + + + +
harfbuzzLua bindings to Harfbuzz.
harfbuzzsubsetLua bindings to the Harfbuzz subset API.
+

Examples

+ + + + + +
core_types.lua
+ +
+
+
+generated by LDoc 1.5.0 +Last updated 2026-06-23 14:19:38 +
+
+ + diff --git a/ldoc.css b/ldoc.css new file mode 100644 index 0000000..f945ae7 --- /dev/null +++ b/ldoc.css @@ -0,0 +1,304 @@ +/* BEGIN RESET + +Copyright (c) 2010, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.8.2r1 +*/ +html { + color: #000; + background: #FFF; +} +body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { + margin: 0; + padding: 0; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +fieldset,img { + border: 0; +} +address,caption,cite,code,dfn,em,strong,th,var,optgroup { + font-style: inherit; + font-weight: inherit; +} +del,ins { + text-decoration: none; +} +li { + margin-left: 20px; +} +caption,th { + text-align: left; +} +h1,h2,h3,h4,h5,h6 { + font-size: 100%; + font-weight: bold; +} +q:before,q:after { + content: ''; +} +abbr,acronym { + border: 0; + font-variant: normal; +} +sup { + vertical-align: baseline; +} +sub { + vertical-align: baseline; +} +legend { + color: #000; +} +input,button,textarea,select,optgroup,option { + font-family: inherit; + font-size: inherit; + font-style: inherit; + font-weight: inherit; +} +input,button,textarea,select {*font-size:100%; +} +/* END RESET */ + +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color: #ffffff; margin: 0px; +} + +code, tt { font-family: monospace; font-size: 1.1em; } +span.parameter { font-family:monospace; } +span.parameter:after { content:":"; } +span.types:before { content:"("; } +span.types:after { content:")"; } +.type { font-weight: bold; font-style:italic } + +body, p, td, th { font-size: .95em; line-height: 1.2em;} + +p, ul { margin: 10px 0 0 0px;} + +strong { font-weight: bold;} + +em { font-style: italic;} + +h1 { + font-size: 1.5em; + margin: 20px 0 20px 0; +} +h2, h3, h4 { margin: 15px 0 10px 0; } +h2 { font-size: 1.25em; } +h3 { font-size: 1.15em; } +h4 { font-size: 1.06em; } + +a:link { font-weight: bold; color: #004080; text-decoration: none; } +a:visited { font-weight: bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration: underline; } + +hr { + color:#cccccc; + background: #00007f; + height: 1px; +} + +blockquote { margin-left: 3em; } + +ul { list-style-type: disc; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; +} + +pre { + background-color: rgb(245, 245, 245); + border: 1px solid #C0C0C0; /* silver */ + padding: 10px; + margin: 10px 0 10px 0; + overflow: auto; + font-family: "Andale Mono", monospace; +} + +pre.example { + font-size: .85em; +} + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } + +#container { + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product { + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#main { + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation { + float: left; + width: 14em; + vertical-align: top; + background-color: #f0f0f0; + overflow: visible; +} + +#navigation h2 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align: left; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + margin: 1px 1px 10px 1px; +} + +#navigation li { + text-indent: -1em; + display: block; + margin: 3px 0px 0px 22px; +} + +#navigation li li a { + margin: 0px 3px 0px -1em; +} + +#content { + margin-left: 14em; + padding: 1em; + width: 700px; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about { + clear: both; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight: bold; color: #004080; text-decoration: underline; } + + #main { + background-color: #ffffff; + border-left: 0px; + } + + #container { + margin-left: 2%; + margin-right: 2%; + background-color: #ffffff; + } + + #content { + padding: 1em; + background-color: #ffffff; + } + + #navigation { + display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.module_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.module_list td.summary { width: 100%; } + + +table.function_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.function_list td.summary { width: 100%; } + +ul.nowrap { + overflow:auto; + white-space:nowrap; +} + +dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} +dl.table h3, dl.function h3 {font-size: .95em;} + +/* stop sublists from having initial vertical space */ +ul ul { margin-top: 0px; } +ol ul { margin-top: 0px; } +ol ol { margin-top: 0px; } +ul ol { margin-top: 0px; } + +/* make the target distinct; helps when we're navigating to a function */ +a:target + * { + background-color: #FF9; +} + + +/* styles for prettification of source */ +pre .comment { color: #558817; } +pre .constant { color: #a8660d; } +pre .escape { color: #844631; } +pre .keyword { color: #aa5050; font-weight: bold; } +pre .library { color: #0e7c6b; } +pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } +pre .string { color: #8080ff; } +pre .number { color: #f8660d; } +pre .function-name { color: #60447f; } +pre .operator { color: #2239a8; font-weight: bold; } +pre .preprocessor, pre .prepro { color: #a33243; } +pre .global { color: #800080; } +pre .user-keyword { color: #800080; } +pre .prompt { color: #558817; } +pre .url { color: #272fc2; text-decoration: underline; } + diff --git a/modules/harfbuzz.html b/modules/harfbuzz.html new file mode 100644 index 0000000..483e0b6 --- /dev/null +++ b/modules/harfbuzz.html @@ -0,0 +1,4188 @@ + + + + + luaharfbuzz Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

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.new_from_file (filename)Wraps hb_blob_create_from_file.
Blob:get_length ()Wraps hb_blob_get_length.
Blob:get_data ()Wraps hb_blob_get_data.
+

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:blob ()Wraps hb_face_reference_blob.
Face:get_name (name_id[, lang])Wraps hb_ot_name_get_utf8.
Face:collect_unicodes ()Wraps hb_face_collect_unicodes.
Face:get_glyph_count ()Wraps hb_face_get_glyph_count.
Face:get_table (tag)Wraps hb_face_reference_table.
Face:get_table_tags ()Wraps hb_face_get_table_tags.
Face:get_upem ()Wraps hb_face_get_upem.
Face:ot_color_has_palettes ()Wraps hb_ot_color_has_palettes.
Face:ot_color_palette_get_count ()Wraps hb_ot_color_palette_get_count.
Face:ot_color_palette_get_colors ([palette_index=1])Wraps hb_ot_color_palette_get_colors.
Face:ot_color_has_layers ()Wraps hb_ot_color_has_layers.
Face:ot_color_glyph_get_layers (glyph)Wraps hb_ot_color_glyph_get_layers.
Face:ot_color_has_png ()Wraps hb_ot_color_has_png.
Face:ot_color_has_svg ()Wraps hb_ot_color_has_svg.
Face:ot_color_glyph_get_svg (glyph)Wraps hb_ot_color_glyph_reference_svg.
Face:ot_var_has_data ()Wraps hb_ot_var_has_data.
Face:ot_var_find_axis_info (tag)Wraps hb_ot_var_find_axis_info.
Face:ot_var_get_axis_infos ([start=1[, stop=-1]])Wraps hb_ot_var_get_axis_infos.
Face:ot_var_named_instance_get_infos ([start=1[, stop=-1]])Wraps hb_ot_var_get_named_instance_count and related functions.
Face:ot_var_named_instance_get_design_coords (index)Wraps hb_ot_var_named_instance_get_design_coords.
Face:ot_var_normalize_variations (...)Wraps hb_ot_var_normalize_variations.
Face:ot_var_normalize_coords (...)Wraps hb_ot_var_normalize_coords.
Face:ot_layout_get_script_tags (table_tag)Wraps hb_ot_layout_table_get_script_tags.
Face:ot_layout_get_language_tags (table_tag, script_index)Wraps hb_ot_layout_script_get_language_tags.
Face:ot_layout_get_feature_tags (table_tag, script_index, language_index)Wraps hb_ot_layout_language_get_feature_tags.
Face:ot_layout_find_script (table_tag, script_tag)Wraps hb_ot_layout_table_find_script.
Face:ot_layout_find_language (table_tag, script_index, language_tag)Wraps hb_ot_layout_script_find_language.
Face:ot_layout_find_feature (table_tag, script_index, language_index, feature_tag)Wraps hb_ot_layout_language_find_feature.
+

Class Font

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Font.new (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.
Font:get_h_extents ()Wraps hb_font_get_h_extents.
Font:get_v_extents ()Wraps hb_font_get_v_extents.
Font:get_glyph_extents (glyph)Wraps hb_font_get_glyph_extents.
Font:get_glyph_name (glyph)Wraps hb_font_get_glyph_name.
Font:get_glyph_from_name (name)Wraps hb_font_get_glyph_from_name.
Font:get_glyph_h_advance (glyph)Wraps hb_font_get_glyph_h_advance.
Font:get_glyph_v_advance (glyph)Wraps hb_font_get_glyph_v_advance.
Font:get_nominal_glyph (codepoint.)Wraps hb_font_get_nominal_glyph.
Font:style_get_value (tag)Wraps hb_style_get_value.
Font:ot_color_glyph_get_png (glyph)Wraps hb_ot_color_glyph_get_png.
Font:ot_metrics_get_position (tag)Wraps hb_ot_metrics_get_position.
Font:ot_metrics_get_variation (tag)Wraps hb_ot_metrics_get_variation.
Font:ot_metrics_get_x_variation (tag)Wraps hb_ot_metrics_get_x_variation.
Font:ot_metrics_get_y_variation (tag)Wraps hb_ot_metrics_get_y_variation.
Font:set_variations (...)Wraps hb_font_set_variations.
Font:set_var_coords_design (...)Wraps hb_font_set_var_coords_design.
Font:set_var_coords_normalized (...)Wraps hb_font_set_var_coords_normalized.
Font:set_var_named_instance (index)Wraps hb_font_set_var_named_instance.
Font:get_var_coords_normalized ()Wraps hb_font_get_var_coords_normalized.
+

Class Buffer

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Buffer.new ()Wraps hb_buffer_create.
Buffer:add (codepoint, cluster)Wraps hb_buffer_add.
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:set_flags (flags)Wraps hb_buffer_set_flags.
Buffer:get_flags ()Wraps hb_buffer_get_flags.
Buffer:set_cluster_level (level)Wraps hb_buffer_set_cluster_level.
Buffer:get_cluster_level ()Wraps hb_buffer_get_cluster_level.
Buffer:set_invisible_glyph (glyph)Wraps hb_buffer_set_invisible_glyph.
Buffer:get_invisible_glyph ()Wraps hb_buffer_get_invisible_glyph.
Buffer:set_replacement_codepoint (codepoint)Wraps hb_buffer_set_replacement_codepoint.
Buffer:get_replacement_codepoint ()Wraps hb_buffer_get_replacement_codepoint.
Buffer:get_length ()Wraps hb_buffer_get_length.
Buffer:guess_segment_properties ()Wraps hb_buffer_guess_segment_properties.
Buffer:reverse ()Wraps hb_buffer_reverse.
Buffer:clear_contents ()Wraps hb_buffer_clear_contents.
Buffer:reset ()Wraps hb_buffer_reset.
Buffer:pre_allocate (size)Wraps hb_buffer_pre_allocate.
Buffer:get_glyphs ()Helper method to get shaped glyph data.
+

Cluster Levels

+ + + + + + + + + + + + + + + + + +
Buffer.CLUSTER_LEVEL_MONOTONE_GRAPHEMESWraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
Buffer.CLUSTER_LEVEL_MONOTONE_CHARACTERSWraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS.
Buffer.CLUSTER_LEVEL_CHARACTERSWraps HB_BUFFER_CLUSTER_LEVEL_CHARACTERS.
Buffer.CLUSTER_LEVEL_DEFAULTWraps HB_BUFFER_CLUSTER_LEVEL_DEFAULT.
+

Buffer Flags

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Buffer.FLAG_DEFAULTWraps HB_BUFFER_FLAG_DEFAULT.
Buffer.FLAG_BOTWraps HB_BUFFER_FLAG_BOT.
Buffer.FLAG_EOTWraps HB_BUFFER_FLAG_EOT.
Buffer.FLAG_PRESERVE_DEFAULT_IGNORABLESWraps HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES.
Buffer.FLAG_REMOVE_DEFAULT_IGNORABLESWraps HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.
Buffer.FLAG_DO_NOT_INSERT_DOTTED_CIRCLEWraps HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE.
Buffer.FLAG_VERIFYWraps HB_BUFFER_FLAG_VERIFY.
Buffer.FLAG_PRODUCE_UNSAFE_TO_CONCATWraps HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT.
Buffer.FLAG_PRODUCE_SAFE_TO_INSERT_TATWEELWraps HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL.
Buffer.FLAG_DEFINEDWraps HB_BUFFER_FLAG_DEFINED.
+

Glyph Flags

+ + + + + + + + + + + + + + + + + +
Buffer.GLYPH_FLAG_UNSAFE_TO_BREAKWraps HB_GLYPH_FLAG_UNSAFE_TO_BREAK.
Buffer.GLYPH_FLAG_UNSAFE_TO_CONCATWraps HB_GLYPH_FLAG_UNSAFE_TO_CONCAT.
Buffer.GLYPH_FLAG_SAFE_TO_INSERT_TATWEELWraps HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL.
Buffer.GLYPH_FLAG_DEFINEDWraps HB_GLYPH_FLAG_DEFINED.
+

Class Feature

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

Class Variation

+ + + + + + + + + +
Variation.new (variation_string)Wraps hb_variation_from_string.
Variation:__tostring ()Wraps hb_variation_to_string.
+

Class Tag

+ + + + + + + + + + + + + +
Tag.new (string)Wraps hb_tag_from_string.
Tag:__tostring ()Wraps hb_tag_to_string.
Tag:__eq ()Enables equality comparisions with == between two tags.
+

Class Script

+ + + + + + + + + + + + + + + + + + + + + +
Script.new (script)Wraps hb_script_from_string.
Script.from_iso15924_tag (tag)Wraps hb_script_from_iso15924_tag
Script:to_iso15924_tag ()Wraps hb_script_to_iso15924_tag.
Script:__tostring ()Enable nice output with tostring(…)
Script:__eq ()Enables equality comparisions with == between two scripts.
+

Predefined Script Codes

+ + + + + + + + + + + + + + + + + +
Script.COMMONWraps HB_SCRIPT_COMMON.
Script.INHERITEDWraps HB_SCRIPT_INHERITED.
Script.UNKNOWNWraps HB_SCRIPT_UNKNOWN.
Script.INVALIDWraps HB_SCRIPT_INVALID.
+

Class Direction

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Direction.new (dir)Wraps hb_direction_from_string.
Direction:__tostring ()Wraps hb_direction_to_string.
Direction:__eq ()Enables equality comparisions with == between two directions.
Direction:is_valid ()Wraps HB_DIRECTION_IS_VALID.
Direction:is_horizontal ()Wraps HB_DIRECTION_IS_HORIZONTAL.
Direction:is_vertical ()Wraps HB_DIRECTION_IS_VERTICAL.
Direction:is_forward ()Wraps HB_DIRECTION_IS_FORWARD.
Direction:is_backward ()Wraps HB_DIRECTION_IS_BACKWARD.
+

Predefined directions

+ + + + + + + + + + + + + + + + + +
Direction.LTRWraps HB_DIRECTION_LTR.
Direction.RTLWraps HB_DIRECTION_RTL.
Direction.TTBWraps HB_DIRECTION_TTB.
Direction.BTTWraps HB_DIRECTION_LTR.
+

Class Language

+ + + + + + + + + + + + + +
Language.new (lang)Wraps hb_language_from_string.
Language:__tostring ()Wraps hb_language_to_string.
Language:__eq ()Enables equality comparisions with == between two languages.
+

Predefined languages

+ + + + + +
Language.INVALIDWraps HB_LANGUAGE_INVALID.
+

Class Set

+ + + + + +
Set:add (codepoint)Wraps hb_set_add.
+

Unicode functions

+ + + + + +
unicode.script (char)Wraps hb_unicode_script
+

Predefined Name IDs

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ot.NAME_ID_COPYRIGHTWraps HB_OT_NAME_ID_COPYRIGHT
ot.NAME_ID_FONT_FAMILYWraps HB_OT_NAME_ID_FONT_FAMILY
ot.NAME_ID_FONT_SUBFAMILYWraps HB_OT_NAME_ID_FONT_SUBFAMILY
ot.NAME_ID_UNIQUE_IDWraps HB_OT_NAME_ID_UNIQUE_ID
ot.NAME_ID_FULL_NAMEWraps HB_OT_NAME_ID_FULL_NAME
ot.NAME_ID_VERSION_STRINGWraps HB_OT_NAME_ID_VERSION_STRING
ot.NAME_ID_POSTSCRIPT_NAMEWraps HB_OT_NAME_ID_POSTSCRIPT_NAME
ot.NAME_ID_TRADEMARKWraps HB_OT_NAME_ID_TRADEMARK
ot.NAME_ID_MANUFACTURERWraps HB_OT_NAME_ID_MANUFACTURER
ot.NAME_ID_DESIGNERWraps HB_OT_NAME_ID_DESIGNER
ot.NAME_ID_DESCRIPTIONWraps HB_OT_NAME_ID_DESCRIPTION
ot.NAME_ID_VENDOR_URLWraps HB_OT_NAME_ID_VENDOR_URL
ot.NAME_ID_DESIGNER_URLWraps HB_OT_NAME_ID_DESIGNER_URL
ot.NAME_ID_LICENSEWraps HB_OT_NAME_ID_LICENSE
ot.NAME_ID_LICENSE_URLWraps HB_OT_NAME_ID_LICENSE_URL
ot.NAME_ID_TYPOGRAPHIC_FAMILYWraps HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY
ot.NAME_ID_TYPOGRAPHIC_SUBFAMILYWraps HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
ot.NAME_ID_MAC_FULL_NAMEWraps HB_OT_NAME_ID_MAC_FULL_NAME
ot.NAME_ID_SAMPLE_TEXTWraps HB_OT_NAME_ID_SAMPLE_TEXT
ot.NAME_ID_CID_FINDFONT_NAMEWraps HB_OT_NAME_ID_CID_FINDFONT_NAME
ot.NAME_ID_WWS_FAMILYWraps HB_OT_NAME_ID_WWS_FAMILY
ot.NAME_ID_WWS_SUBFAMILYWraps HB_OT_NAME_ID_WWS_SUBFAMILY
ot.NAME_ID_LIGHT_BACKGROUNDWraps HB_OT_NAME_ID_LIGHT_BACKGROUND
ot.NAME_ID_DARK_BACKGROUNDWraps HB_OT_NAME_ID_DARK_BACKGROUND
ot.NAME_ID_VARIATIONS_PS_PREFIXWraps HB_OT_NAME_ID_VARIATIONS_PS_PREFIX
ot.NAME_ID_INVALIDWraps HB_OT_NAME_ID_INVALID
ot.LAYOUT_NO_SCRIPT_INDEXWraps HB_OT_LAYOUT_NO_SCRIPT_INDEX
ot.LAYOUT_NO_FEATURE_INDEXWraps HB_OT_LAYOUT_NO_FEATURE_INDEX
ot.LAYOUT_DEFAULT_LANGUAGE_INDEXWraps HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX
ot.LAYOUT_NO_VARIATIONS_INDEXWraps HB_OT_LAYOUT_NO_VARIATIONS_INDEX
+ +
+
+ + +

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: A Direction object representing the object.
    • +
    • script: A Script object representing the script.
    • +
    • language: A Language object representing the language.
    • +
    • features: features to enable, specified as either of the following. +
    • +
    + + (optional) +
  • +
+ + + + + +
+
+

Class Blob

+ +
+ Lua wrapper for hb_blob_t type. + Wraps binary data such as font file contents or raw font table data. +
+
+
+ + Blob.new (data) +
+
+ Wraps hb_blob_create. + Initializes a new hb_blob_t. + + +

Parameters:

+
    +
  • data + lua string containing binary or character data. +
  • +
+ +

Returns:

+
    + + a Blob object holding the binary data. +
+ + + + +
+
+ + Blob.new_from_file (filename) +
+
+ Wraps hb_blob_create_from_file. + Initializes a new hb_blob_t. + + +

Parameters:

+
    +
  • filename + lua string. +
  • +
+ +

Returns:

+
    + + a Blob object holding the file contents. +
+ + + + +
+
+ + Blob:get_length () +
+
+ Wraps hb_blob_get_length. + + + +

Returns:

+
    + + length of the blob in bytes. +
+ + + + +
+
+ + Blob:get_data () +
+
+ Wraps hb_blob_get_data. + + + +

Returns:

+
    + + blob contents as a string. +
+ + + + +
+
+

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) +
  • +
+ +

Returns:

+
    + + a Face object, or nil if the blob is invalid. +
+ + + + +
+
+ + 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) +
  • +
+ +

Returns:

+
    + + a Face object, or nil if the file cannot be read. +
+ + + + +
+
+ + Face:blob () +
+
+ Wraps hb_face_reference_blob. + + + +

Returns:

+
    + + Blob containing the raw font data, or nil. +
+ + + + +
+
+ + Face:get_name (name_id[, lang]) +
+
+ Wraps hb_ot_name_get_utf8. + + +

Parameters:

+
    +
  • name_id + an ot.NAME_ID_* constant. +
  • +
  • lang + a Language object; uses default language if omitted. + (optional) +
  • +
+ +

Returns:

+
    + + name string, or nil if not found. +
+ + + + +
+
+ + Face:collect_unicodes () +
+
+ Wraps hb_face_collect_unicodes. + + + +

Returns:

+
    + + table of codepoints supported by the face. +
+ + + + +
+
+ + Face:get_glyph_count () +
+
+ Wraps hb_face_get_glyph_count. + + + +

Returns:

+
    + + number of glyphs in the face. +
+ + + + +
+
+ + Face:get_table (tag) +
+
+ Wraps hb_face_reference_table. + + +

Parameters:

+
    +
  • tag + Tag object of the table. +
  • +
+ +

Returns:

+
    + + Blob object for the face table of tag. +
+ + + + +
+
+ + Face:get_table_tags () +
+
+ Wraps hb_face_get_table_tags. + + + +

Returns:

+
    + + table of Tags representing face table tags. +
+ + + + +
+
+ + Face:get_upem () +
+
+ Wraps hb_face_get_upem. + + + +

Returns:

+
    + + units-per-em value of the face. +
+ + + + +
+
+ + Face:ot_color_has_palettes () +
+
+ Wraps hb_ot_color_has_palettes. + + + +

Returns:

+
    + + boolean indicating whether the face has color palettes. +
+ + + + +
+
+ + Face:ot_color_palette_get_count () +
+
+ Wraps hb_ot_color_palette_get_count. + + + +

Returns:

+
    + + number of color palettes in the face. +
+ + + + +
+
+ + Face:ot_color_palette_get_colors ([palette_index=1]) +
+
+ Wraps hb_ot_color_palette_get_colors. + + +

Parameters:

+
    +
  • palette_index + 1-indexed palette index. + (default 1) +
  • +
+ +

Returns:

+
    + + table of color tables each with red, green, blue, alpha fields, or nil. +
+ + + + +
+
+ + Face:ot_color_has_layers () +
+
+ Wraps hb_ot_color_has_layers. + + + +

Returns:

+
    + + boolean indicating whether the face has layered color glyphs. +
+ + + + +
+
+ + Face:ot_color_glyph_get_layers (glyph) +
+
+ Wraps hb_ot_color_glyph_get_layers. + + +

Parameters:

+
    +
  • glyph + glyph index. +
  • +
+ +

Returns:

+
    + + table of layer tables each with glyph and color_index fields, or nil. +
+ + + + +
+
+ + Face:ot_color_has_png () +
+
+ Wraps hb_ot_color_has_png. + + + +

Returns:

+
    + + boolean indicating whether the face has PNG color glyphs. +
+ + + + +
+
+ + Face:ot_color_has_svg () +
+
+ Wraps hb_ot_color_has_svg. + + + +

Returns:

+
    + + boolean indicating whether the face has SVG color glyphs. +
+ + + + +
+
+ + Face:ot_color_glyph_get_svg (glyph) +
+
+ Wraps hb_ot_color_glyph_reference_svg. + + +

Parameters:

+
    +
  • glyph + glyph index. +
  • +
+ +

Returns:

+
    + + Blob containing the SVG data, or nil. +
+ + + + +
+
+ + Face:ot_var_has_data () +
+
+ Wraps hb_ot_var_has_data. + + + +

Returns:

+
    + + boolean indicating whether the face has OpenType variation data. +
+ + + + +
+
+ + Face:ot_var_find_axis_info (tag) +
+
+ Wraps hb_ot_var_find_axis_info. + + +

Parameters:

+
    +
  • tag + Tag of the variation axis. +
  • +
+ +

Returns:

+
    + + table with fields axis_index, tag, name_id, flags, min_value, default_value, max_value, or nil if not found. +
+ + + + +
+
+ + Face:ot_var_get_axis_infos ([start=1[, stop=-1]]) +
+
+ Wraps hb_ot_var_get_axis_infos. + + +

Parameters:

+
    +
  • start + 1-indexed start axis. + (default 1) +
  • +
  • stop + 1-indexed end axis (inclusive); -1 means last. + (default -1) +
  • +
+ +

Returns:

+
    + + table of axis info tables, each with fields axis_index, tag, name_id, flags, min_value, default_value, max_value. +
+ + + + +
+
+ + Face:ot_var_named_instance_get_infos ([start=1[, stop=-1]]) +
+
+ Wraps hb_ot_var_get_named_instance_count and related functions. + + +

Parameters:

+
    +
  • start + 1-indexed start instance. + (default 1) +
  • +
  • stop + 1-indexed end instance (inclusive); -1 means last. + (default -1) +
  • +
+ +

Returns:

+
    + + table of instance info tables, each with fields index, subfamily_name_id, postscript_name_id. +
+ + + + +
+
+ + Face:ot_var_named_instance_get_design_coords (index) +
+
+ Wraps hb_ot_var_named_instance_get_design_coords. + + +

Parameters:

+
    +
  • index + 1-indexed named instance index. +
  • +
+ +

Returns:

+
    + + multiple return values, one number per axis. +
+ + + + +
+
+ + Face:ot_var_normalize_variations (...) +
+
+ Wraps hb_ot_var_normalize_variations. + + +

Parameters:

+
    +
  • ... + one or more Variation objects. +
  • +
+ +

Returns:

+
    + + multiple return values, one normalized integer coordinate per axis. +
+ + + + +
+
+ + Face:ot_var_normalize_coords (...) +
+
+ Wraps hb_ot_var_normalize_coords. + + +

Parameters:

+
    +
  • ... + one or more design-space coordinate numbers, one per axis. +
  • +
+ +

Returns:

+
    + + multiple return values, one normalized integer coordinate per axis. +
+ + + + +
+
+ + Face:ot_layout_get_script_tags (table_tag) +
+
+ Wraps hb_ot_layout_table_get_script_tags. + + +

Parameters:

+
    +
  • table_tag + Tag for the layout table (GSUB or GPOS). +
  • +
+ +

Returns:

+
    + + table of script Tags, or nil. +
+ + + + +
+
+ + Face:ot_layout_get_language_tags (table_tag, script_index) +
+
+ Wraps hb_ot_layout_script_get_language_tags. + + +

Parameters:

+
    +
  • table_tag + Tag for the layout table (GSUB or GPOS). +
  • +
  • script_index + index of the script. +
  • +
+ +

Returns:

+
    + + table of language Tags, or nil. +
+ + + + +
+
+ + Face:ot_layout_get_feature_tags (table_tag, script_index, language_index) +
+
+ Wraps hb_ot_layout_language_get_feature_tags. + + +

Parameters:

+
    +
  • table_tag + Tag for the layout table (GSUB or GPOS). +
  • +
  • script_index + index of the script. +
  • +
  • language_index + index of the language. +
  • +
+ +

Returns:

+
    + + table of feature Tags, or nil. +
+ + + + +
+
+ + Face:ot_layout_find_script (table_tag, script_tag) +
+
+ Wraps hb_ot_layout_table_find_script. + + +

Parameters:

+
    +
  • table_tag + Tag for the layout table (GSUB or GPOS). +
  • +
  • script_tag + Tag of the script to find. +
  • +
+ +

Returns:

+
    + + boolean indicating whether the script was found, and its index. +
+ + + + +
+
+ + Face:ot_layout_find_language (table_tag, script_index, language_tag) +
+
+ Wraps hb_ot_layout_script_find_language. + + +

Parameters:

+
    +
  • table_tag + Tag for the layout table (GSUB or GPOS). +
  • +
  • script_index + index of the script. +
  • +
  • language_tag + Tag of the language to find. +
  • +
+ +

Returns:

+
    + + boolean indicating whether the language was found, and its index. +
+ + + + +
+
+ + Face:ot_layout_find_feature (table_tag, script_index, language_index, feature_tag) +
+
+ Wraps hb_ot_layout_language_find_feature. + + +

Parameters:

+
    +
  • table_tag + Tag for the layout table (GSUB or GPOS). +
  • +
  • script_index + index of the script. +
  • +
  • language_index + index of the language. +
  • +
  • feature_tag + Tag of the feature to find. +
  • +
+ +

Returns:

+
    + + boolean indicating whether the feature was found, and its index. +
+ + + + +
+
+

Class Font

+ +
+ Lua wrapper for hb_font_t type +
+
+
+ + Font.new (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. +
  • +
+ +

Returns:

+
    + + a Font object. +
+ + + + +
+
+ + 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. +
  • +
+ + + + + +
+
+ + Font:get_h_extents () +
+
+ Wraps hb_font_get_h_extents. + + + +

Returns:

+
    + + +

    font extents table for horizontal direction, contains the following + or nil if HarfBuzz fails to load font extents:

    + +
      +
    • ascender: typographic ascender.
    • +
    • descender: typographic descender.
    • +
    • line_gap: line spacing gap.
    • +
    + +
+ + + + +
+
+ + Font:get_v_extents () +
+
+ Wraps hb_font_get_v_extents. + + + +

Returns:

+
    + + font extents table for vertical direction, similar to + Font:get_h_extents, or nil if HarfBuzz fails to load font extents: +
+ + + + +
+
+ + Font:get_glyph_extents (glyph) +
+
+ Wraps hb_font_get_glyph_extents. + + +

Parameters:

+
    +
  • glyph + index inside the font. +
  • +
+ +

Returns:

+
    + + +

    extents table contains the following or nil if HarfBuzz fails to + load glyph extents:

    + +
      +
    • x_bearing: left side of glyph from origin.
    • +
    • y_bearing: top side of glyph from origin.
    • +
    • width: distance from left to right side.
    • +
    • height: distance from top to bottom side.
    • +
    + +
+ + + + +
+
+ + Font:get_glyph_name (glyph) +
+
+ Wraps hb_font_get_glyph_name. + + +

Parameters:

+
    +
  • glyph + index inside the font. +
  • +
+ +

Returns:

+
    + + name of the glyph or nil. +
+ + + + +
+
+ + Font:get_glyph_from_name (name) +
+
+ Wraps hb_font_get_glyph_from_name. + + +

Parameters:

+
    +
  • name + of the glyph. +
  • +
+ +

Returns:

+
    + + glyph index inside the font or nil. +
+ + + + +
+
+ + Font:get_glyph_h_advance (glyph) +
+
+ Wraps hb_font_get_glyph_h_advance. + + +

Parameters:

+
    +
  • glyph + index inside the font. +
  • +
+ +

Returns:

+
    + + advance glyph advance of the glyph in horizontal direction. +
+ + + + +
+
+ + Font:get_glyph_v_advance (glyph) +
+
+ Wraps hb_font_get_glyph_v_advance. + + +

Parameters:

+
    +
  • glyph + index inside the font. +
  • +
+ +

Returns:

+
    + + advance glyph advance of the glyph in vertical direction. +
+ + + + +
+
+ + Font:get_nominal_glyph (codepoint.) +
+
+ Wraps hb_font_get_nominal_glyph. + + +

Parameters:

+
    +
  • codepoint. + + + +
  • +
+ +

Returns:

+
    + + glyph index or nil if codepoint is not supported by the font. +
+ + + + +
+
+ + Font:style_get_value (tag) +
+
+ Wraps hb_style_get_value. + Available when HarfBuzz >= 3. + + +

Parameters:

+
    +
  • tag + a Tag object for the style axis (e.g. wght, ital). +
  • +
+ +

Returns:

+
    + + style value as a number. +
+ + + + +
+
+ + Font:ot_color_glyph_get_png (glyph) +
+
+ Wraps hb_ot_color_glyph_get_png. + + +

Parameters:

+
    +
  • glyph + glyph index. +
  • +
+ +

Returns:

+
    + + Blob containing the PNG data, or nil. +
+ + + + +
+
+ + Font:ot_metrics_get_position (tag) +
+
+ Wraps hb_ot_metrics_get_position. + + +

Parameters:

+
    +
  • tag + a Tag object for the metric. +
  • +
+ +

Returns:

+
    + + integer position value, or nil if not available. +
+ + + + +
+
+ + Font:ot_metrics_get_variation (tag) +
+
+ Wraps hb_ot_metrics_get_variation. + + +

Parameters:

+
    +
  • tag + a Tag object for the metric. +
  • +
+ +

Returns:

+
    + + number variation value. +
+ + + + +
+
+ + Font:ot_metrics_get_x_variation (tag) +
+
+ Wraps hb_ot_metrics_get_x_variation. + + +

Parameters:

+
    +
  • tag + a Tag object for the metric. +
  • +
+ +

Returns:

+
    + + integer x variation value. +
+ + + + +
+
+ + Font:ot_metrics_get_y_variation (tag) +
+
+ Wraps hb_ot_metrics_get_y_variation. + + +

Parameters:

+
    +
  • tag + a Tag object for the metric. +
  • +
+ +

Returns:

+
    + + integer y variation value. +
+ + + + +
+
+ + Font:set_variations (...) +
+
+ Wraps hb_font_set_variations. + + +

Parameters:

+
    +
  • ... + one or more Variation objects. +
  • +
+ + + + + +
+
+ + Font:set_var_coords_design (...) +
+
+ Wraps hb_font_set_var_coords_design. + + +

Parameters:

+
    +
  • ... + one or more design-space coordinate numbers, one per axis. +
  • +
+ + + + + +
+
+ + Font:set_var_coords_normalized (...) +
+
+ Wraps hb_font_set_var_coords_normalized. + + +

Parameters:

+
    +
  • ... + one or more normalized coordinate integers, one per axis. +
  • +
+ + + + + +
+
+ + Font:set_var_named_instance (index) +
+
+ Wraps hb_font_set_var_named_instance. + + +

Parameters:

+
    +
  • index + 1-indexed named instance index. +
  • +
+ + + + + +
+
+ + Font:get_var_coords_normalized () +
+
+ Wraps hb_font_get_var_coords_normalized. + + + +

Returns:

+
    + + multiple return values, one normalized integer coordinate per axis. +
+ + + + +
+
+

Class Buffer

+ +
+ Lua wrapper for hb_buffer_t type. +
+
+
+ + Buffer.new () +
+
+ Wraps hb_buffer_create. + + + +

Returns:

+
    + + a Buffer object. +
+ + + + +
+
+ + Buffer:add (codepoint, cluster) +
+
+ Wraps hb_buffer_add. + + +

Parameters:

+
    +
  • codepoint + Unicode codepoint to add. +
  • +
  • cluster + cluster index of the codepoint. +
  • +
+ + + + + +
+
+ + 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 + A Direction object. +
  • +
+ + + + + +
+
+ + Buffer:get_direction () +
+
+ Wraps hb_buffer_get_direction. + + + +

Returns:

+
    + + A Direction object. +
+ + + + +
+
+ + Buffer:set_script (script) +
+
+ Wraps hb_buffer_set_script. + + +

Parameters:

+
    +
  • script + A Script object. +
  • +
+ + + + + +
+
+ + Buffer:get_script () +
+
+ Wraps hb_buffer_get_script. + + + +

Returns:

+
    + + A Script object. +
+ + + + +
+
+ + Buffer:set_language (lang) +
+
+ Wraps hb_buffer_set_language. + + +

Parameters:

+
    +
  • lang + A Language object +
  • +
+ + + + + +
+
+ + Buffer:get_language () +
+
+ Wraps hb_buffer_get_language. + + + +

Returns:

+
    + + A Language object +
+ + + + +
+
+ + Buffer:set_flags (flags) +
+
+ Wraps hb_buffer_set_flags. + + +

Parameters:

+ + + + + + +
+
+ + Buffer:get_flags () +
+
+ Wraps hb_buffer_get_flags. + + + +

Returns:

+
    + + see Buffer Flags +
+ + + + +
+
+ + Buffer:set_cluster_level (level) +
+
+ Wraps hb_buffer_set_cluster_level. + + +

Parameters:

+ + + + + + +
+
+ + Buffer:get_cluster_level () +
+
+ Wraps hb_buffer_get_cluster_level. + + + +

Returns:

+
    + + see Cluster Levels +
+ + + + +
+
+ + Buffer:set_invisible_glyph (glyph) +
+
+ Wraps hb_buffer_set_invisible_glyph. + + +

Parameters:

+
    +
  • glyph + glyph index to use for invisible characters. +
  • +
+ + + + + +
+
+ + Buffer:get_invisible_glyph () +
+
+ Wraps hb_buffer_get_invisible_glyph. + + + +

Returns:

+
    + + glyph index used for invisible characters. +
+ + + + +
+
+ + Buffer:set_replacement_codepoint (codepoint) +
+
+ Wraps hb_buffer_set_replacement_codepoint. + + +

Parameters:

+
    +
  • codepoint + replacement codepoint for invalid input. +
  • +
+ + + + + +
+
+ + Buffer:get_replacement_codepoint () +
+
+ Wraps hb_buffer_get_replacement_codepoint. + + + +

Returns:

+
    + + replacement codepoint for invalid input. +
+ + + + +
+
+ + Buffer:get_length () +
+
+ Wraps hb_buffer_get_length. + + + +

Returns:

+
    + + number of items in the buffer. +
+ + + + +
+
+ + Buffer:guess_segment_properties () +
+
+ Wraps hb_buffer_guess_segment_properties. + + + + + + + +
+
+ + Buffer:reverse () +
+
+ Wraps hb_buffer_reverse. + + + + + + + +
+
+ + Buffer:clear_contents () +
+
+ Wraps hb_buffer_clear_contents. + + + + + + + +
+
+ + Buffer:reset () +
+
+ Wraps hb_buffer_reset. + + + + + + + +
+
+ + Buffer:pre_allocate (size) +
+
+ Wraps hb_buffer_pre_allocate. + + +

Parameters:

+
    +
  • size + number of items to pre-allocate. +
  • +
+ +

Returns:

+
    + + boolean indicating success. +
+ + + + +
+
+ + Buffer: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. + + + +

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).
    • +
    • flags: glyph flags
    • +
    + +
+ + + + +
+
+

Cluster Levels

+ +
+ See Harfbuzz docs for more details + about what each of these levels mean. +
+
+
+ + Buffer.CLUSTER_LEVEL_MONOTONE_GRAPHEMES +
+
+ Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. + + + + + + + +
+
+ + Buffer.CLUSTER_LEVEL_MONOTONE_CHARACTERS +
+
+ Wraps HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS. + + + + + + + +
+
+ + Buffer.CLUSTER_LEVEL_CHARACTERS +
+
+ Wraps HB_BUFFER_CLUSTER_LEVEL_CHARACTERS. + + + + + + + +
+
+ + Buffer.CLUSTER_LEVEL_DEFAULT +
+
+ Wraps HB_BUFFER_CLUSTER_LEVEL_DEFAULT. + + + + + + + +
+
+

Buffer Flags

+ +
+ See Harfbuzz docs for more details + about what each of these flags mean. +
+
+
+ + Buffer.FLAG_DEFAULT +
+
+ Wraps HB_BUFFER_FLAG_DEFAULT. + + + + + + + +
+
+ + Buffer.FLAG_BOT +
+
+ Wraps HB_BUFFER_FLAG_BOT. + + + + + + + +
+
+ + Buffer.FLAG_EOT +
+
+ Wraps HB_BUFFER_FLAG_EOT. + + + + + + + +
+
+ + Buffer.FLAG_PRESERVE_DEFAULT_IGNORABLES +
+
+ Wraps HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES. + + + + + + + +
+
+ + Buffer.FLAG_REMOVE_DEFAULT_IGNORABLES +
+
+ Wraps HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES. + + + + + + + +
+
+ + Buffer.FLAG_DO_NOT_INSERT_DOTTED_CIRCLE +
+
+ Wraps HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE. + + + + + + + +
+
+ + Buffer.FLAG_VERIFY +
+
+ Wraps HB_BUFFER_FLAG_VERIFY. + + + + + + + +
+
+ + Buffer.FLAG_PRODUCE_UNSAFE_TO_CONCAT +
+
+ Wraps HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT. + + + + + + + +
+
+ + Buffer.FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL +
+
+ Wraps HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL. + + + + + + + +
+
+ + Buffer.FLAG_DEFINED +
+
+ Wraps HB_BUFFER_FLAG_DEFINED. + + + + + + + +
+
+

Glyph Flags

+ +
+ See Harfbuzz docs for more details + about what each of these flags mean. +
+
+
+ + Buffer.GLYPH_FLAG_UNSAFE_TO_BREAK +
+
+ Wraps HB_GLYPH_FLAG_UNSAFE_TO_BREAK. + + + + + + + +
+
+ + Buffer.GLYPH_FLAG_UNSAFE_TO_CONCAT +
+
+ Wraps HB_GLYPH_FLAG_UNSAFE_TO_CONCAT. + + + + + + + +
+
+ + Buffer.GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL +
+
+ Wraps HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL. + + + + + + + +
+
+ + Buffer.GLYPH_FLAG_DEFINED +
+
+ Wraps HB_GLYPH_FLAG_DEFINED. + + + + + + + +
+
+

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(…). + + + + + + + +
+
+

Class Variation

+ +
+ Lua wrapper for hb_variation_t type. +
+
+
+ + Variation.new (variation_string) +
+
+ Wraps hb_variation_from_string. + + +

Parameters:

+
    +
  • variation_string + variation string, e.g. "wght=700". +
  • +
+ +

Returns:

+
    + + a Variation object, or nil if the string is invalid. +
+ + + + +
+
+ + Variation:__tostring () +
+
+ Wraps hb_variation_to_string. + Enables nice output with tostring(…). + + + + + + + +
+
+

Class Tag

+ +
+ Lua wrapper for hb_tag_t type. +
+
+
+ + Tag.new (string) +
+
+ Wraps hb_tag_from_string. + + +

Parameters:

+
    +
  • string + to be converted to a Tag object. +
  • +
+ +

Returns:

+
    + + a Tag object. +
+ + + + +
+
+ + Tag:__tostring () +
+
+ Wraps hb_tag_to_string. Enable nice output with tostring(…). + + + +

Returns:

+
    + + Returns a string representation for the tag object. +
+ + + + +
+
+ + Tag:__eq () +
+
+ Enables equality comparisions with == between two tags. + + + +

Returns:

+
    + + true or false depending on whether the two tags are equal. +
+ + + + +
+
+

Class Script

+ +
+ Lua wrapper for hb_script_t type. +
+
+
+ + Script.new (script) +
+
+ Wraps hb_script_from_string. + + +

Parameters:

+ + +

Returns:

+
    + + a Script object. +
+ + + + +
+
+ + Script.from_iso15924_tag (tag) +
+
+ Wraps hb_script_from_iso15924_tag + + +

Parameters:

+ + + + + + +
+
+ + Script:to_iso15924_tag () +
+
+ Wraps hb_script_to_iso15924_tag. + + + +

Returns:

+
    + + a Tag object representing the script. +
+ + + + +
+
+ + Script:__tostring () +
+
+ Enable nice output with tostring(…) + + + +

Returns:

+
    + + Returns a 4-letter ISO 15924 script code for the script object. +
+ + + + +
+
+ + Script:__eq () +
+
+ Enables equality comparisions with == between two scripts. + + + +

Returns:

+
    + + true or false depending on whether the two scripts are equal. +
+ + + + +
+
+

Predefined Script Codes

+ +
+ Predefined directions that correspond to their original definitions in Harfbuzz. +
+
+
+ + Script.COMMON +
+
+ Wraps HB_SCRIPT_COMMON. + + + + + + + +
+
+ + Script.INHERITED +
+
+ Wraps HB_SCRIPT_INHERITED. + + + + + + + +
+
+ + Script.UNKNOWN +
+
+ Wraps HB_SCRIPT_UNKNOWN. + + + + + + + +
+
+ + Script.INVALID +
+
+ Wraps HB_SCRIPT_INVALID. + + + + + + + +
+
+

Class Direction

+ +
+ Lua wrapper for hb_direction_t type. +
+
+
+ + Direction.new (dir) +
+
+ Wraps hb_direction_from_string. + + +

Parameters:

+
    +
  • dir + can be one of ltr, rtl, ttb, btt or invalid. +
  • +
+ +

Returns:

+
    + + a Direction object. +
+ + + + +
+
+ + Direction:__tostring () +
+
+ Wraps hb_direction_to_string. Enable nice output with tostring(…). + + + +

Returns:

+
    + + Returns a string representation for direction. +
+ + + + +
+
+ + Direction:__eq () +
+
+ Enables equality comparisions with == between two directions. + + + +

Returns:

+
    + + true or false depending on whether the two tags are equal. +
+ + + + +
+
+ + Direction:is_valid () +
+
+ Wraps HB_DIRECTION_IS_VALID. + + + +

Returns:

+
    + + a boolean value +
+ + + + +
+
+ + Direction:is_horizontal () +
+
+ Wraps HB_DIRECTION_IS_HORIZONTAL. + + + +

Returns:

+
    + + a boolean value +
+ + + + +
+
+ + Direction:is_vertical () +
+
+ Wraps HB_DIRECTION_IS_VERTICAL. + + + +

Returns:

+
    + + a boolean value +
+ + + + +
+
+ + Direction:is_forward () +
+
+ Wraps HB_DIRECTION_IS_FORWARD. + + + +

Returns:

+
    + + a boolean value +
+ + + + +
+
+ + Direction:is_backward () +
+
+ Wraps HB_DIRECTION_IS_BACKWARD. + + + +

Returns:

+
    + + a boolean value +
+ + + + +
+
+

Predefined directions

+ +
+ Predefined directions that correspond to their original definitions in Harfbuzz. +
+
+
+ + Direction.LTR +
+
+ Wraps HB_DIRECTION_LTR. + + + + + + + +
+
+ + Direction.RTL +
+
+ Wraps HB_DIRECTION_RTL. + + + + + + + +
+
+ + Direction.TTB +
+
+ Wraps HB_DIRECTION_TTB. + + + + + + + +
+
+ + Direction.BTT +
+
+ Wraps HB_DIRECTION_LTR. + + + + + + + +
+
+

Class Language

+ +
+ Lua wrapper for hb_language_t type. +
+
+
+ + Language.new (lang) +
+
+ Wraps hb_language_from_string. + + +

Parameters:

+ + +

Returns:

+
    + + a Language object. +
+ + + + +
+
+ + Language:__tostring () +
+
+ Wraps hb_language_to_string. Enable nice output with tostring(…). + + + +

Returns:

+
    + + Returns a string representation for the language object. +
+ + + + +
+
+ + Language:__eq () +
+
+ Enables equality comparisions with == between two languages. + + + +

Returns:

+
    + + true or false depending on whether the two languages are equal. +
+ + + + +
+
+

Predefined languages

+ +
+ Predefined languages that correspond to their original definitions in Harfbuzz. +
+
+
+ + Language.INVALID +
+
+ Wraps HB_LANGUAGE_INVALID. + + + + + + + +
+
+

Class Set

+ +
+ Lua wrapper for hb_set_t type.

+ +

Set objects represent a mathematical set of integer values. +

+
+
+ + Set:add (codepoint) +
+
+ Wraps hb_set_add.

+ +

Adds a codepoint to the set. + + +

Parameters:

+
    +
  • codepoint + The element to add. +
  • +
+ + + + + +
+
+

Unicode functions

+ +
+
+ + unicode.script (char) +
+
+ Wraps hb_unicode_script + + +

Parameters:

+
    +
  • char + Unicode codepoint +
  • +
+ +

Returns:

+
    + + a Script object. +
+ + + + +
+
+

Predefined Name IDs

+ +
+ Predefined OpenType 'name' table name identifier. +
+
+
+ + ot.NAME_ID_COPYRIGHT +
+
+ Wraps HB_OT_NAME_ID_COPYRIGHT + + + + + + + +
+
+ + ot.NAME_ID_FONT_FAMILY +
+
+ Wraps HB_OT_NAME_ID_FONT_FAMILY + + + + + + + +
+
+ + ot.NAME_ID_FONT_SUBFAMILY +
+
+ Wraps HB_OT_NAME_ID_FONT_SUBFAMILY + + + + + + + +
+
+ + ot.NAME_ID_UNIQUE_ID +
+
+ Wraps HB_OT_NAME_ID_UNIQUE_ID + + + + + + + +
+
+ + ot.NAME_ID_FULL_NAME +
+
+ Wraps HB_OT_NAME_ID_FULL_NAME + + + + + + + +
+
+ + ot.NAME_ID_VERSION_STRING +
+
+ Wraps HB_OT_NAME_ID_VERSION_STRING + + + + + + + +
+
+ + ot.NAME_ID_POSTSCRIPT_NAME +
+
+ Wraps HB_OT_NAME_ID_POSTSCRIPT_NAME + + + + + + + +
+
+ + ot.NAME_ID_TRADEMARK +
+
+ Wraps HB_OT_NAME_ID_TRADEMARK + + + + + + + +
+
+ + ot.NAME_ID_MANUFACTURER +
+
+ Wraps HB_OT_NAME_ID_MANUFACTURER + + + + + + + +
+
+ + ot.NAME_ID_DESIGNER +
+
+ Wraps HB_OT_NAME_ID_DESIGNER + + + + + + + +
+
+ + ot.NAME_ID_DESCRIPTION +
+
+ Wraps HB_OT_NAME_ID_DESCRIPTION + + + + + + + +
+
+ + ot.NAME_ID_VENDOR_URL +
+
+ Wraps HB_OT_NAME_ID_VENDOR_URL + + + + + + + +
+
+ + ot.NAME_ID_DESIGNER_URL +
+
+ Wraps HB_OT_NAME_ID_DESIGNER_URL + + + + + + + +
+
+ + ot.NAME_ID_LICENSE +
+
+ Wraps HB_OT_NAME_ID_LICENSE + + + + + + + +
+
+ + ot.NAME_ID_LICENSE_URL +
+
+ Wraps HB_OT_NAME_ID_LICENSE_URL + + + + + + + +
+
+ + ot.NAME_ID_TYPOGRAPHIC_FAMILY +
+
+ Wraps HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY + + + + + + + +
+
+ + ot.NAME_ID_TYPOGRAPHIC_SUBFAMILY +
+
+ Wraps HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY + + + + + + + +
+
+ + ot.NAME_ID_MAC_FULL_NAME +
+
+ Wraps HB_OT_NAME_ID_MAC_FULL_NAME + + + + + + + +
+
+ + ot.NAME_ID_SAMPLE_TEXT +
+
+ Wraps HB_OT_NAME_ID_SAMPLE_TEXT + + + + + + + +
+
+ + ot.NAME_ID_CID_FINDFONT_NAME +
+
+ Wraps HB_OT_NAME_ID_CID_FINDFONT_NAME + + + + + + + +
+
+ + ot.NAME_ID_WWS_FAMILY +
+
+ Wraps HB_OT_NAME_ID_WWS_FAMILY + + + + + + + +
+
+ + ot.NAME_ID_WWS_SUBFAMILY +
+
+ Wraps HB_OT_NAME_ID_WWS_SUBFAMILY + + + + + + + +
+
+ + ot.NAME_ID_LIGHT_BACKGROUND +
+
+ Wraps HB_OT_NAME_ID_LIGHT_BACKGROUND + + + + + + + +
+
+ + ot.NAME_ID_DARK_BACKGROUND +
+
+ Wraps HB_OT_NAME_ID_DARK_BACKGROUND + + + + + + + +
+
+ + ot.NAME_ID_VARIATIONS_PS_PREFIX +
+
+ Wraps HB_OT_NAME_ID_VARIATIONS_PS_PREFIX + + + + + + + +
+
+ + ot.NAME_ID_INVALID +
+
+ Wraps HB_OT_NAME_ID_INVALID + + + + + + + +
+
+ + ot.LAYOUT_NO_SCRIPT_INDEX +
+
+ Wraps HB_OT_LAYOUT_NO_SCRIPT_INDEX + + + + + + + +
+
+ + ot.LAYOUT_NO_FEATURE_INDEX +
+
+ Wraps HB_OT_LAYOUT_NO_FEATURE_INDEX + + + + + + + +
+
+ + ot.LAYOUT_DEFAULT_LANGUAGE_INDEX +
+
+ Wraps HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX + + + + + + + +
+
+ + ot.LAYOUT_NO_VARIATIONS_INDEX +
+
+ Wraps HB_OT_LAYOUT_NO_VARIATIONS_INDEX + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2026-06-23 14:19:38 +
+
+ + diff --git a/modules/harfbuzzsubset.html b/modules/harfbuzzsubset.html new file mode 100644 index 0000000..b714b73 --- /dev/null +++ b/modules/harfbuzzsubset.html @@ -0,0 +1,326 @@ + + + + + luaharfbuzz Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module harfbuzzsubset

+

Lua bindings to the Harfbuzz subset API.

+

+ +

+ +

This module provides bindings to the HarfBuzz hb-subset API. It is + designed to be used together with the main harfbuzz module.

+ +

Typical usage:

+ + +
+local hb = require('harfbuzz')
+local hb_subset  = require("harfbuzzsubset")
+
+local input = hb_subset.SubsetInput.new()
+
+local wght = hb.Tag.new("wght")
+local wdth = hb.Tag.new("wdth")
+local face = hb.Face.new("myfont.ttf")
+
+input:pin_axis_location(face, wght, 100)
+input:pin_axis_location(face, wdth, 100)
+
+input:keep_everything()
+
+local new_face = hb_subset.subset(face, input)
+
+local blob = new_face:blob()
+local fh, err = io.open("out.ttf", "wb")
+if not fh then error(err) end
+fh:write(blob:get_data())
+fh:close()
+
+ +

+

Info:

+ + + +

Functions

+ + + + + + + + + +
subset (face, input)Wraps hb_subset_or_fail.
version ()Wraps hb_version.
+

Class SubsetInput

+ + + + + + + + + + + + + + + + + + + + + +
SubsetInput.new ()Wraps hb_subset_input_create_or_fail.
SubsetInput:unicode_set ()Wraps hb_subset_input_unicode_set.
SubsetInput:pin_axis_location (face, tag, value)Wraps hb_subset_input_pin_axis_location.
SubsetInput:keep_everything ()Wraps hb_subset_input_keep_everything.
SubsetInput:__gc ()Wraps hb_subset_input_destroy.
+ +
+
+ + +

Functions

+ +
+
+ + subset (face, input) +
+
+ Wraps hb_subset_or_fail.

+ +

Performs the actual subset operation, producing a new Face that only + contains the glyphs and data configured on this input. + + +

Parameters:

+
    +
  • face + source Face object to subset. +
  • +
  • input + SubsetInput object to subset based on. +
  • +
+ +

Returns:

+
    + + new Face object representing the subset, or nil on failure. +
+ + + + +
+
+ + version () +
+
+ Wraps hb_version. + + + + + + + +
+
+

Class SubsetInput

+ +
+ Lua wrapper for hb_subset_input_t type.

+ +

Objects of this type control which parts of a Face are kept when + creating a subset.

+ +

Instances are usually created via SubsetInput.new. +

+
+
+ + SubsetInput.new () +
+
+ Wraps hb_subset_input_create_or_fail.

+ +

Initializes a new hb_subset_input_t. The returned object can be used to + configure which glyphs and features are kept when subsetting a face. + + + +

Returns:

+
    + + SubsetInput object, or nil on failure. +
+ + + + +
+
+ + SubsetInput:unicode_set () +
+
+ Wraps hb_subset_input_unicode_set.

+ +

Returns the Unicode set associated with this subset input. The returned + harfbuzz.Set can be modified (e.g. via add) to control which + Unicode codepoints are included in the subset. + + + +

Returns:

+
    + + Set object representing the Unicode set, or nil on failure. +
+ + + + +
+
+ + SubsetInput:pin_axis_location (face, tag, value) +
+
+ Wraps hb_subset_input_pin_axis_location.

+ +

Pins a variation axis at a specific value for subsetting. + + +

Parameters:

+
    +
  • face + Face object whose design space is being subset. +
  • +
  • tag + Tag object representing the axis tag (e.g. "wght", "wdth"). +
  • +
  • value + numeric axis value to pin. +
  • +
+ +

Returns:

+
    + + true on success, false on failure. +
+ + + + +
+
+ + SubsetInput:keep_everything () +
+
+ Wraps hb_subset_input_keep_everything.

+ +

Configures the input so that everything in the original face is kept. + This is useful as a starting point before applying more specific filters. + + + + + + + +

+
+ + SubsetInput:__gc () +
+
+ Wraps hb_subset_input_destroy.

+ +

Destructor for subset inputs. Normally this is invoked automatically by + the garbage collector; applications rarely need to call it directly. + + + + + + + +

+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 2026-06-23 14:19:38 +
+
+ +