1 | /* |
2 | * Copyright © 2016 Igalia S.L. |
3 | * |
4 | * This is part of HarfBuzz, a text shaping library. |
5 | * |
6 | * Permission is hereby granted, without written agreement and without |
7 | * license or royalty fees, to use, copy, modify, and distribute this |
8 | * software and its documentation for any purpose, provided that the |
9 | * above copyright notice and the following two paragraphs appear in |
10 | * all copies of this software. |
11 | * |
12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
16 | * DAMAGE. |
17 | * |
18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
23 | * |
24 | * Igalia Author(s): Frédéric Wang |
25 | */ |
26 | |
27 | #ifndef HB_OT_H_IN |
28 | #error "Include <hb-ot.h> instead." |
29 | #endif |
30 | |
31 | #ifndef HB_OT_MATH_H |
32 | #define HB_OT_MATH_H |
33 | |
34 | #include "hb.h" |
35 | |
36 | HB_BEGIN_DECLS |
37 | |
38 | |
39 | /* |
40 | * MATH |
41 | */ |
42 | |
43 | #define HB_OT_TAG_MATH HB_TAG('M','A','T','H') |
44 | |
45 | /* Use with hb_buffer_set_script() for math shaping. */ |
46 | #define HB_OT_MATH_SCRIPT HB_TAG('m','a','t','h') |
47 | |
48 | /* Types */ |
49 | |
50 | /** |
51 | * hb_ot_math_constant_t: |
52 | * |
53 | * The 'MATH' table constants specified at |
54 | * https://docs.microsoft.com/en-us/typography/opentype/spec/math |
55 | * |
56 | * Since: 1.3.3 |
57 | */ |
58 | typedef enum { |
59 | HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN = 0, |
60 | HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN = 1, |
61 | HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT = 2, |
62 | HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT = 3, |
63 | HB_OT_MATH_CONSTANT_MATH_LEADING = 4, |
64 | HB_OT_MATH_CONSTANT_AXIS_HEIGHT = 5, |
65 | HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT = 6, |
66 | HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT = 7, |
67 | HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN = 8, |
68 | HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX = 9, |
69 | HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN = 10, |
70 | HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP = 11, |
71 | HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED = 12, |
72 | HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN = 13, |
73 | HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX = 14, |
74 | HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN = 15, |
75 | HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT = 16, |
76 | HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT = 17, |
77 | HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN = 18, |
78 | HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN = 19, |
79 | HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN = 20, |
80 | HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN = 21, |
81 | HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP = 22, |
82 | HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP = 23, |
83 | HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN = 24, |
84 | HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN = 25, |
85 | HB_OT_MATH_CONSTANT_STACK_GAP_MIN = 26, |
86 | HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN = 27, |
87 | HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP = 28, |
88 | HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN = 29, |
89 | HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN = 30, |
90 | HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN = 31, |
91 | HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP = 32, |
92 | HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP = 33, |
93 | HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN = 34, |
94 | HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN = 35, |
95 | HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN = 36, |
96 | HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN = 37, |
97 | HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS = 38, |
98 | HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN = 39, |
99 | HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN = 40, |
100 | HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP = 41, |
101 | HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP = 42, |
102 | HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP = 43, |
103 | HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS = 44, |
104 | = 45, |
105 | HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP = 46, |
106 | HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS = 47, |
107 | = 48, |
108 | HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP = 49, |
109 | HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP = 50, |
110 | HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS = 51, |
111 | = 52, |
112 | HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE = 53, |
113 | HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE = 54, |
114 | HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT = 55 |
115 | } hb_ot_math_constant_t; |
116 | |
117 | /** |
118 | * hb_ot_math_kern_t: |
119 | * |
120 | * The math kerning-table types defined for the four corners |
121 | * of a glyph. |
122 | * |
123 | * Since: 1.3.3 |
124 | */ |
125 | typedef enum { |
126 | HB_OT_MATH_KERN_TOP_RIGHT = 0, |
127 | HB_OT_MATH_KERN_TOP_LEFT = 1, |
128 | HB_OT_MATH_KERN_BOTTOM_RIGHT = 2, |
129 | HB_OT_MATH_KERN_BOTTOM_LEFT = 3 |
130 | } hb_ot_math_kern_t; |
131 | |
132 | /** |
133 | * hb_ot_math_glyph_variant_t: |
134 | * @glyph: The glyph index of the variant |
135 | * @advance: The advance width of the variant |
136 | * |
137 | * Data type to hold math-variant information for a glyph. |
138 | * |
139 | * Since: 1.3.3 |
140 | */ |
141 | typedef struct hb_ot_math_glyph_variant_t { |
142 | hb_codepoint_t glyph; |
143 | hb_position_t advance; |
144 | } hb_ot_math_glyph_variant_t; |
145 | |
146 | /** |
147 | * hb_ot_math_glyph_part_flags_t: |
148 | * |
149 | * Flags for math glyph parts. |
150 | * |
151 | * Since: 1.3.3 |
152 | */ |
153 | typedef enum { /*< flags >*/ |
154 | HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER = 0x00000001u /* Extender glyph */ |
155 | } hb_ot_math_glyph_part_flags_t; |
156 | |
157 | /** |
158 | * hb_ot_math_glyph_part_t: |
159 | * @glyph: The glyph index of the variant part |
160 | * @start_connector_length: The length of the connector on the starting side of the variant part |
161 | * @end_connector_length: The length of the connector on the ending side of the variant part |
162 | * @full_advance: The total advance of the part |
163 | * @flags: #hb_ot_math_glyph_part_flags_t flags for the part |
164 | * |
165 | * Data type to hold information for a "part" component of a math-variant glyph. |
166 | * Large variants for stretchable math glyphs (such as parentheses) can be constructed |
167 | * on the fly from parts. |
168 | * |
169 | * Since: 1.3.3 |
170 | */ |
171 | typedef struct hb_ot_math_glyph_part_t { |
172 | hb_codepoint_t glyph; |
173 | hb_position_t start_connector_length; |
174 | hb_position_t end_connector_length; |
175 | hb_position_t full_advance; |
176 | hb_ot_math_glyph_part_flags_t flags; |
177 | } hb_ot_math_glyph_part_t; |
178 | |
179 | /* Methods */ |
180 | |
181 | HB_EXTERN hb_bool_t |
182 | hb_ot_math_has_data (hb_face_t *face); |
183 | |
184 | HB_EXTERN hb_position_t |
185 | hb_ot_math_get_constant (hb_font_t *font, |
186 | hb_ot_math_constant_t constant); |
187 | |
188 | HB_EXTERN hb_position_t |
189 | hb_ot_math_get_glyph_italics_correction (hb_font_t *font, |
190 | hb_codepoint_t glyph); |
191 | |
192 | HB_EXTERN hb_position_t |
193 | hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font, |
194 | hb_codepoint_t glyph); |
195 | |
196 | HB_EXTERN hb_bool_t |
197 | hb_ot_math_is_glyph_extended_shape (hb_face_t *face, |
198 | hb_codepoint_t glyph); |
199 | |
200 | HB_EXTERN hb_position_t |
201 | hb_ot_math_get_glyph_kerning (hb_font_t *font, |
202 | hb_codepoint_t glyph, |
203 | hb_ot_math_kern_t kern, |
204 | hb_position_t correction_height); |
205 | |
206 | HB_EXTERN unsigned int |
207 | hb_ot_math_get_glyph_variants (hb_font_t *font, |
208 | hb_codepoint_t glyph, |
209 | hb_direction_t direction, |
210 | unsigned int start_offset, |
211 | unsigned int *variants_count, /* IN/OUT */ |
212 | hb_ot_math_glyph_variant_t *variants /* OUT */); |
213 | |
214 | HB_EXTERN hb_position_t |
215 | hb_ot_math_get_min_connector_overlap (hb_font_t *font, |
216 | hb_direction_t direction); |
217 | |
218 | HB_EXTERN unsigned int |
219 | hb_ot_math_get_glyph_assembly (hb_font_t *font, |
220 | hb_codepoint_t glyph, |
221 | hb_direction_t direction, |
222 | unsigned int start_offset, |
223 | unsigned int *parts_count, /* IN/OUT */ |
224 | hb_ot_math_glyph_part_t *parts, /* OUT */ |
225 | hb_position_t *italics_correction /* OUT */); |
226 | |
227 | |
228 | HB_END_DECLS |
229 | |
230 | #endif /* HB_OT_MATH_H */ |
231 | |