1 | /* Pango |
2 | * pango-ot.h: |
3 | * |
4 | * Copyright (C) 2000,2007 Red Hat Software |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public |
17 | * License along with this library; if not, write to the |
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | * Boston, MA 02111-1307, USA. |
20 | */ |
21 | |
22 | #ifndef __PANGO_OT_H__ |
23 | #define __PANGO_OT_H__ |
24 | |
25 | /* Deprecated. Use HarfBuzz directly! */ |
26 | |
27 | #include <pango/pangofc-font.h> |
28 | #include <pango/pango-glyph.h> |
29 | #include <pango/pango-font.h> |
30 | #include <pango/pango-script.h> |
31 | #include <pango/pango-language.h> |
32 | |
33 | #include <ft2build.h> |
34 | #include FT_FREETYPE_H |
35 | |
36 | G_BEGIN_DECLS |
37 | |
38 | #ifndef PANGO_DISABLE_DEPRECATED |
39 | |
40 | /** |
41 | * PangoOTTag: |
42 | * |
43 | * The `PangoOTTag` typedef is used to represent TrueType and OpenType |
44 | * four letter tags inside Pango. Use PANGO_OT_TAG_MAKE() |
45 | * or PANGO_OT_TAG_MAKE_FROM_STRING() macros to create PangoOTTags manually. |
46 | */ |
47 | typedef guint32 PangoOTTag; |
48 | |
49 | /** |
50 | * PANGO_OT_TAG_MAKE: |
51 | * @c1: First character. |
52 | * @c2: Second character. |
53 | * @c3: Third character. |
54 | * @c4: Fourth character. |
55 | * |
56 | * Creates a `PangoOTTag` from four characters. This is similar and |
57 | * compatible with the FT_MAKE_TAG() macro from FreeType. |
58 | */ |
59 | /** |
60 | * PANGO_OT_TAG_MAKE_FROM_STRING: |
61 | * @s: The string representation of the tag. |
62 | * |
63 | * Creates a `PangoOTTag` from a string. The string should be at least |
64 | * four characters long (pad with space characters if needed), and need |
65 | * not be nul-terminated. This is a convenience wrapper around |
66 | * PANGO_OT_TAG_MAKE(), but cannot be used in certain situations, for |
67 | * example, as a switch expression, as it dereferences pointers. |
68 | */ |
69 | #define PANGO_OT_TAG_MAKE(c1,c2,c3,c4) ((PangoOTTag) FT_MAKE_TAG (c1, c2, c3, c4)) |
70 | #define PANGO_OT_TAG_MAKE_FROM_STRING(s) (PANGO_OT_TAG_MAKE(((const char *) s)[0], \ |
71 | ((const char *) s)[1], \ |
72 | ((const char *) s)[2], \ |
73 | ((const char *) s)[3])) |
74 | |
75 | typedef struct _PangoOTInfo PangoOTInfo; |
76 | typedef struct _PangoOTBuffer PangoOTBuffer; |
77 | typedef struct _PangoOTGlyph PangoOTGlyph; |
78 | typedef struct _PangoOTRuleset PangoOTRuleset; |
79 | typedef struct _PangoOTFeatureMap PangoOTFeatureMap; |
80 | typedef struct _PangoOTRulesetDescription PangoOTRulesetDescription; |
81 | |
82 | /** |
83 | * PangoOTTableType: |
84 | * @PANGO_OT_TABLE_GSUB: The GSUB table. |
85 | * @PANGO_OT_TABLE_GPOS: The GPOS table. |
86 | * |
87 | * The PangoOTTableType enumeration values are used to |
88 | * identify the various OpenType tables in the |
89 | * pango_ot_info_… functions. |
90 | */ |
91 | typedef enum |
92 | { |
93 | PANGO_OT_TABLE_GSUB, |
94 | PANGO_OT_TABLE_GPOS |
95 | } PangoOTTableType; |
96 | |
97 | /** |
98 | * PANGO_OT_ALL_GLYPHS: |
99 | * |
100 | * This is used as the property bit in pango_ot_ruleset_add_feature() when a |
101 | * feature should be applied to all glyphs. |
102 | * |
103 | * Since: 1.16 |
104 | */ |
105 | /** |
106 | * PANGO_OT_NO_FEATURE: |
107 | * |
108 | * This is used as a feature index that represent no feature, that is, should be |
109 | * skipped. It may be returned as feature index by pango_ot_info_find_feature() |
110 | * if the feature is not found, and pango_ot_ruleset_add_feature() function |
111 | * automatically skips this value, so no special handling is required by the user. |
112 | * |
113 | * Since: 1.18 |
114 | */ |
115 | /** |
116 | * PANGO_OT_NO_SCRIPT: |
117 | * |
118 | * This is used as a script index that represent no script, that is, when the |
119 | * requested script was not found, and a default ('DFLT') script was not found |
120 | * either. It may be returned as script index by pango_ot_info_find_script() |
121 | * if the script or a default script are not found, all other functions |
122 | * taking a script index essentially return if the input script index is |
123 | * this value, so no special handling is required by the user. |
124 | * |
125 | * Since: 1.18 |
126 | */ |
127 | /** |
128 | * PANGO_OT_DEFAULT_LANGUAGE: |
129 | * |
130 | * This is used as the language index in pango_ot_info_find_feature() when |
131 | * the default language system of the script is desired. |
132 | * |
133 | * It is also returned by pango_ot_info_find_language() if the requested language |
134 | * is not found, or the requested language tag was PANGO_OT_TAG_DEFAULT_LANGUAGE. |
135 | * The end result is that one can always call pango_ot_tag_from_language() |
136 | * followed by pango_ot_info_find_language() and pass the result to |
137 | * pango_ot_info_find_feature() without having to worry about falling back to |
138 | * default language system explicitly. |
139 | * |
140 | * Since: 1.16 |
141 | */ |
142 | #define PANGO_OT_ALL_GLYPHS ((guint) 0xFFFF) |
143 | #define PANGO_OT_NO_FEATURE ((guint) 0xFFFF) |
144 | #define PANGO_OT_NO_SCRIPT ((guint) 0xFFFF) |
145 | #define PANGO_OT_DEFAULT_LANGUAGE ((guint) 0xFFFF) |
146 | |
147 | /** |
148 | * PANGO_OT_TAG_DEFAULT_SCRIPT: |
149 | * |
150 | * This is a `PangoOTTag` representing the special script tag 'DFLT'. It is |
151 | * returned as script tag by pango_ot_tag_from_script() if the requested script |
152 | * is not found. |
153 | * |
154 | * Since: 1.18 |
155 | */ |
156 | /** |
157 | * PANGO_OT_TAG_DEFAULT_LANGUAGE: |
158 | * |
159 | * This is a `PangoOTTag` representing a special language tag 'dflt'. It is |
160 | * returned as language tag by pango_ot_tag_from_language() if the requested |
161 | * language is not found. It is safe to pass this value to |
162 | * pango_ot_info_find_language() as that function falls back to returning default |
163 | * language-system if the requested language tag is not found. |
164 | * |
165 | * Since: 1.18 |
166 | */ |
167 | #define PANGO_OT_TAG_DEFAULT_SCRIPT PANGO_OT_TAG_MAKE ('D', 'F', 'L', 'T') |
168 | #define PANGO_OT_TAG_DEFAULT_LANGUAGE PANGO_OT_TAG_MAKE ('d', 'f', 'l', 't') |
169 | |
170 | /* Note that this must match hb_glyph_info_t */ |
171 | /** |
172 | * PangoOTGlyph: |
173 | * @glyph: the glyph itself. |
174 | * @properties: the properties value, identifying which features should be |
175 | * applied on this glyph. See pango_ot_ruleset_add_feature(). |
176 | * @cluster: the cluster that this glyph belongs to. |
177 | * @component: a component value, set by the OpenType layout engine. |
178 | * @ligID: a ligature index value, set by the OpenType layout engine. |
179 | * @internal: for Pango internal use |
180 | * |
181 | * The `PangoOTGlyph` structure represents a single glyph together with |
182 | * information used for OpenType layout processing of the glyph. |
183 | * It contains the following fields. |
184 | */ |
185 | struct _PangoOTGlyph |
186 | { |
187 | guint32 glyph; |
188 | guint properties; |
189 | guint cluster; |
190 | gushort component; |
191 | gushort ligID; |
192 | |
193 | guint internal; |
194 | }; |
195 | |
196 | /** |
197 | * PangoOTFeatureMap: |
198 | * @feature_name: feature tag in represented as four-letter ASCII string. |
199 | * @property_bit: the property bit to use for this feature. See |
200 | * pango_ot_ruleset_add_feature() for details. |
201 | * |
202 | * The `PangoOTFeatureMap` typedef is used to represent an OpenType |
203 | * feature with the property bit associated with it. The feature tag is |
204 | * represented as a char array instead of a `PangoOTTag` for convenience. |
205 | * |
206 | * Since: 1.18 |
207 | */ |
208 | struct _PangoOTFeatureMap |
209 | { |
210 | char feature_name[5]; |
211 | gulong property_bit; |
212 | }; |
213 | |
214 | /** |
215 | * PangoOTRulesetDescription: |
216 | * @script: a `PangoScript` |
217 | * @language: a `PangoLanguage` |
218 | * @static_gsub_features: (nullable): static map of GSUB features |
219 | * @n_static_gsub_features: length of @static_gsub_features, or 0. |
220 | * @static_gpos_features: (nullable): static map of GPOS features |
221 | * @n_static_gpos_features: length of @static_gpos_features, or 0. |
222 | * @other_features: (nullable): map of extra features to add to both |
223 | * GSUB and GPOS. Unlike the static maps, this pointer need not |
224 | * live beyond the life of function calls taking this struct. |
225 | * @n_other_features: length of @other_features, or 0. |
226 | * |
227 | * The `PangoOTRuleset` structure holds all the information needed |
228 | * to build a complete `PangoOTRuleset` from an OpenType font. |
229 | * The main use of this struct is to act as the key for a per-font |
230 | * hash of rulesets. The user populates a ruleset description and |
231 | * gets the ruleset using pango_ot_ruleset_get_for_description() |
232 | * or create a new one using pango_ot_ruleset_new_from_description(). |
233 | * |
234 | * Since: 1.18 |
235 | */ |
236 | struct _PangoOTRulesetDescription { |
237 | PangoScript script; |
238 | PangoLanguage *language; |
239 | const PangoOTFeatureMap *static_gsub_features; |
240 | guint n_static_gsub_features; |
241 | const PangoOTFeatureMap *static_gpos_features; |
242 | guint n_static_gpos_features; |
243 | const PangoOTFeatureMap *other_features; |
244 | guint n_other_features; |
245 | }; |
246 | |
247 | #ifdef __GI_SCANNER__ |
248 | #define PANGO_OT_TYPE_INFO (pango_ot_info_get_type ()) |
249 | #define PANGO_OT_INFO(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_OT_TYPE_INFO, PangoOTInfo)) |
250 | #define PANGO_OT_IS_INFO(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_OT_TYPE_INFO)) |
251 | #else |
252 | #define PANGO_TYPE_OT_INFO (pango_ot_info_get_type ()) |
253 | #define PANGO_OT_INFO(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_OT_INFO, PangoOTInfo)) |
254 | #define PANGO_IS_OT_INFO(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_OT_INFO)) |
255 | #endif |
256 | |
257 | PANGO_DEPRECATED |
258 | GType pango_ot_info_get_type (void) G_GNUC_CONST; |
259 | |
260 | #ifdef __GI_SCANNER__ |
261 | #define PANGO_OT_TYPE_RULESET (pango_ot_ruleset_get_type ()) |
262 | #define PANGO_OT_RULESET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_OT_TYPE_RULESET, PangoOTRuleset)) |
263 | #define PANGO_OT_IS_RULESET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_OT_TYPE_RULESET)) |
264 | #else |
265 | #define PANGO_TYPE_OT_RULESET (pango_ot_ruleset_get_type ()) |
266 | #define PANGO_OT_RULESET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_OT_RULESET, PangoOTRuleset)) |
267 | #define PANGO_IS_OT_RULESET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_OT_RULESET)) |
268 | #endif |
269 | |
270 | PANGO_DEPRECATED |
271 | GType pango_ot_ruleset_get_type (void) G_GNUC_CONST; |
272 | |
273 | |
274 | PANGO_DEPRECATED |
275 | PangoOTInfo *pango_ot_info_get (FT_Face face); |
276 | |
277 | PANGO_DEPRECATED |
278 | gboolean pango_ot_info_find_script (PangoOTInfo *info, |
279 | PangoOTTableType table_type, |
280 | PangoOTTag script_tag, |
281 | guint *script_index); |
282 | |
283 | PANGO_DEPRECATED |
284 | gboolean pango_ot_info_find_language (PangoOTInfo *info, |
285 | PangoOTTableType table_type, |
286 | guint script_index, |
287 | PangoOTTag language_tag, |
288 | guint *language_index, |
289 | guint *required_feature_index); |
290 | PANGO_DEPRECATED |
291 | gboolean pango_ot_info_find_feature (PangoOTInfo *info, |
292 | PangoOTTableType table_type, |
293 | PangoOTTag feature_tag, |
294 | guint script_index, |
295 | guint language_index, |
296 | guint *feature_index); |
297 | |
298 | PANGO_DEPRECATED |
299 | PangoOTTag *pango_ot_info_list_scripts (PangoOTInfo *info, |
300 | PangoOTTableType table_type); |
301 | PANGO_DEPRECATED |
302 | PangoOTTag *pango_ot_info_list_languages (PangoOTInfo *info, |
303 | PangoOTTableType table_type, |
304 | guint script_index, |
305 | PangoOTTag language_tag); |
306 | PANGO_DEPRECATED |
307 | PangoOTTag *pango_ot_info_list_features (PangoOTInfo *info, |
308 | PangoOTTableType table_type, |
309 | PangoOTTag tag, |
310 | guint script_index, |
311 | guint language_index); |
312 | |
313 | #ifdef __GI_SCANNER__ |
314 | #define PANGO_OT_TYPE_BUFFER (pango_ot_buffer_get_type()) |
315 | #else |
316 | #define PANGO_TYPE_OT_BUFFER (pango_ot_buffer_get_type()) |
317 | #endif |
318 | |
319 | PANGO_DEPRECATED |
320 | GType pango_ot_buffer_get_type (void) G_GNUC_CONST; |
321 | |
322 | PANGO_DEPRECATED |
323 | PangoOTBuffer *pango_ot_buffer_new (PangoFcFont *font); |
324 | PANGO_DEPRECATED |
325 | void pango_ot_buffer_destroy (PangoOTBuffer *buffer); |
326 | PANGO_DEPRECATED |
327 | void pango_ot_buffer_clear (PangoOTBuffer *buffer); |
328 | PANGO_DEPRECATED |
329 | void pango_ot_buffer_set_rtl (PangoOTBuffer *buffer, |
330 | gboolean rtl); |
331 | PANGO_DEPRECATED |
332 | void pango_ot_buffer_add_glyph (PangoOTBuffer *buffer, |
333 | guint glyph, |
334 | guint properties, |
335 | guint cluster); |
336 | PANGO_DEPRECATED |
337 | void pango_ot_buffer_get_glyphs (const PangoOTBuffer *buffer, |
338 | PangoOTGlyph **glyphs, |
339 | int *n_glyphs); |
340 | PANGO_DEPRECATED |
341 | void pango_ot_buffer_output (const PangoOTBuffer *buffer, |
342 | PangoGlyphString *glyphs); |
343 | |
344 | PANGO_DEPRECATED |
345 | void pango_ot_buffer_set_zero_width_marks (PangoOTBuffer *buffer, |
346 | gboolean zero_width_marks); |
347 | |
348 | PANGO_DEPRECATED |
349 | const PangoOTRuleset *pango_ot_ruleset_get_for_description (PangoOTInfo *info, |
350 | const PangoOTRulesetDescription *desc); |
351 | PANGO_DEPRECATED |
352 | PangoOTRuleset *pango_ot_ruleset_new (PangoOTInfo *info); |
353 | PANGO_DEPRECATED |
354 | PangoOTRuleset *pango_ot_ruleset_new_for (PangoOTInfo *info, |
355 | PangoScript script, |
356 | PangoLanguage *language); |
357 | PANGO_DEPRECATED |
358 | PangoOTRuleset *pango_ot_ruleset_new_from_description (PangoOTInfo *info, |
359 | const PangoOTRulesetDescription *desc); |
360 | PANGO_DEPRECATED |
361 | void pango_ot_ruleset_add_feature (PangoOTRuleset *ruleset, |
362 | PangoOTTableType table_type, |
363 | guint feature_index, |
364 | gulong property_bit); |
365 | PANGO_DEPRECATED |
366 | gboolean pango_ot_ruleset_maybe_add_feature (PangoOTRuleset *ruleset, |
367 | PangoOTTableType table_type, |
368 | PangoOTTag feature_tag, |
369 | gulong property_bit); |
370 | PANGO_DEPRECATED |
371 | guint pango_ot_ruleset_maybe_add_features (PangoOTRuleset *ruleset, |
372 | PangoOTTableType table_type, |
373 | const PangoOTFeatureMap *features, |
374 | guint n_features); |
375 | PANGO_DEPRECATED |
376 | guint pango_ot_ruleset_get_feature_count (const PangoOTRuleset *ruleset, |
377 | guint *n_gsub_features, |
378 | guint *n_gpos_features); |
379 | |
380 | PANGO_DEPRECATED |
381 | void pango_ot_ruleset_substitute (const PangoOTRuleset *ruleset, |
382 | PangoOTBuffer *buffer); |
383 | |
384 | PANGO_DEPRECATED |
385 | void pango_ot_ruleset_position (const PangoOTRuleset *ruleset, |
386 | PangoOTBuffer *buffer); |
387 | |
388 | PANGO_DEPRECATED |
389 | PangoScript pango_ot_tag_to_script (PangoOTTag script_tag) G_GNUC_CONST; |
390 | |
391 | PANGO_DEPRECATED |
392 | PangoOTTag pango_ot_tag_from_script (PangoScript script) G_GNUC_CONST; |
393 | |
394 | PANGO_DEPRECATED |
395 | PangoLanguage *pango_ot_tag_to_language (PangoOTTag language_tag) G_GNUC_CONST; |
396 | |
397 | PANGO_DEPRECATED |
398 | PangoOTTag pango_ot_tag_from_language (PangoLanguage *language) G_GNUC_CONST; |
399 | |
400 | #ifdef __GI_SCANNER__ |
401 | #define PANGO_OT_TYPE_RULESET_DESCRIPTION (pango_ot_ruleset_description_get_type()) |
402 | #else |
403 | #define PANGO_TYPE_OT_RULESET_DESCRIPTION (pango_ot_ruleset_description_get_type()) |
404 | #endif |
405 | |
406 | PANGO_DEPRECATED |
407 | GType pango_ot_ruleset_description_get_type (void) G_GNUC_CONST; |
408 | |
409 | PANGO_DEPRECATED |
410 | guint pango_ot_ruleset_description_hash (const PangoOTRulesetDescription *desc) G_GNUC_PURE; |
411 | |
412 | PANGO_DEPRECATED |
413 | gboolean pango_ot_ruleset_description_equal (const PangoOTRulesetDescription *desc1, |
414 | const PangoOTRulesetDescription *desc2) G_GNUC_PURE; |
415 | |
416 | PANGO_DEPRECATED |
417 | PangoOTRulesetDescription *pango_ot_ruleset_description_copy (const PangoOTRulesetDescription *desc); |
418 | |
419 | PANGO_DEPRECATED |
420 | void pango_ot_ruleset_description_free (PangoOTRulesetDescription *desc); |
421 | |
422 | |
423 | #endif /* PANGO_DISABLE_DEPRECATED */ |
424 | |
425 | G_END_DECLS |
426 | |
427 | #endif /* __PANGO_OT_H__ */ |
428 | |