pango-ot.h 14 KB

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