hb-ot-layout.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*
  2. * Copyright © 2007,2008,2009 Red Hat, Inc.
  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. * Red Hat Author(s): Behdad Esfahbod
  25. */
  26. #ifndef HB_OT_H_IN
  27. #error "Include <hb-ot.h> instead."
  28. #endif
  29. #ifndef HB_OT_LAYOUT_H
  30. #define HB_OT_LAYOUT_H
  31. #include "hb.h"
  32. #include "hb-ot-tag.h"
  33. HB_BEGIN_DECLS
  34. #define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
  35. #define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
  36. #define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
  37. #define HB_OT_TAG_JSTF HB_TAG('J','S','T','F')
  38. /*
  39. * GDEF
  40. */
  41. HB_EXTERN hb_bool_t
  42. hb_ot_layout_has_glyph_classes (hb_face_t *face);
  43. typedef enum {
  44. HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0,
  45. HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 1,
  46. HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 2,
  47. HB_OT_LAYOUT_GLYPH_CLASS_MARK = 3,
  48. HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 4
  49. } hb_ot_layout_glyph_class_t;
  50. HB_EXTERN hb_ot_layout_glyph_class_t
  51. hb_ot_layout_get_glyph_class (hb_face_t *face,
  52. hb_codepoint_t glyph);
  53. HB_EXTERN void
  54. hb_ot_layout_get_glyphs_in_class (hb_face_t *face,
  55. hb_ot_layout_glyph_class_t klass,
  56. hb_set_t *glyphs /* OUT */);
  57. /* Not that useful. Provides list of attach points for a glyph that a
  58. * client may want to cache */
  59. HB_EXTERN unsigned int
  60. hb_ot_layout_get_attach_points (hb_face_t *face,
  61. hb_codepoint_t glyph,
  62. unsigned int start_offset,
  63. unsigned int *point_count /* IN/OUT */,
  64. unsigned int *point_array /* OUT */);
  65. /* Ligature caret positions */
  66. HB_EXTERN unsigned int
  67. hb_ot_layout_get_ligature_carets (hb_font_t *font,
  68. hb_direction_t direction,
  69. hb_codepoint_t glyph,
  70. unsigned int start_offset,
  71. unsigned int *caret_count /* IN/OUT */,
  72. hb_position_t *caret_array /* OUT */);
  73. /*
  74. * GSUB/GPOS feature query and enumeration interface
  75. */
  76. #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu
  77. #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu
  78. #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu
  79. HB_EXTERN unsigned int
  80. hb_ot_layout_table_get_script_tags (hb_face_t *face,
  81. hb_tag_t table_tag,
  82. unsigned int start_offset,
  83. unsigned int *script_count /* IN/OUT */,
  84. hb_tag_t *script_tags /* OUT */);
  85. HB_EXTERN hb_bool_t
  86. hb_ot_layout_table_find_script (hb_face_t *face,
  87. hb_tag_t table_tag,
  88. hb_tag_t script_tag,
  89. unsigned int *script_index);
  90. /* Like find_script, but takes zero-terminated array of scripts to test */
  91. HB_EXTERN hb_bool_t
  92. hb_ot_layout_table_choose_script (hb_face_t *face,
  93. hb_tag_t table_tag,
  94. const hb_tag_t *script_tags,
  95. unsigned int *script_index,
  96. hb_tag_t *chosen_script);
  97. HB_EXTERN unsigned int
  98. hb_ot_layout_table_get_feature_tags (hb_face_t *face,
  99. hb_tag_t table_tag,
  100. unsigned int start_offset,
  101. unsigned int *feature_count /* IN/OUT */,
  102. hb_tag_t *feature_tags /* OUT */);
  103. HB_EXTERN unsigned int
  104. hb_ot_layout_script_get_language_tags (hb_face_t *face,
  105. hb_tag_t table_tag,
  106. unsigned int script_index,
  107. unsigned int start_offset,
  108. unsigned int *language_count /* IN/OUT */,
  109. hb_tag_t *language_tags /* OUT */);
  110. HB_EXTERN hb_bool_t
  111. hb_ot_layout_script_find_language (hb_face_t *face,
  112. hb_tag_t table_tag,
  113. unsigned int script_index,
  114. hb_tag_t language_tag,
  115. unsigned int *language_index);
  116. HB_EXTERN hb_bool_t
  117. hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
  118. hb_tag_t table_tag,
  119. unsigned int script_index,
  120. unsigned int language_index,
  121. unsigned int *feature_index);
  122. HB_EXTERN hb_bool_t
  123. hb_ot_layout_language_get_required_feature (hb_face_t *face,
  124. hb_tag_t table_tag,
  125. unsigned int script_index,
  126. unsigned int language_index,
  127. unsigned int *feature_index,
  128. hb_tag_t *feature_tag);
  129. HB_EXTERN unsigned int
  130. hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
  131. hb_tag_t table_tag,
  132. unsigned int script_index,
  133. unsigned int language_index,
  134. unsigned int start_offset,
  135. unsigned int *feature_count /* IN/OUT */,
  136. unsigned int *feature_indexes /* OUT */);
  137. HB_EXTERN unsigned int
  138. hb_ot_layout_language_get_feature_tags (hb_face_t *face,
  139. hb_tag_t table_tag,
  140. unsigned int script_index,
  141. unsigned int language_index,
  142. unsigned int start_offset,
  143. unsigned int *feature_count /* IN/OUT */,
  144. hb_tag_t *feature_tags /* OUT */);
  145. HB_EXTERN hb_bool_t
  146. hb_ot_layout_language_find_feature (hb_face_t *face,
  147. hb_tag_t table_tag,
  148. unsigned int script_index,
  149. unsigned int language_index,
  150. hb_tag_t feature_tag,
  151. unsigned int *feature_index);
  152. HB_EXTERN unsigned int
  153. hb_ot_layout_feature_get_lookups (hb_face_t *face,
  154. hb_tag_t table_tag,
  155. unsigned int feature_index,
  156. unsigned int start_offset,
  157. unsigned int *lookup_count /* IN/OUT */,
  158. unsigned int *lookup_indexes /* OUT */);
  159. HB_EXTERN unsigned int
  160. hb_ot_layout_table_get_lookup_count (hb_face_t *face,
  161. hb_tag_t table_tag);
  162. HB_EXTERN void
  163. hb_ot_layout_collect_lookups (hb_face_t *face,
  164. hb_tag_t table_tag,
  165. const hb_tag_t *scripts,
  166. const hb_tag_t *languages,
  167. const hb_tag_t *features,
  168. hb_set_t *lookup_indexes /* OUT */);
  169. HB_EXTERN void
  170. hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
  171. hb_tag_t table_tag,
  172. unsigned int lookup_index,
  173. hb_set_t *glyphs_before, /* OUT. May be NULL */
  174. hb_set_t *glyphs_input, /* OUT. May be NULL */
  175. hb_set_t *glyphs_after, /* OUT. May be NULL */
  176. hb_set_t *glyphs_output /* OUT. May be NULL */);
  177. #ifdef HB_NOT_IMPLEMENTED
  178. typedef struct
  179. {
  180. const hb_codepoint_t *before,
  181. unsigned int before_length,
  182. const hb_codepoint_t *input,
  183. unsigned int input_length,
  184. const hb_codepoint_t *after,
  185. unsigned int after_length,
  186. } hb_ot_layout_glyph_sequence_t;
  187. typedef hb_bool_t
  188. (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font,
  189. hb_tag_t table_tag,
  190. unsigned int lookup_index,
  191. const hb_ot_layout_glyph_sequence_t *sequence,
  192. void *user_data);
  193. HB_EXTERN void
  194. Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face,
  195. hb_tag_t table_tag,
  196. unsigned int lookup_index,
  197. hb_ot_layout_glyph_sequence_func_t callback,
  198. void *user_data);
  199. #endif
  200. /*
  201. * GSUB
  202. */
  203. HB_EXTERN hb_bool_t
  204. hb_ot_layout_has_substitution (hb_face_t *face);
  205. HB_EXTERN hb_bool_t
  206. hb_ot_layout_lookup_would_substitute (hb_face_t *face,
  207. unsigned int lookup_index,
  208. const hb_codepoint_t *glyphs,
  209. unsigned int glyphs_length,
  210. hb_bool_t zero_context);
  211. HB_EXTERN void
  212. hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
  213. unsigned int lookup_index,
  214. hb_set_t *glyphs
  215. /*TODO , hb_bool_t inclusive */);
  216. #ifdef HB_NOT_IMPLEMENTED
  217. /* Note: You better have GDEF when using this API, or marks won't do much. */
  218. HB_EXTERN hb_bool_t
  219. Xhb_ot_layout_lookup_substitute (hb_font_t *font,
  220. unsigned int lookup_index,
  221. const hb_ot_layout_glyph_sequence_t *sequence,
  222. unsigned int out_size,
  223. hb_codepoint_t *glyphs_out, /* OUT */
  224. unsigned int *clusters_out, /* OUT */
  225. unsigned int *out_length /* OUT */);
  226. #endif
  227. /*
  228. * GPOS
  229. */
  230. HB_EXTERN hb_bool_t
  231. hb_ot_layout_has_positioning (hb_face_t *face);
  232. #ifdef HB_NOT_IMPLEMENTED
  233. /* Note: You better have GDEF when using this API, or marks won't do much. */
  234. HB_EXTERN hb_bool_t
  235. Xhb_ot_layout_lookup_position (hb_font_t *font,
  236. unsigned int lookup_index,
  237. const hb_ot_layout_glyph_sequence_t *sequence,
  238. hb_glyph_position_t *positions /* IN / OUT */);
  239. #endif
  240. /* Optical 'size' feature info. Returns true if found.
  241. * http://www.microsoft.com/typography/otspec/features_pt.htm#size */
  242. HB_EXTERN hb_bool_t
  243. hb_ot_layout_get_size_params (hb_face_t *face,
  244. unsigned int *design_size, /* OUT. May be NULL */
  245. unsigned int *subfamily_id, /* OUT. May be NULL */
  246. unsigned int *subfamily_name_id, /* OUT. May be NULL */
  247. unsigned int *range_start, /* OUT. May be NULL */
  248. unsigned int *range_end /* OUT. May be NULL */);
  249. HB_END_DECLS
  250. #endif /* HB_OT_LAYOUT_H */