hb-face.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Copyright © 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. #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
  27. #error "Include <hb.h> instead."
  28. #endif
  29. #ifndef HB_FACE_H
  30. #define HB_FACE_H
  31. #include "hb-common.h"
  32. #include "hb-blob.h"
  33. #include "hb-map.h"
  34. #include "hb-set.h"
  35. HB_BEGIN_DECLS
  36. HB_EXTERN unsigned int
  37. hb_face_count (hb_blob_t *blob);
  38. /*
  39. * hb_face_t
  40. */
  41. /**
  42. * hb_face_t:
  43. *
  44. * Data type for holding font faces.
  45. *
  46. **/
  47. typedef struct hb_face_t hb_face_t;
  48. HB_EXTERN hb_face_t *
  49. hb_face_create (hb_blob_t *blob,
  50. unsigned int index);
  51. /**
  52. * hb_reference_table_func_t:
  53. * @face: an #hb_face_t to reference table for
  54. * @tag: the tag of the table to reference
  55. * @user_data: User data pointer passed by the caller
  56. *
  57. * Callback function for hb_face_create_for_tables().
  58. *
  59. * Return value: (transfer full): A pointer to the @tag table within @face
  60. *
  61. * Since: 0.9.2
  62. */
  63. typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data);
  64. /* calls destroy() when not needing user_data anymore */
  65. HB_EXTERN hb_face_t *
  66. hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
  67. void *user_data,
  68. hb_destroy_func_t destroy);
  69. HB_EXTERN hb_face_t *
  70. hb_face_get_empty (void);
  71. HB_EXTERN hb_face_t *
  72. hb_face_reference (hb_face_t *face);
  73. HB_EXTERN void
  74. hb_face_destroy (hb_face_t *face);
  75. HB_EXTERN hb_bool_t
  76. hb_face_set_user_data (hb_face_t *face,
  77. hb_user_data_key_t *key,
  78. void * data,
  79. hb_destroy_func_t destroy,
  80. hb_bool_t replace);
  81. HB_EXTERN void *
  82. hb_face_get_user_data (const hb_face_t *face,
  83. hb_user_data_key_t *key);
  84. HB_EXTERN void
  85. hb_face_make_immutable (hb_face_t *face);
  86. HB_EXTERN hb_bool_t
  87. hb_face_is_immutable (const hb_face_t *face);
  88. HB_EXTERN hb_blob_t *
  89. hb_face_reference_table (const hb_face_t *face,
  90. hb_tag_t tag);
  91. HB_EXTERN hb_blob_t *
  92. hb_face_reference_blob (hb_face_t *face);
  93. HB_EXTERN void
  94. hb_face_set_index (hb_face_t *face,
  95. unsigned int index);
  96. HB_EXTERN unsigned int
  97. hb_face_get_index (const hb_face_t *face);
  98. HB_EXTERN void
  99. hb_face_set_upem (hb_face_t *face,
  100. unsigned int upem);
  101. HB_EXTERN unsigned int
  102. hb_face_get_upem (const hb_face_t *face);
  103. HB_EXTERN void
  104. hb_face_set_glyph_count (hb_face_t *face,
  105. unsigned int glyph_count);
  106. HB_EXTERN unsigned int
  107. hb_face_get_glyph_count (const hb_face_t *face);
  108. /**
  109. * hb_get_table_tags_func_t:
  110. * @face: A face object
  111. * @start_offset: The index of first table tag to retrieve
  112. * @table_count: (inout): Input = the maximum number of table tags to return;
  113. * Output = the actual number of table tags returned (may be zero)
  114. * @table_tags: (out) (array length=table_count): The array of table tags found
  115. * @user_data: User data pointer passed by the caller
  116. *
  117. * Callback function for hb_face_get_table_tags().
  118. *
  119. * Return value: Total number of tables, or zero if it is not possible to list
  120. *
  121. * Since: 10.0.0
  122. */
  123. typedef unsigned int (*hb_get_table_tags_func_t) (const hb_face_t *face,
  124. unsigned int start_offset,
  125. unsigned int *table_count, /* IN/OUT */
  126. hb_tag_t *table_tags /* OUT */,
  127. void *user_data);
  128. HB_EXTERN void
  129. hb_face_set_get_table_tags_func (hb_face_t *face,
  130. hb_get_table_tags_func_t func,
  131. void *user_data,
  132. hb_destroy_func_t destroy);
  133. HB_EXTERN unsigned int
  134. hb_face_get_table_tags (const hb_face_t *face,
  135. unsigned int start_offset,
  136. unsigned int *table_count, /* IN/OUT */
  137. hb_tag_t *table_tags /* OUT */);
  138. /*
  139. * Character set.
  140. */
  141. HB_EXTERN void
  142. hb_face_collect_unicodes (hb_face_t *face,
  143. hb_set_t *out);
  144. HB_EXTERN void
  145. hb_face_collect_nominal_glyph_mapping (hb_face_t *face,
  146. hb_map_t *mapping,
  147. hb_set_t *unicodes);
  148. HB_EXTERN void
  149. hb_face_collect_variation_selectors (hb_face_t *face,
  150. hb_set_t *out);
  151. HB_EXTERN void
  152. hb_face_collect_variation_unicodes (hb_face_t *face,
  153. hb_codepoint_t variation_selector,
  154. hb_set_t *out);
  155. /*
  156. * Builder face.
  157. */
  158. HB_EXTERN hb_face_t *
  159. hb_face_builder_create (void);
  160. HB_EXTERN hb_bool_t
  161. hb_face_builder_add_table (hb_face_t *face,
  162. hb_tag_t tag,
  163. hb_blob_t *blob);
  164. HB_EXTERN void
  165. hb_face_builder_sort_tables (hb_face_t *face,
  166. const hb_tag_t *tags);
  167. HB_END_DECLS
  168. #endif /* HB_FACE_H */