1 
2 //          Copyright Ahmet Sait Koçak 2020.
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          https://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.hb.bind.ot.math;
8 
9 import bindbc.hb.bind.common;
10 import bindbc.hb.bind.face;
11 import bindbc.hb.bind.font;
12 
13 extern(C) @nogc nothrow:
14 
15 /*
16  * MATH
17  */
18 
19 enum HB_OT_TAG_MATH = HB_TAG('M', 'A', 'T', 'H');
20 
21 /* Use with hb_buffer_set_script() for math shaping. */
22 enum HB_OT_MATH_SCRIPT = HB_TAG('m', 'a', 't', 'h');
23 
24 /* Types */
25 
26 /**
27  * hb_ot_math_constant_t:
28  *
29  * The 'MATH' table constants specified at
30  * https://docs.microsoft.com/en-us/typography/opentype/spec/math
31  *
32  * Since: 1.3.3
33  */
34 enum : int
35 {
36     HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN = 0,
37     HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN = 1,
38     HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT = 2,
39     HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT = 3,
40     HB_OT_MATH_CONSTANT_MATH_LEADING = 4,
41     HB_OT_MATH_CONSTANT_AXIS_HEIGHT = 5,
42     HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT = 6,
43     HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT = 7,
44     HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN = 8,
45     HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX = 9,
46     HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN = 10,
47     HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP = 11,
48     HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED = 12,
49     HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN = 13,
50     HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX = 14,
51     HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN = 15,
52     HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT = 16,
53     HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT = 17,
54     HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN = 18,
55     HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN = 19,
56     HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN = 20,
57     HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN = 21,
58     HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP = 22,
59     HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP = 23,
60     HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN = 24,
61     HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN = 25,
62     HB_OT_MATH_CONSTANT_STACK_GAP_MIN = 26,
63     HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN = 27,
64     HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP = 28,
65     HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN = 29,
66     HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN = 30,
67     HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN = 31,
68     HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP = 32,
69     HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP = 33,
70     HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN = 34,
71     HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN = 35,
72     HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN = 36,
73     HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN = 37,
74     HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS = 38,
75     HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN = 39,
76     HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN = 40,
77     HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP = 41,
78     HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP = 42,
79     HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP = 43,
80     HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS = 44,
81     HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER = 45,
82     HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP = 46,
83     HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS = 47,
84     HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER = 48,
85     HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP = 49,
86     HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP = 50,
87     HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS = 51,
88     HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER = 52,
89     HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE = 53,
90     HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE = 54,
91     HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT = 55
92 }
93 alias hb_ot_math_constant_t = int;
94 
95 /**
96  * hb_ot_math_kern_t:
97  *
98  * The math kerning-table types defined for the four corners
99  * of a glyph.
100  *
101  * Since: 1.3.3
102  */
103 enum : int
104 {
105     HB_OT_MATH_KERN_TOP_RIGHT = 0,
106     HB_OT_MATH_KERN_TOP_LEFT = 1,
107     HB_OT_MATH_KERN_BOTTOM_RIGHT = 2,
108     HB_OT_MATH_KERN_BOTTOM_LEFT = 3
109 }
110 alias hb_ot_math_kern_t = int;
111 
112 /**
113  * hb_ot_math_glyph_variant_t:
114  * @glyph: The glyph index of the variant
115  * @advance: The advance width of the variant
116  *
117  * Data type to hold math-variant information for a glyph.
118  *
119  * Since: 1.3.3
120  */
121 struct hb_ot_math_glyph_variant_t
122 {
123     hb_codepoint_t glyph;
124     hb_position_t advance;
125 }
126 
127 /**
128  * hb_ot_math_glyph_part_flags_t:
129  *
130  * Flags for math glyph parts.
131  *
132  * Since: 1.3.3
133  */
134 enum : uint
135 {
136     /*< flags >*/
137     HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER = 0x00000001u /* Extender glyph */
138 }
139 alias hb_ot_math_glyph_part_flags_t = uint;
140 
141 /**
142  * hb_ot_math_glyph_part_t:
143  * @glyph: The glyph index of the variant part
144  * @start_connector_length: The length of the connector on the starting side of the variant part
145  * @end_connector_length: The length of the connector on the ending side of the variant part
146  * @full_advance: The total advance of the part
147  * @flags: #hb_ot_math_glyph_part_flags_t flags for the part
148  *
149  * Data type to hold information for a "part" component of a math-variant glyph.
150  * Large variants for stretchable math glyphs (such as parentheses) can be constructed
151  * on the fly from parts.
152  *
153  * Since: 1.3.3
154  */
155 struct hb_ot_math_glyph_part_t
156 {
157     hb_codepoint_t glyph;
158     hb_position_t start_connector_length;
159     hb_position_t end_connector_length;
160     hb_position_t full_advance;
161     hb_ot_math_glyph_part_flags_t flags;
162 }
163 
164 /* Methods */
165 
166 version(BindHB_Static)
167     hb_bool_t hb_ot_math_has_data (hb_face_t* face);
168 else
169 {
170     private alias fp_hb_ot_math_has_data = hb_bool_t function (hb_face_t* face);
171     __gshared fp_hb_ot_math_has_data hb_ot_math_has_data;
172 }
173 
174 version(BindHB_Static)
175     hb_position_t hb_ot_math_get_constant (
176         hb_font_t* font,
177         hb_ot_math_constant_t constant);
178 else
179 {
180     private alias fp_hb_ot_math_get_constant = hb_position_t function (
181         hb_font_t* font,
182         hb_ot_math_constant_t constant);
183     __gshared fp_hb_ot_math_get_constant hb_ot_math_get_constant;
184 }
185 
186 version(BindHB_Static)
187     hb_position_t hb_ot_math_get_glyph_italics_correction (
188         hb_font_t* font,
189         hb_codepoint_t glyph);
190 else
191 {
192     private alias fp_hb_ot_math_get_glyph_italics_correction = hb_position_t function (
193         hb_font_t* font,
194         hb_codepoint_t glyph);
195     __gshared fp_hb_ot_math_get_glyph_italics_correction hb_ot_math_get_glyph_italics_correction;
196 }
197 
198 version(BindHB_Static)
199     hb_position_t hb_ot_math_get_glyph_top_accent_attachment (
200         hb_font_t* font,
201         hb_codepoint_t glyph);
202 else
203 {
204     private alias fp_hb_ot_math_get_glyph_top_accent_attachment = hb_position_t function (
205         hb_font_t* font,
206         hb_codepoint_t glyph);
207     __gshared fp_hb_ot_math_get_glyph_top_accent_attachment hb_ot_math_get_glyph_top_accent_attachment;
208 }
209 
210 version(BindHB_Static)
211     hb_bool_t hb_ot_math_is_glyph_extended_shape (
212         hb_face_t* face,
213         hb_codepoint_t glyph);
214 else
215 {
216     private alias fp_hb_ot_math_is_glyph_extended_shape = hb_bool_t function (
217         hb_face_t* face,
218         hb_codepoint_t glyph);
219     __gshared fp_hb_ot_math_is_glyph_extended_shape hb_ot_math_is_glyph_extended_shape;
220 }
221 
222 version(BindHB_Static)
223     hb_position_t hb_ot_math_get_glyph_kerning (
224         hb_font_t* font,
225         hb_codepoint_t glyph,
226         hb_ot_math_kern_t kern,
227         hb_position_t correction_height);
228 else
229 {
230     private alias fp_hb_ot_math_get_glyph_kerning = hb_position_t function (
231         hb_font_t* font,
232         hb_codepoint_t glyph,
233         hb_ot_math_kern_t kern,
234         hb_position_t correction_height);
235     __gshared fp_hb_ot_math_get_glyph_kerning hb_ot_math_get_glyph_kerning;
236 }
237 
238 /* IN/OUT */
239 /* OUT */
240 version(BindHB_Static)
241     uint hb_ot_math_get_glyph_variants (
242         hb_font_t* font,
243         hb_codepoint_t glyph,
244         hb_direction_t direction,
245         uint start_offset,
246         uint* variants_count,
247         hb_ot_math_glyph_variant_t* variants);
248 else
249 {
250     private alias fp_hb_ot_math_get_glyph_variants = uint function (
251         hb_font_t* font,
252         hb_codepoint_t glyph,
253         hb_direction_t direction,
254         uint start_offset,
255         uint* variants_count,
256         hb_ot_math_glyph_variant_t* variants);
257     __gshared fp_hb_ot_math_get_glyph_variants hb_ot_math_get_glyph_variants;
258 }
259 
260 version(BindHB_Static)
261     hb_position_t hb_ot_math_get_min_connector_overlap (
262         hb_font_t* font,
263         hb_direction_t direction);
264 else
265 {
266     private alias fp_hb_ot_math_get_min_connector_overlap = hb_position_t function (
267         hb_font_t* font,
268         hb_direction_t direction);
269     __gshared fp_hb_ot_math_get_min_connector_overlap hb_ot_math_get_min_connector_overlap;
270 }
271 
272 /* IN/OUT */
273 /* OUT */
274 /* OUT */
275 version(BindHB_Static)
276     uint hb_ot_math_get_glyph_assembly (
277         hb_font_t* font,
278         hb_codepoint_t glyph,
279         hb_direction_t direction,
280         uint start_offset,
281         uint* parts_count,
282         hb_ot_math_glyph_part_t* parts,
283         hb_position_t* italics_correction);
284 else
285 {
286     private alias fp_hb_ot_math_get_glyph_assembly = uint function (
287         hb_font_t* font,
288         hb_codepoint_t glyph,
289         hb_direction_t direction,
290         uint start_offset,
291         uint* parts_count,
292         hb_ot_math_glyph_part_t* parts,
293         hb_position_t* italics_correction);
294     __gshared fp_hb_ot_math_get_glyph_assembly hb_ot_math_get_glyph_assembly;
295 }