Debian Codegraph @

texk/web2c/luatexdir/luaharfbuzz/src/harfbuzz.luadoc

raw
1 -----------
2 -- Lua bindings to Harfbuzz.
3 -- * [Wiki](http://github.com/harfbuzz/luaharfbuzz/wiki)
4 -- * [Source on Github](https://github.com/harfbuzz/luaharfbuzz)
5 -- * [API Coverage Status](https://github.com/harfbuzz/luaharfbuzz/blob/master/status/done.txt)
6 --
7 -- @author Deepak Jois <<[email protected]>>
8 -- @copyright 2016
9 -- @license MIT
10 -- @module harfbuzz
11
12 --- Wraps `hb_version`.
13 -- @function version
14
15 --- Wraps `hb_shape`.
16 -- @param font `Font` to use for shaping
17 --
18 -- @param buffer `Buffer` to shape
19 --
20 -- @param[opt] options table containing one or more supported options:
21 --
22 -- * `direction`: A `Direction` object representing the object.
23 -- * `script`: A `Script` object representing the script.
24 -- * `language`: A `Language` object representing the language.
25 -- * `features`: features to enable, specified as either of the following.
26 -- - comma-separated list of features. See [feature string syntax reference](https://github.com/harfbuzz/luaharfbuzz/wiki/Feature-Strings)
27 -- - table of `Feature` objects
28 -- @function shape
29
30 --- Lua wrapper for `hb_blob_t` type
31 -- @type Blob
32
33 --- Wraps `hb_blob_create`.
34 -- Initializes a new `hb_blob_t`.
35 -- @param data lua string containing binary or character data.
36 -- @function Blob.new
37
38 --- Wraps `hb_blob_create_from_file`.
39 -- Initializes a new `hb_blob_t`.
40 -- @param filename lua string.
41 -- @function Blob.new_from_file
42
43 --- Wraps `hb_blob_get_length`.
44 -- @function Blob:get_length
45
46 --- Wraps `hb_blob_get_data`.
47 -- @function Blob:get_data
48
49 --- Lua wrapper for `hb_face_t` type
50 -- @type Face
51
52 --- Wraps `hb_face_create`.
53 -- Initializes a new `hb_face_t` from a `Blob` object.
54 -- @param blob `Blob` to read the font from.
55 -- @param[opt=0] font_index index of font to read.
56 -- @function Face.new_from_blob
57
58 --- Create a new `Face` from a file.
59 -- Makes a call to `Face:new_from_blob` after creating a `Blob` from the
60 -- file contents.
61 -- @param file path to font file.
62 -- @param[opt=0] font_index index of font to read.
63 -- @function Face.new
64
65 --- Wraps `hb_face_collect_unicodes`.
66 -- @return table of codepoints supported by the face.
67 -- @function Face:collect_unicodes
68
69 --- Wraps `hb_face_get_glyph_count`.
70 -- @function Face:get_glyph_count
71
72 --- Wraps `hb_face_reference_table`.
73 -- @param tag `Tag` object of the table.
74 -- @return `Blob` object for the face table of `tag`.
75 -- @function Face:get_table
76
77 --- Wraps `hb_face_get_table_tags`.
78 -- @return table of `Tag`s representing face table tags.
79 -- @function Face:get_table_tags
80
81 --- Wraps `hb_face_get_upem`.
82 -- @function Face:get_upem
83
84 --- Wraps `hb_ot_color_has_palettes`.
85 -- @function Face:ot_color_has_palettes
86
87 --- Wraps `hb_ot_color_palette_get_count`.
88 -- @function Face:ot_color_palette_get_count
89
90 --- Wraps `hb_ot_color_palette_get_colors`.
91 -- @function Face:ot_color_palette_get_colors
92
93 --- Wraps `hb_ot_color_has_layers`.
94 -- @function Face:ot_color_has_layers
95
96 --- Wraps `hb_ot_color_glyph_get_layers`.
97 -- @function Face:ot_color_glyph_get_layers
98
99 --- Wraps `hb_ot_color_has_png`.
100 -- @function Face:ot_color_has_png
101
102 --- Wraps `hb_ot_layout_table_get_script_tags`.
103 -- @function Face:ot_layout_get_script_tags
104
105 --- Wraps `hb_ot_layout_script_get_language_tags`.
106 -- @function Face:ot_layout_get_language_tags
107
108 --- Wraps `hb_ot_layout_language_get_feature_tags`.
109 -- @function Face:ot_layout_get_feature_tags
110
111 --- Wraps `hb_ot_layout_table_find_script`.
112 -- @function Face:ot_layout_find_script
113
114 --- Wraps `hb_ot_layout_script_find_language`.
115 -- @function Face:ot_layout_find_language
116
117 --- Wraps `hb_ot_layout_language_find_feature`.
118 -- @function Face:ot_layout_find_feature
119
120
121 --- Lua wrapper for `hb_font_t` type
122 -- @type Font
123
124 --- Wraps `hb_font_create`, and sets up some defaults for scale and shaping functions.
125 -- Initializes a new `hb_font_t` from a `Face` object. Sets the default scale
126 -- to the face’s upem value, and sets the font shaping functions by
127 -- calling `hb_ot_font_set_funcs` on it.
128 -- @param face `Face` object.
129 -- @function Font.new
130
131 --- Wraps `hb_font_get_scale`.
132 -- @return two values for the x-scale and y-scale of the font.
133 -- @function Font:get_scale
134
135 --- Wraps `hb_font_set_scale`.
136 -- @param x_scale desired x-scale of font.
137 -- @param y_scale desired y-scale of font.
138 -- @function Font:set_scale
139
140 --- Wraps `hb_font_get_h_extents`.
141 -- @return font extents table for horizontal direction, contains the following
142 -- or `nil` if HarfBuzz fails to load font extents:
143 --
144 -- * `ascender`: typographic ascender.
145 -- * `descender`: typographic descender.
146 -- * `line_gap`: line spacing gap.
147 -- @function Font:get_h_extents
148
149 --- Wraps `hb_font_get_v_extents`.
150 -- @return font extents table for vertical direction, similar to
151 -- `Font:get_h_extents`, or `nil` if HarfBuzz fails to load font extents:
152 -- @function Font:get_v_extents
153
154 --- Wraps `hb_font_get_glyph_extents`.
155 -- @param glyph index inside the font.
156 -- @return extents table contains the following or `nil` if HarfBuzz fails to
157 -- load glyph extents:
158 --
159 -- * `x_bearing`: left side of glyph from origin.
160 -- * `y_bearing`: top side of glyph from origin.
161 -- * `width`: distance from left to right side.
162 -- * `height`: distance from top to bottom side.
163 -- @function Font:get_glyph_extents
164
165 --- Wraps `hb_font_get_glyph_name`.
166 -- @param glyph index inside the font.
167 -- @return name of the glyph or nil.
168 -- @function Font:get_glyph_name
169
170 --- Wraps `hb_font_get_glyph_from_name`.
171 -- @param name of the glyph.
172 -- @return glyph index inside the font or nil.
173 -- @function Font:get_glyph_from_name
174
175 --- Wraps `hb_font_get_glyph_h_advance`.
176 -- @param glyph index inside the font.
177 -- @return advance glyph advance of the glyph in horizontal direction.
178 -- @function Font:get_glyph_h_advance
179
180 --- Wraps `hb_font_get_glyph_v_advance`.
181 -- @param glyph index inside the font.
182 -- @return advance glyph advance of the glyph in vertical direction.
183 -- @function Font:get_glyph_v_advance
184
185 --- Wraps `hb_font_get_nominal_glyph`.
186 -- @param codepoint.
187 -- @return glyph index or `nil` if `codepoint` is not supported by the font.
188 -- @function Font:get_nominal_glyph
189
190 --- Wraps `hb_ot_color_glyph_get_png`.
191 -- @function Font:ot_color_glyph_get_png
192
193 --- Lua wrapper for `hb_buffer_t` type.
194 -- @type Buffer
195
196 --- Wraps `hb_buffer_create`.
197 -- @function Buffer.new
198
199 --- Wraps `hb_buffer_add_utf8`.
200 -- @param text UTF8 encoded string.
201 -- @param[opt=0] item_offset 0-indexed offset in `text`, from where to start adding.
202 -- @param[opt=-1] item_length length to add from `item_offset`. `-1` adds till end of `text`.
203 -- @function Buffer:add_utf8
204
205 --- Wraps `hb_buffer_add_codepoints`.
206 -- @param text table with codepoints as lua numbers.
207 -- @param[opt=0] item_offset 0-indexed offset in `text`, from where to start adding.
208 -- @param[opt=-1] item_length length to add from `item_offset`. `-1` adds till end of&nbsp;`text`.
209 -- @function Buffer:add_codepoints
210
211 --- Wraps `hb_buffer_set_direction`.
212 -- @param dir A `Direction` object.
213 -- @function Buffer:set_direction
214
215 --- Wraps `hb_buffer_get_direction`.
216 -- @return A `Direction` object.
217 -- @function Buffer:get_direction
218
219 --- Wraps `hb_buffer_set_script`.
220 -- @param script A `Script` object.
221 -- @function Buffer:set_script
222
223 --- Wraps `hb_buffer_get_script`.
224 -- @return A `Script` object.
225 -- @function Buffer:get_script
226
227 --- Wraps `hb_buffer_set_language`.
228 -- @param lang A `Language` object
229 -- @function Buffer:set_language
230
231 --- Wraps `hb_buffer_get_language`.
232 -- @return A `Language` object
233 -- @function Buffer:get_language
234
235 --- Wraps `hb_buffer_reverse`.
236 -- @function Buffer:reverse
237
238 --- Wraps `hb_buffer_get_length`.
239 -- @function Buffer:get_length
240
241 --- Wraps `hb_buffer_get_cluster_level`.
242 -- @return see [Cluster Levels](#Cluster_Levels)
243 -- @function Buffer:get_cluster_level
244
245 --- Wraps `hb_buffer_set_cluster_level`.
246 -- @param level see [Cluster Levels](#Cluster_Levels)
247 -- @function Buffer:set_cluster_level
248
249 --- Wraps `hb_buffer_guess_segment_properties`.
250 -- @function Buffer:guess_segment_properties
251
252 --- Helper method to get shaped glyph data.
253 -- Calls `hb_buffer_get_glyph_infos`, `hb_buffer_get_glyph_positions` and
254 -- `hb_glyph_info_get_glyph_flags`, and assembles the data into a Lua table.
255 -- @return table containing data for each glyph, in a nested table. Each nested
256 -- table contains the following:
257 --
258 -- * `x_advance`: horizontal advance.
259 -- * `y_advance`: vertical advance.
260 -- * `x_offset`: horizontal displacement.
261 -- * `y_offset`: vertical displacement.
262 -- * `cluster`: glyph cluster index within input.
263 -- * `codepoint`: glyph index inside the font _(this field name is a bit misleading, but that’s what Harfbuzz uses)_.
264 -- * `flags`: glyph flags
265 -- @function Buffer:get_glyphs
266
267 --- Cluster Levels.
268 -- See [Harfbuzz docs](http://behdad.github.io/harfbuzz/clusters.html) for more details
269 -- about what each of these levels mean.
270 -- @section cluster-levels
271
272 --- Wraps `HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES`.
273 -- @field Buffer.CLUSTER_LEVEL_MONOTONE_GRAPHEMES
274
275 --- Wraps `HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS`.
276 -- @field Buffer.CLUSTER_LEVEL_MONOTONE_CHARACTERS
277
278 --- Wraps `HB_BUFFER_CLUSTER_LEVEL_CHARACTERS`.
279 -- @field Buffer.CLUSTER_LEVEL_CHARACTERS
280
281 --- Wraps `HB_BUFFER_CLUSTER_LEVEL_DEFAULT`.
282 -- @field Buffer.CLUSTER_LEVEL_DEFAULT
283
284 --- Wraps `HB_GLYPH_FLAG_UNSAFE_TO_BREAK`.
285 -- @field Buffer.GLYPH_FLAG_UNSAFE_TO_BREAK
286
287 --- Wraps `HB_GLYPH_FLAG_DEFINED`.
288 -- @field Buffer.GLYPH_FLAG_DEFINED
289
290 --- Lua wrapper for `hb_feature_t` type
291 -- @type Feature
292
293 --- Wraps `hb_feature_from_string`
294 -- @param feature_string See [feature string syntax reference](https://github.com/harfbuzz/luaharfbuzz/wiki/Feature-Strings)
295 -- @function Feature.new
296
297 --- Wraps `hb_feature_to_string`.
298 -- Enables nice output with `tostring(…)`.
299 -- @function Feature:__tostring
300
301 --- Lua wrapper for `hb_tag_t` type.
302 -- @type Tag
303
304 --- Wraps `hb_tag_from_string`.
305 -- @param string to be converted to a `Tag` object.
306 -- @return a `Tag` object.
307 -- @function Tag.new
308
309 --- Wraps `hb_tag_to_string`. Enable nice output with `tostring(…)`.
310 -- @return Returns a string representation for the tag object.
311 -- @function Tag:__tostring
312
313 --- Enables equality comparisions with `==` between two tags.
314 -- @return `true` or `false` depending on whether the two tags are equal.
315 -- @function Tag:__eq
316
317
318 --- Lua wrapper for `hb_script_t` type.
319 -- @type Script
320
321 --- Wraps `hb_script_from_string`.
322 -- @param script 4-letter script code according to the [ISO 15924 standard](http://www.unicode.org/iso15924/iso15924-num.html).
323 -- @return a `Script` object.
324 -- @function Script.new
325
326 --- Wraps `hb_script_from_iso15924_tag`
327 -- @param tag a `Tag` object representing a [ISO 15924 script](http://www.unicode.org/iso15924/iso15924-num.html).
328 -- @function Script.from_iso15924_tag
329
330 --- Wraps `hb_script_to_iso15924_tag`.
331 -- @return a `Tag` object representing the script.
332 -- @function Script:to_iso15924_tag
333
334 --- Enable nice output with `tostring(…)`
335 -- @return Returns a 4-letter [ISO 15924 script code](http://www.unicode.org/iso15924/iso15924-num.html) for the script object.
336 -- @function Script:__tostring
337
338 --- Enables equality comparisions with `==` between two scripts.
339 -- @return `true` or `false` depending on whether the two scripts are equal.
340 -- @function Script:__eq
341
342 --- Predefined Script Codes.
343 -- Predefined directions that correspond to their original definitions in Harfbuzz.
344 -- @section predefined-script-codes
345
346 --- Wraps `HB_SCRIPT_COMMON`.
347 -- @field Script.COMMON
348
349 --- Wraps `HB_SCRIPT_INHERITED`.
350 -- @field Script.INHERITED
351
352 --- Wraps `HB_SCRIPT_UNKNOWN`.
353 -- @field Script.UNKNOWN
354
355 --- Wraps `HB_SCRIPT_INVALID`.
356 -- @field Script.INVALID
357
358 --- Lua wrapper for `hb_direction_t` type.
359 -- @type Direction
360
361 --- Wraps `hb_direction_from_string`.
362 -- @param dir can be one of `ltr`, `rtl`, `ttb`, `btt` or `invalid`.
363 -- @return a `Direction` object.
364 -- @function Direction.new
365
366 --- Wraps `hb_direction_to_string`. Enable nice output with `tostring(…)`.
367 -- @return Returns a string representation for direction.
368 -- @function Direction:__tostring
369
370 --- Enables equality comparisions with `==` between two directions.
371 -- @return `true` or `false` depending on whether the two tags are equal.
372 -- @function Direction:__eq
373
374 --- Wraps `HB_DIRECTION_IS_VALID`.
375 -- @return a boolean value
376 -- @function Direction:is_valid
377
378 --- Wraps `HB_DIRECTION_IS_HORIZONTAL`.
379 -- @return a boolean value
380 -- @function Direction:is_horizontal
381
382 --- Wraps `HB_DIRECTION_IS_VERTICAL`.
383 -- @return a boolean value
384 -- @function Direction:is_vertical
385
386 --- Wraps `HB_DIRECTION_IS_FORWARD`.
387 -- @return a boolean value
388 -- @function Direction:is_forward
389
390 --- Wraps `HB_DIRECTION_IS_BACKWARD`.
391 -- @return a boolean value
392 -- @function Direction:is_backward
393
394 --- Predefined directions.
395 -- Predefined directions that correspond to their original definitions in Harfbuzz.
396 -- @section predefined-directions
397
398 --- Wraps `HB_DIRECTION_LTR`.
399 -- @field Direction.LTR
400
401 --- Wraps `HB_DIRECTION_RTL`.
402 -- @field Direction.RTL
403
404 --- Wraps `HB_DIRECTION_TTB`.
405 -- @field Direction.TTB
406
407 --- Wraps `HB_DIRECTION_LTR`.
408 -- @field Direction.BTT
409
410 --- Lua wrapper for `hb_language_t` type.
411 -- @type Language
412
413 --- Wraps `hb_language_from_string`.
414 -- @param lang [three-letter language tag](http://www.microsoft.com/typography/otspec/languagetags.htm) to be converted to a `Language` object.
415 -- @return a `Language` object.
416 -- @function Language.new
417
418 --- Wraps `hb_language_to_string`. Enable nice output with `tostring(…)`.
419 -- @return Returns a string representation for the language object.
420 -- @function Language:__tostring
421
422 --- Enables equality comparisions with `==` between two languages.
423 -- @return `true` or `false` depending on whether the two languages are equal.
424 -- @function Language:__eq
425
426 --- Predefined languages.
427 -- Predefined languages that correspond to their original definitions in Harfbuzz.
428 -- @section predefined-languages
429
430 --- Wraps `HB_LANGUAGE_INVALID`.
431 -- @field Language.INVALID
432
433
434 --- Lua wrapper for `hb_set_t` type.
435 --
436 -- Set objects represent a mathematical set of integer values.
437 --
438 -- @type Set
439
440 --- Wraps `hb_set_add`.
441 --
442 -- Adds a codepoint to the set.
443 --
444 -- @param codepoint The element to add.
445 -- @function Set:add
446
447
448 --- Unicode functions.
449 -- @section unicode-functions
450
451 --- Wraps `hb_unicode_script`
452 -- @param char Unicode codepoint
453 -- @return a `Script` object.
454 -- @function unicode.script
455
456
457 --- Predefined Name IDs.
458 -- Predefined OpenType 'name' table name identifier.
459 -- @section predefined-name-ids
460
461 --- Wraps `HB_OT_NAME_ID_COPYRIGHT`
462 -- @field ot.NAME_ID_COPYRIGHT
463
464 --- Wraps `HB_OT_NAME_ID_FONT_FAMILY`
465 -- @field ot.NAME_ID_FONT_FAMILY
466
467 --- Wraps `HB_OT_NAME_ID_FONT_SUBFAMILY`
468 -- @field ot.NAME_ID_FONT_SUBFAMILY
469
470 --- Wraps `HB_OT_NAME_ID_UNIQUE_ID`
471 -- @field ot.NAME_ID_UNIQUE_ID
472
473 --- Wraps `HB_OT_NAME_ID_FULL_NAME`
474 -- @field ot.NAME_ID_FULL_NAME
475
476 --- Wraps `HB_OT_NAME_ID_VERSION_STRING`
477 -- @field ot.NAME_ID_VERSION_STRING
478
479 --- Wraps `HB_OT_NAME_ID_POSTSCRIPT_NAME`
480 -- @field ot.NAME_ID_POSTSCRIPT_NAME
481
482 --- Wraps `HB_OT_NAME_ID_TRADEMARK`
483 -- @field ot.NAME_ID_TRADEMARK
484
485 --- Wraps `HB_OT_NAME_ID_MANUFACTURER`
486 -- @field ot.NAME_ID_MANUFACTURER
487
488 --- Wraps `HB_OT_NAME_ID_DESIGNER`
489 -- @field ot.NAME_ID_DESIGNER
490
491 --- Wraps `HB_OT_NAME_ID_DESCRIPTION`
492 -- @field ot.NAME_ID_DESCRIPTION
493
494 --- Wraps `HB_OT_NAME_ID_VENDOR_URL`
495 -- @field ot.NAME_ID_VENDOR_URL
496
497 --- Wraps `HB_OT_NAME_ID_DESIGNER_URL`
498 -- @field ot.NAME_ID_DESIGNER_URL
499
500 --- Wraps `HB_OT_NAME_ID_LICENSE`
501 -- @field ot.NAME_ID_LICENSE
502
503 --- Wraps `HB_OT_NAME_ID_LICENSE_URL`
504 -- @field ot.NAME_ID_LICENSE_URL
505
506 --- Wraps `HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY`
507 -- @field ot.NAME_ID_TYPOGRAPHIC_FAMILY
508
509 --- Wraps `HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY`
510 -- @field ot.NAME_ID_TYPOGRAPHIC_SUBFAMILY
511
512 --- Wraps `HB_OT_NAME_ID_MAC_FULL_NAME`
513 -- @field ot.NAME_ID_MAC_FULL_NAME
514
515 --- Wraps `HB_OT_NAME_ID_SAMPLE_TEXT`
516 -- @field ot.NAME_ID_SAMPLE_TEXT
517
518 --- Wraps `HB_OT_NAME_ID_CID_FINDFONT_NAME`
519 -- @field ot.NAME_ID_CID_FINDFONT_NAME
520
521 --- Wraps `HB_OT_NAME_ID_WWS_FAMILY`
522 -- @field ot.NAME_ID_WWS_FAMILY
523
524 --- Wraps `HB_OT_NAME_ID_WWS_SUBFAMILY`
525 -- @field ot.NAME_ID_WWS_SUBFAMILY
526
527 --- Wraps `HB_OT_NAME_ID_LIGHT_BACKGROUND`
528 -- @field ot.NAME_ID_LIGHT_BACKGROUND
529
530 --- Wraps `HB_OT_NAME_ID_DARK_BACKGROUND`
531 -- @field ot.NAME_ID_DARK_BACKGROUND
532
533 --- Wraps `HB_OT_NAME_ID_VARIATIONS_PS_PREFIX`
534 -- @field ot.NAME_ID_VARIATIONS_PS_PREFIX
535
536 --- Wraps `HB_OT_NAME_ID_INVALID`
537 -- @field ot.NAME_ID_INVALID
538
539 --- Wraps `HB_OT_LAYOUT_NO_SCRIPT_INDEX`
540 -- @field ot.LAYOUT_NO_SCRIPT_INDEX
541
542 --- Wraps `HB_OT_LAYOUT_NO_FEATURE_INDEX`
543 -- @field ot.LAYOUT_NO_FEATURE_INDEX
544
545 --- Wraps `HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX`
546 -- @field ot.LAYOUT_DEFAULT_LANGUAGE_INDEX
547
548 --- Wraps `HB_OT_LAYOUT_NO_VARIATIONS_INDEX`
549 -- @field ot.LAYOUT_NO_VARIATIONS_INDEX