hb-ot-var.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright © 2017 Google, 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_OT_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
  27. #error "Include <hb-ot.h> instead."
  28. #endif
  29. #ifndef HB_OT_VAR_H
  30. #define HB_OT_VAR_H
  31. #include "hb.h"
  32. HB_BEGIN_DECLS
  33. /**
  34. * HB_OT_TAG_VAR_AXIS_ITALIC:
  35. *
  36. * Registered tag for the roman/italic axis.
  37. */
  38. #define HB_OT_TAG_VAR_AXIS_ITALIC HB_TAG('i','t','a','l')
  39. /**
  40. * HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE:
  41. *
  42. * Registered tag for the optical-size axis.
  43. * <note>Note: The optical-size axis supersedes the OpenType `size` feature.</note>
  44. */
  45. #define HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE HB_TAG('o','p','s','z')
  46. /**
  47. * HB_OT_TAG_VAR_AXIS_SLANT:
  48. *
  49. * Registered tag for the slant axis
  50. */
  51. #define HB_OT_TAG_VAR_AXIS_SLANT HB_TAG('s','l','n','t')
  52. /**
  53. * HB_OT_TAG_VAR_AXIS_WIDTH:
  54. *
  55. * Registered tag for the width axis.
  56. */
  57. #define HB_OT_TAG_VAR_AXIS_WIDTH HB_TAG('w','d','t','h')
  58. /**
  59. * HB_OT_TAG_VAR_AXIS_WEIGHT:
  60. *
  61. * Registered tag for the weight axis.
  62. */
  63. #define HB_OT_TAG_VAR_AXIS_WEIGHT HB_TAG('w','g','h','t')
  64. /*
  65. * fvar / avar
  66. */
  67. HB_EXTERN hb_bool_t
  68. hb_ot_var_has_data (hb_face_t *face);
  69. /*
  70. * Variation axes.
  71. */
  72. HB_EXTERN unsigned int
  73. hb_ot_var_get_axis_count (hb_face_t *face);
  74. /**
  75. * hb_ot_var_axis_flags_t:
  76. * @HB_OT_VAR_AXIS_FLAG_HIDDEN: The axis should not be exposed directly in user interfaces.
  77. *
  78. * Flags for #hb_ot_var_axis_info_t.
  79. *
  80. * Since: 2.2.0
  81. */
  82. typedef enum { /*< flags >*/
  83. HB_OT_VAR_AXIS_FLAG_HIDDEN = 0x00000001u,
  84. /*< private >*/
  85. _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= HB_TAG_MAX_SIGNED /*< skip >*/
  86. } hb_ot_var_axis_flags_t;
  87. /**
  88. * hb_ot_var_axis_info_t:
  89. * @axis_index: Index of the axis in the variation-axis array
  90. * @tag: The #hb_tag_t tag identifying the design variation of the axis
  91. * @name_id: The `name` table Name ID that provides display names for the axis
  92. * @flags: The #hb_ot_var_axis_flags_t flags for the axis
  93. * @min_value: The minimum value on the variation axis that the font covers
  94. * @default_value: The position on the variation axis corresponding to the font's defaults
  95. * @max_value: The maximum value on the variation axis that the font covers
  96. *
  97. * Data type for holding variation-axis values.
  98. *
  99. * The minimum, default, and maximum values are in un-normalized, user scales.
  100. *
  101. * <note>Note: at present, the only flag defined for @flags is
  102. * #HB_OT_VAR_AXIS_FLAG_HIDDEN.</note>
  103. *
  104. * Since: 2.2.0
  105. */
  106. typedef struct hb_ot_var_axis_info_t {
  107. unsigned int axis_index;
  108. hb_tag_t tag;
  109. hb_ot_name_id_t name_id;
  110. hb_ot_var_axis_flags_t flags;
  111. float min_value;
  112. float default_value;
  113. float max_value;
  114. /*< private >*/
  115. unsigned int reserved;
  116. } hb_ot_var_axis_info_t;
  117. HB_EXTERN unsigned int
  118. hb_ot_var_get_axis_infos (hb_face_t *face,
  119. unsigned int start_offset,
  120. unsigned int *axes_count /* IN/OUT */,
  121. hb_ot_var_axis_info_t *axes_array /* OUT */);
  122. HB_EXTERN hb_bool_t
  123. hb_ot_var_find_axis_info (hb_face_t *face,
  124. hb_tag_t axis_tag,
  125. hb_ot_var_axis_info_t *axis_info);
  126. /*
  127. * Named instances.
  128. */
  129. HB_EXTERN unsigned int
  130. hb_ot_var_get_named_instance_count (hb_face_t *face);
  131. HB_EXTERN hb_ot_name_id_t
  132. hb_ot_var_named_instance_get_subfamily_name_id (hb_face_t *face,
  133. unsigned int instance_index);
  134. HB_EXTERN hb_ot_name_id_t
  135. hb_ot_var_named_instance_get_postscript_name_id (hb_face_t *face,
  136. unsigned int instance_index);
  137. HB_EXTERN unsigned int
  138. hb_ot_var_named_instance_get_design_coords (hb_face_t *face,
  139. unsigned int instance_index,
  140. unsigned int *coords_length, /* IN/OUT */
  141. float *coords /* OUT */);
  142. /*
  143. * Conversions.
  144. */
  145. HB_EXTERN void
  146. hb_ot_var_normalize_variations (hb_face_t *face,
  147. const hb_variation_t *variations, /* IN */
  148. unsigned int variations_length,
  149. int *coords, /* OUT */
  150. unsigned int coords_length);
  151. HB_EXTERN void
  152. hb_ot_var_normalize_coords (hb_face_t *face,
  153. unsigned int coords_length,
  154. const float *design_coords, /* IN */
  155. int *normalized_coords /* OUT */);
  156. HB_END_DECLS
  157. #endif /* HB_OT_VAR_H */