pango-ot.h 15 KB

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