hb-ot-layout.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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-name.h"
  33. HB_BEGIN_DECLS
  34. #define HB_OT_TAG_BASE HB_TAG('B','A','S','E')
  35. #define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
  36. #define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
  37. #define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
  38. #define HB_OT_TAG_JSTF HB_TAG('J','S','T','F')
  39. /*
  40. * Script & Language tags.
  41. */
  42. #define HB_OT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
  43. #define HB_OT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
  44. /**
  45. * HB_OT_MAX_TAGS_PER_SCRIPT:
  46. *
  47. * Since: 2.0.0
  48. **/
  49. #define HB_OT_MAX_TAGS_PER_SCRIPT 3u
  50. /**
  51. * HB_OT_MAX_TAGS_PER_LANGUAGE:
  52. *
  53. * Since: 2.0.0
  54. **/
  55. #define HB_OT_MAX_TAGS_PER_LANGUAGE 3u
  56. HB_EXTERN void
  57. hb_ot_tags_from_script_and_language (hb_script_t script,
  58. hb_language_t language,
  59. unsigned int *script_count /* IN/OUT */,
  60. hb_tag_t *script_tags /* OUT */,
  61. unsigned int *language_count /* IN/OUT */,
  62. hb_tag_t *language_tags /* OUT */);
  63. HB_EXTERN hb_script_t
  64. hb_ot_tag_to_script (hb_tag_t tag);
  65. HB_EXTERN hb_language_t
  66. hb_ot_tag_to_language (hb_tag_t tag);
  67. HB_EXTERN void
  68. hb_ot_tags_to_script_and_language (hb_tag_t script_tag,
  69. hb_tag_t language_tag,
  70. hb_script_t *script /* OUT */,
  71. hb_language_t *language /* OUT */);
  72. /*
  73. * GDEF
  74. */
  75. HB_EXTERN hb_bool_t
  76. hb_ot_layout_has_glyph_classes (hb_face_t *face);
  77. /**
  78. * hb_ot_layout_glyph_class_t:
  79. * @HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED: Glyphs not matching the other classifications
  80. * @HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH: Spacing, single characters, capable of accepting marks
  81. * @HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE: Glyphs that represent ligation of multiple characters
  82. * @HB_OT_LAYOUT_GLYPH_CLASS_MARK: Non-spacing, combining glyphs that represent marks
  83. * @HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT: Spacing glyphs that represent part of a single character
  84. *
  85. * The GDEF classes defined for glyphs.
  86. *
  87. **/
  88. typedef enum {
  89. HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0,
  90. HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 1,
  91. HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 2,
  92. HB_OT_LAYOUT_GLYPH_CLASS_MARK = 3,
  93. HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 4
  94. } hb_ot_layout_glyph_class_t;
  95. HB_EXTERN hb_ot_layout_glyph_class_t
  96. hb_ot_layout_get_glyph_class (hb_face_t *face,
  97. hb_codepoint_t glyph);
  98. HB_EXTERN void
  99. hb_ot_layout_get_glyphs_in_class (hb_face_t *face,
  100. hb_ot_layout_glyph_class_t klass,
  101. hb_set_t *glyphs /* OUT */);
  102. /* Not that useful. Provides list of attach points for a glyph that a
  103. * client may want to cache */
  104. HB_EXTERN unsigned int
  105. hb_ot_layout_get_attach_points (hb_face_t *face,
  106. hb_codepoint_t glyph,
  107. unsigned int start_offset,
  108. unsigned int *point_count /* IN/OUT */,
  109. unsigned int *point_array /* OUT */);
  110. /* Ligature caret positions */
  111. HB_EXTERN unsigned int
  112. hb_ot_layout_get_ligature_carets (hb_font_t *font,
  113. hb_direction_t direction,
  114. hb_codepoint_t glyph,
  115. unsigned int start_offset,
  116. unsigned int *caret_count /* IN/OUT */,
  117. hb_position_t *caret_array /* OUT */);
  118. /*
  119. * GSUB/GPOS feature query and enumeration interface
  120. */
  121. #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu
  122. #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu
  123. #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu
  124. #define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu
  125. HB_EXTERN unsigned int
  126. hb_ot_layout_table_get_script_tags (hb_face_t *face,
  127. hb_tag_t table_tag,
  128. unsigned int start_offset,
  129. unsigned int *script_count /* IN/OUT */,
  130. hb_tag_t *script_tags /* OUT */);
  131. HB_EXTERN hb_bool_t
  132. hb_ot_layout_table_find_script (hb_face_t *face,
  133. hb_tag_t table_tag,
  134. hb_tag_t script_tag,
  135. unsigned int *script_index);
  136. HB_EXTERN hb_bool_t
  137. hb_ot_layout_table_select_script (hb_face_t *face,
  138. hb_tag_t table_tag,
  139. unsigned int script_count,
  140. const hb_tag_t *script_tags,
  141. unsigned int *script_index /* OUT */,
  142. hb_tag_t *chosen_script /* OUT */);
  143. HB_EXTERN unsigned int
  144. hb_ot_layout_table_get_feature_tags (hb_face_t *face,
  145. hb_tag_t table_tag,
  146. unsigned int start_offset,
  147. unsigned int *feature_count /* IN/OUT */,
  148. hb_tag_t *feature_tags /* OUT */);
  149. HB_EXTERN unsigned int
  150. hb_ot_layout_script_get_language_tags (hb_face_t *face,
  151. hb_tag_t table_tag,
  152. unsigned int script_index,
  153. unsigned int start_offset,
  154. unsigned int *language_count /* IN/OUT */,
  155. hb_tag_t *language_tags /* OUT */);
  156. HB_EXTERN hb_bool_t
  157. hb_ot_layout_script_select_language (hb_face_t *face,
  158. hb_tag_t table_tag,
  159. unsigned int script_index,
  160. unsigned int language_count,
  161. const hb_tag_t *language_tags,
  162. unsigned int *language_index /* OUT */);
  163. HB_EXTERN hb_bool_t
  164. hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
  165. hb_tag_t table_tag,
  166. unsigned int script_index,
  167. unsigned int language_index,
  168. unsigned int *feature_index);
  169. HB_EXTERN hb_bool_t
  170. hb_ot_layout_language_get_required_feature (hb_face_t *face,
  171. hb_tag_t table_tag,
  172. unsigned int script_index,
  173. unsigned int language_index,
  174. unsigned int *feature_index,
  175. hb_tag_t *feature_tag);
  176. HB_EXTERN unsigned int
  177. hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
  178. hb_tag_t table_tag,
  179. unsigned int script_index,
  180. unsigned int language_index,
  181. unsigned int start_offset,
  182. unsigned int *feature_count /* IN/OUT */,
  183. unsigned int *feature_indexes /* OUT */);
  184. HB_EXTERN unsigned int
  185. hb_ot_layout_language_get_feature_tags (hb_face_t *face,
  186. hb_tag_t table_tag,
  187. unsigned int script_index,
  188. unsigned int language_index,
  189. unsigned int start_offset,
  190. unsigned int *feature_count /* IN/OUT */,
  191. hb_tag_t *feature_tags /* OUT */);
  192. HB_EXTERN hb_bool_t
  193. hb_ot_layout_language_find_feature (hb_face_t *face,
  194. hb_tag_t table_tag,
  195. unsigned int script_index,
  196. unsigned int language_index,
  197. hb_tag_t feature_tag,
  198. unsigned int *feature_index);
  199. HB_EXTERN unsigned int
  200. hb_ot_layout_feature_get_lookups (hb_face_t *face,
  201. hb_tag_t table_tag,
  202. unsigned int feature_index,
  203. unsigned int start_offset,
  204. unsigned int *lookup_count /* IN/OUT */,
  205. unsigned int *lookup_indexes /* OUT */);
  206. HB_EXTERN unsigned int
  207. hb_ot_layout_table_get_lookup_count (hb_face_t *face,
  208. hb_tag_t table_tag);
  209. HB_EXTERN void
  210. hb_ot_layout_collect_features (hb_face_t *face,
  211. hb_tag_t table_tag,
  212. const hb_tag_t *scripts,
  213. const hb_tag_t *languages,
  214. const hb_tag_t *features,
  215. hb_set_t *feature_indexes /* OUT */);
  216. HB_EXTERN void
  217. hb_ot_layout_collect_lookups (hb_face_t *face,
  218. hb_tag_t table_tag,
  219. const hb_tag_t *scripts,
  220. const hb_tag_t *languages,
  221. const hb_tag_t *features,
  222. hb_set_t *lookup_indexes /* OUT */);
  223. HB_EXTERN void
  224. hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
  225. hb_tag_t table_tag,
  226. unsigned int lookup_index,
  227. hb_set_t *glyphs_before, /* OUT. May be NULL */
  228. hb_set_t *glyphs_input, /* OUT. May be NULL */
  229. hb_set_t *glyphs_after, /* OUT. May be NULL */
  230. hb_set_t *glyphs_output /* OUT. May be NULL */);
  231. #ifdef HB_NOT_IMPLEMENTED
  232. typedef struct
  233. {
  234. const hb_codepoint_t *before,
  235. unsigned int before_length,
  236. const hb_codepoint_t *input,
  237. unsigned int input_length,
  238. const hb_codepoint_t *after,
  239. unsigned int after_length,
  240. } hb_ot_layout_glyph_sequence_t;
  241. typedef hb_bool_t
  242. (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font,
  243. hb_tag_t table_tag,
  244. unsigned int lookup_index,
  245. const hb_ot_layout_glyph_sequence_t *sequence,
  246. void *user_data);
  247. HB_EXTERN void
  248. Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face,
  249. hb_tag_t table_tag,
  250. unsigned int lookup_index,
  251. hb_ot_layout_glyph_sequence_func_t callback,
  252. void *user_data);
  253. #endif
  254. /* Variations support */
  255. HB_EXTERN hb_bool_t
  256. hb_ot_layout_table_find_feature_variations (hb_face_t *face,
  257. hb_tag_t table_tag,
  258. const int *coords,
  259. unsigned int num_coords,
  260. unsigned int *variations_index /* out */);
  261. HB_EXTERN unsigned int
  262. hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
  263. hb_tag_t table_tag,
  264. unsigned int feature_index,
  265. unsigned int variations_index,
  266. unsigned int start_offset,
  267. unsigned int *lookup_count /* IN/OUT */,
  268. unsigned int *lookup_indexes /* OUT */);
  269. /*
  270. * GSUB
  271. */
  272. HB_EXTERN hb_bool_t
  273. hb_ot_layout_has_substitution (hb_face_t *face);
  274. HB_EXTERN hb_bool_t
  275. hb_ot_layout_lookup_would_substitute (hb_face_t *face,
  276. unsigned int lookup_index,
  277. const hb_codepoint_t *glyphs,
  278. unsigned int glyphs_length,
  279. hb_bool_t zero_context);
  280. HB_EXTERN void
  281. hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
  282. unsigned int lookup_index,
  283. hb_set_t *glyphs
  284. /*TODO , hb_bool_t inclusive */);
  285. HB_EXTERN void
  286. hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
  287. const hb_set_t *lookups,
  288. hb_set_t *glyphs);
  289. #ifdef HB_NOT_IMPLEMENTED
  290. /* Note: You better have GDEF when using this API, or marks won't do much. */
  291. HB_EXTERN hb_bool_t
  292. Xhb_ot_layout_lookup_substitute (hb_font_t *font,
  293. unsigned int lookup_index,
  294. const hb_ot_layout_glyph_sequence_t *sequence,
  295. unsigned int out_size,
  296. hb_codepoint_t *glyphs_out, /* OUT */
  297. unsigned int *clusters_out, /* OUT */
  298. unsigned int *out_length /* OUT */);
  299. #endif
  300. /*
  301. * GPOS
  302. */
  303. HB_EXTERN hb_bool_t
  304. hb_ot_layout_has_positioning (hb_face_t *face);
  305. #ifdef HB_NOT_IMPLEMENTED
  306. /* Note: You better have GDEF when using this API, or marks won't do much. */
  307. HB_EXTERN hb_bool_t
  308. Xhb_ot_layout_lookup_position (hb_font_t *font,
  309. unsigned int lookup_index,
  310. const hb_ot_layout_glyph_sequence_t *sequence,
  311. hb_glyph_position_t *positions /* IN / OUT */);
  312. #endif
  313. /* Optical 'size' feature info. Returns true if found.
  314. * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
  315. HB_EXTERN hb_bool_t
  316. hb_ot_layout_get_size_params (hb_face_t *face,
  317. unsigned int *design_size, /* OUT. May be NULL */
  318. unsigned int *subfamily_id, /* OUT. May be NULL */
  319. hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */
  320. unsigned int *range_start, /* OUT. May be NULL */
  321. unsigned int *range_end /* OUT. May be NULL */);
  322. HB_EXTERN hb_bool_t
  323. hb_ot_layout_feature_get_name_ids (hb_face_t *face,
  324. hb_tag_t table_tag,
  325. unsigned int feature_index,
  326. hb_ot_name_id_t *label_id /* OUT. May be NULL */,
  327. hb_ot_name_id_t *tooltip_id /* OUT. May be NULL */,
  328. hb_ot_name_id_t *sample_id /* OUT. May be NULL */,
  329. unsigned int *num_named_parameters /* OUT. May be NULL */,
  330. hb_ot_name_id_t *first_param_id /* OUT. May be NULL */);
  331. HB_EXTERN unsigned int
  332. hb_ot_layout_feature_get_characters (hb_face_t *face,
  333. hb_tag_t table_tag,
  334. unsigned int feature_index,
  335. unsigned int start_offset,
  336. unsigned int *char_count /* IN/OUT. May be NULL */,
  337. hb_codepoint_t *characters /* OUT. May be NULL */);
  338. /*
  339. * BASE
  340. */
  341. /**
  342. * hb_ot_layout_baseline_tag_t:
  343. * @HB_OT_LAYOUT_BASELINE_TAG_ROMAN: The baseline used by alphabetic scripts such as Latin, Cyrillic and Greek.
  344. * In vertical writing mode, the alphabetic baseline for characters rotated 90 degrees clockwise.
  345. * (This would not apply to alphabetic characters that remain upright in vertical writing mode, since these
  346. * characters are not rotated.)
  347. * @HB_OT_LAYOUT_BASELINE_TAG_HANGING: The hanging baseline. In horizontal direction, this is the horizontal
  348. * line from which syllables seem, to hang in Tibetan and other similar scripts. In vertical writing mode,
  349. * for Tibetan (or some other similar script) characters rotated 90 degrees clockwise.
  350. * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT: Ideographic character face bottom or left edge,
  351. * if the direction is horizontal or vertical, respectively.
  352. * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT: Ideographic character face top or right edge,
  353. * if the direction is horizontal or vertical, respectively.
  354. * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT: Ideographic em-box bottom or left edge,
  355. * if the direction is horizontal or vertical, respectively.
  356. * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT: Ideographic em-box top or right edge baseline,
  357. * if the direction is horizontal or vertical, respectively.
  358. * @HB_OT_LAYOUT_BASELINE_TAG_MATH: The baseline about which mathematical characters are centered.
  359. * In vertical writing mode when mathematical characters rotated 90 degrees clockwise, are centered.
  360. *
  361. * Baseline tags from https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags
  362. *
  363. * Since: 2.6.0
  364. */
  365. typedef enum {
  366. HB_OT_LAYOUT_BASELINE_TAG_ROMAN = HB_TAG ('r','o','m','n'),
  367. HB_OT_LAYOUT_BASELINE_TAG_HANGING = HB_TAG ('h','a','n','g'),
  368. HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT = HB_TAG ('i','c','f','b'),
  369. HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT = HB_TAG ('i','c','f','t'),
  370. HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT = HB_TAG ('i','d','e','o'),
  371. HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT = HB_TAG ('i','d','t','p'),
  372. HB_OT_LAYOUT_BASELINE_TAG_MATH = HB_TAG ('m','a','t','h'),
  373. _HB_OT_LAYOUT_BASELINE_TAG_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
  374. } hb_ot_layout_baseline_tag_t;
  375. HB_EXTERN hb_bool_t
  376. hb_ot_layout_get_baseline (hb_font_t *font,
  377. hb_ot_layout_baseline_tag_t baseline_tag,
  378. hb_direction_t direction,
  379. hb_tag_t script_tag,
  380. hb_tag_t language_tag,
  381. hb_position_t *coord /* OUT. May be NULL. */);
  382. HB_END_DECLS
  383. #endif /* HB_OT_LAYOUT_H */