pango-glyph-item.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* Pango
  2. * pango-glyph-item.h: Pair of PangoItem and a glyph string
  3. *
  4. * Copyright (C) 2002 Red Hat Software
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __PANGO_GLYPH_ITEM_H__
  22. #define __PANGO_GLYPH_ITEM_H__
  23. #include <pango/pango-attributes.h>
  24. #include <pango/pango-break.h>
  25. #include <pango/pango-item.h>
  26. #include <pango/pango-glyph.h>
  27. G_BEGIN_DECLS
  28. /**
  29. * PangoGlyphItem:
  30. * @item: corresponding `PangoItem`
  31. * @glyphs: corresponding `PangoGlyphString`
  32. * @y_offset: shift of the baseline, relative to the baseline
  33. * of the containing line. Positive values shift upwards
  34. * @start_x_offset: horizontal displacement to apply before the
  35. * glyph item. Positive values shift right
  36. * @end_x_offset: horizontal displacement to apply after th
  37. * glyph item. Positive values shift right
  38. *
  39. * A `PangoGlyphItem` is a pair of a `PangoItem` and the glyphs
  40. * resulting from shaping the items text.
  41. *
  42. * As an example of the usage of `PangoGlyphItem`, the results
  43. * of shaping text with `PangoLayout` is a list of `PangoLayoutLine`,
  44. * each of which contains a list of `PangoGlyphItem`.
  45. */
  46. typedef struct _PangoGlyphItem PangoGlyphItem;
  47. struct _PangoGlyphItem
  48. {
  49. PangoItem *item;
  50. PangoGlyphString *glyphs;
  51. int y_offset;
  52. int start_x_offset;
  53. int end_x_offset;
  54. };
  55. #define PANGO_TYPE_GLYPH_ITEM (pango_glyph_item_get_type ())
  56. PANGO_AVAILABLE_IN_ALL
  57. GType pango_glyph_item_get_type (void) G_GNUC_CONST;
  58. PANGO_AVAILABLE_IN_1_2
  59. PangoGlyphItem *pango_glyph_item_split (PangoGlyphItem *orig,
  60. const char *text,
  61. int split_index);
  62. PANGO_AVAILABLE_IN_1_20
  63. PangoGlyphItem *pango_glyph_item_copy (PangoGlyphItem *orig);
  64. PANGO_AVAILABLE_IN_1_6
  65. void pango_glyph_item_free (PangoGlyphItem *glyph_item);
  66. PANGO_AVAILABLE_IN_1_2
  67. GSList * pango_glyph_item_apply_attrs (PangoGlyphItem *glyph_item,
  68. const char *text,
  69. PangoAttrList *list);
  70. PANGO_AVAILABLE_IN_1_6
  71. void pango_glyph_item_letter_space (PangoGlyphItem *glyph_item,
  72. const char *text,
  73. PangoLogAttr *log_attrs,
  74. int letter_spacing);
  75. PANGO_AVAILABLE_IN_1_26
  76. void pango_glyph_item_get_logical_widths (PangoGlyphItem *glyph_item,
  77. const char *text,
  78. int *logical_widths);
  79. /**
  80. * PangoGlyphItemIter:
  81. *
  82. * A `PangoGlyphItemIter` is an iterator over the clusters in a
  83. * `PangoGlyphItem`.
  84. *
  85. * The *forward direction* of the iterator is the logical direction of text.
  86. * That is, with increasing @start_index and @start_char values. If @glyph_item
  87. * is right-to-left (that is, if `glyph_item->item->analysis.level` is odd),
  88. * then @start_glyph decreases as the iterator moves forward. Moreover,
  89. * in right-to-left cases, @start_glyph is greater than @end_glyph.
  90. *
  91. * An iterator should be initialized using either
  92. * pango_glyph_item_iter_init_start() or
  93. * pango_glyph_item_iter_init_end(), for forward and backward iteration
  94. * respectively, and walked over using any desired mixture of
  95. * pango_glyph_item_iter_next_cluster() and
  96. * pango_glyph_item_iter_prev_cluster().
  97. *
  98. * A common idiom for doing a forward iteration over the clusters is:
  99. *
  100. * ```
  101. * PangoGlyphItemIter cluster_iter;
  102. * gboolean have_cluster;
  103. *
  104. * for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
  105. * glyph_item, text);
  106. * have_cluster;
  107. * have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
  108. * {
  109. * ...
  110. * }
  111. * ```
  112. *
  113. * Note that @text is the start of the text for layout, which is then
  114. * indexed by `glyph_item->item->offset` to get to the text of @glyph_item.
  115. * The @start_index and @end_index values can directly index into @text. The
  116. * @start_glyph, @end_glyph, @start_char, and @end_char values however are
  117. * zero-based for the @glyph_item. For each cluster, the item pointed at by
  118. * the start variables is included in the cluster while the one pointed at by
  119. * end variables is not.
  120. *
  121. * None of the members of a `PangoGlyphItemIter` should be modified manually.
  122. *
  123. * Since: 1.22
  124. */
  125. typedef struct _PangoGlyphItemIter PangoGlyphItemIter;
  126. struct _PangoGlyphItemIter
  127. {
  128. PangoGlyphItem *glyph_item;
  129. const gchar *text;
  130. int start_glyph;
  131. int start_index;
  132. int start_char;
  133. int end_glyph;
  134. int end_index;
  135. int end_char;
  136. };
  137. #define PANGO_TYPE_GLYPH_ITEM_ITER (pango_glyph_item_iter_get_type ())
  138. PANGO_AVAILABLE_IN_1_22
  139. GType pango_glyph_item_iter_get_type (void) G_GNUC_CONST;
  140. PANGO_AVAILABLE_IN_1_22
  141. PangoGlyphItemIter *pango_glyph_item_iter_copy (PangoGlyphItemIter *orig);
  142. PANGO_AVAILABLE_IN_1_22
  143. void pango_glyph_item_iter_free (PangoGlyphItemIter *iter);
  144. PANGO_AVAILABLE_IN_1_22
  145. gboolean pango_glyph_item_iter_init_start (PangoGlyphItemIter *iter,
  146. PangoGlyphItem *glyph_item,
  147. const char *text);
  148. PANGO_AVAILABLE_IN_1_22
  149. gboolean pango_glyph_item_iter_init_end (PangoGlyphItemIter *iter,
  150. PangoGlyphItem *glyph_item,
  151. const char *text);
  152. PANGO_AVAILABLE_IN_1_22
  153. gboolean pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter);
  154. PANGO_AVAILABLE_IN_1_22
  155. gboolean pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter);
  156. G_END_DECLS
  157. #endif /* __PANGO_GLYPH_ITEM_H__ */