Debian Codegraph @

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

raw
1 -----------
2 -- Lua bindings to the Harfbuzz subset API.
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 -- This module provides bindings to the HarfBuzz `hb-subset` API. It is
8 -- designed to be used together with the main @{harfbuzz} module.
9 --
10 -- Typical usage:
11 --
12 -- local hb = require('harfbuzz')
13 -- local hb_subset = require("harfbuzzsubset")
14 --
15 -- local input = hb_subset.SubsetInput.new()
16 --
17 -- local wght = hb.Tag.new("wght")
18 -- local wdth = hb.Tag.new("wdth")
19 -- local face = hb.Face.new("myfont.ttf")
20 --
21 -- input:pin_axis_location(face, wght, 100)
22 -- input:pin_axis_location(face, wdth, 100)
23 --
24 -- input:keep_everything()
25 --
26 -- local new_face = hb_subset.subset(face, input)
27 --
28 -- local blob = new_face:blob()
29 -- local fh, err = io.open("out.ttf", "wb")
30 -- if not fh then error(err) end
31 -- fh:write(blob:get_data())
32 -- fh:close()
33 --
34 -- @author Patrick Gundlach <<[email protected]>>
35 -- @copyright 2025
36 -- @license MIT
37 -- @module harfbuzzsubset
38
39
40 --- Wraps `hb_subset_or_fail`.
41 --
42 -- Performs the actual subset operation, producing a new `Face` that only
43 -- contains the glyphs and data configured on this input.
44 --
45 -- @param face source `Face` object to subset.
46 -- @param input `SubsetInput` object to subset based on.
47 -- @return new `Face` object representing the subset, or `nil` on failure.
48 -- @function subset
49
50
51 --- Wraps `hb_version`.
52 -- @function version
53
54 --- Lua wrapper for `hb_subset_input_t` type.
55 --
56 -- Objects of this type control which parts of a `Face` are kept when
57 -- creating a subset.
58 --
59 -- Instances are usually created via @{SubsetInput.new}.
60 --
61 -- @type SubsetInput
62
63
64 --- Wraps `hb_subset_input_create_or_fail`.
65 --
66 -- Initializes a new `hb_subset_input_t`. The returned object can be used to
67 -- configure which glyphs and features are kept when subsetting a face.
68 --
69 -- @return `SubsetInput` object, or `nil` on failure.
70 -- @function SubsetInput.new
71
72
73 --- Wraps `hb_subset_input_unicode_set`.
74 --
75 -- Returns the Unicode set associated with this subset input. The returned
76 -- @{harfbuzz.Set} can be modified (e.g. via @{harfbuzz.Set:add}) to control which
77 -- Unicode codepoints are included in the subset.
78 --
79 -- @return `Set` object representing the Unicode set, or `nil` on failure.
80 -- @function SubsetInput:unicode_set
81
82
83 --- Wraps `hb_subset_input_pin_axis_location`.
84 --
85 -- Pins a variation axis at a specific value for subsetting.
86 --
87 -- @param face `Face` object whose design space is being subset.
88 -- @param tag `Tag` object representing the axis tag (e.g. `"wght"`, `"wdth"`).
89 -- @param value numeric axis value to pin.
90 -- @return `true` on success, `false` on failure.
91 -- @function SubsetInput:pin_axis_location
92
93
94 --- Wraps `hb_subset_input_keep_everything`.
95 --
96 -- Configures the input so that everything in the original face is kept.
97 -- This is useful as a starting point before applying more specific filters.
98 --
99 -- @function SubsetInput:keep_everything
100
101
102 --- Wraps `hb_subset_input_destroy`.
103 --
104 -- Destructor for subset inputs. Normally this is invoked automatically by
105 -- the garbage collector; applications rarely need to call it directly.
106 --
107 -- @function SubsetInput:__gc