raqm.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright © 2015 Information Technology Authority (ITA) <foss@ita.gov.om>
  3. * Copyright © 2016 Khaled Hosny <khaledhosny@eglug.org>
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to
  7. * deal in the Software without restriction, including without limitation the
  8. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. * sell copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef _RAQM_H_
  25. #define _RAQM_H_
  26. #ifdef HAVE_CONFIG_H
  27. #error #include "config.h"
  28. #endif
  29. #ifndef bool
  30. typedef int bool;
  31. #endif
  32. #ifndef uint32_t
  33. typedef UINT32 uint32_t;
  34. #endif
  35. #include <ft2build.h>
  36. #include FT_FREETYPE_H
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /**
  41. * raqm_t:
  42. *
  43. * This is the main object holding all state of the currently processed text as
  44. * well as its output.
  45. *
  46. * Since: 0.1
  47. */
  48. typedef struct _raqm raqm_t;
  49. /**
  50. * raqm_direction_t:
  51. * @RAQM_DIRECTION_DEFAULT: Detect paragraph direction automatically.
  52. * @RAQM_DIRECTION_RTL: Paragraph is mainly right-to-left text.
  53. * @RAQM_DIRECTION_LTR: Paragraph is mainly left-to-right text.
  54. * @RAQM_DIRECTION_TTB: Paragraph is mainly vertical top-to-bottom text.
  55. *
  56. * Base paragraph direction, see raqm_set_par_direction().
  57. *
  58. * Since: 0.1
  59. */
  60. typedef enum
  61. {
  62. RAQM_DIRECTION_DEFAULT,
  63. RAQM_DIRECTION_RTL,
  64. RAQM_DIRECTION_LTR,
  65. RAQM_DIRECTION_TTB
  66. } raqm_direction_t;
  67. /**
  68. * raqm_glyph_t:
  69. * @index: the index of the glyph in the font file.
  70. * @x_advance: the glyph advance width in horizontal text.
  71. * @y_advance: the glyph advance width in vertical text.
  72. * @x_offset: the horizontal movement of the glyph from the current point.
  73. * @y_offset: the vertical movement of the glyph from the current point.
  74. * @cluster: the index of original character in input text.
  75. * @ftface: the @FT_Face of the glyph.
  76. *
  77. * The structure that holds information about output glyphs, returned from
  78. * raqm_get_glyphs().
  79. */
  80. typedef struct raqm_glyph_t {
  81. unsigned int index;
  82. int x_advance;
  83. int y_advance;
  84. int x_offset;
  85. int y_offset;
  86. uint32_t cluster;
  87. FT_Face ftface;
  88. } raqm_glyph_t;
  89. /**
  90. * version 0.1 of the raqm_glyph_t structure
  91. */
  92. typedef struct raqm_glyph_t_01 {
  93. unsigned int index;
  94. int x_advance;
  95. int y_advance;
  96. int x_offset;
  97. int y_offset;
  98. uint32_t cluster;
  99. } raqm_glyph_t_01;
  100. raqm_t *
  101. raqm_create (void);
  102. raqm_t *
  103. raqm_reference (raqm_t *rq);
  104. void
  105. raqm_destroy (raqm_t *rq);
  106. bool
  107. raqm_set_text (raqm_t *rq,
  108. const uint32_t *text,
  109. size_t len);
  110. bool
  111. raqm_set_text_utf8 (raqm_t *rq,
  112. const char *text,
  113. size_t len);
  114. bool
  115. raqm_set_par_direction (raqm_t *rq,
  116. raqm_direction_t dir);
  117. bool
  118. raqm_set_language (raqm_t *rq,
  119. const char *lang,
  120. size_t start,
  121. size_t len);
  122. bool
  123. raqm_add_font_feature (raqm_t *rq,
  124. const char *feature,
  125. int len);
  126. bool
  127. raqm_set_freetype_face (raqm_t *rq,
  128. FT_Face face);
  129. bool
  130. raqm_set_freetype_face_range (raqm_t *rq,
  131. FT_Face face,
  132. size_t start,
  133. size_t len);
  134. bool
  135. raqm_set_freetype_load_flags (raqm_t *rq,
  136. int flags);
  137. bool
  138. raqm_layout (raqm_t *rq);
  139. raqm_glyph_t *
  140. raqm_get_glyphs (raqm_t *rq,
  141. size_t *length);
  142. bool
  143. raqm_index_to_position (raqm_t *rq,
  144. size_t *index,
  145. int *x,
  146. int *y);
  147. bool
  148. raqm_position_to_index (raqm_t *rq,
  149. int x,
  150. int y,
  151. size_t *index);
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155. #endif /* _RAQM_H_ */