pango-glyph-item.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. *
  33. * A #PangoGlyphItem is a pair of a #PangoItem and the glyphs
  34. * resulting from shaping the text corresponding to an item.
  35. * As an example of the usage of #PangoGlyphItem, the results
  36. * of shaping text with #PangoLayout is a list of #PangoLayoutLine,
  37. * each of which contains a list of #PangoGlyphItem.
  38. */
  39. typedef struct _PangoGlyphItem PangoGlyphItem;
  40. struct _PangoGlyphItem
  41. {
  42. PangoItem *item;
  43. PangoGlyphString *glyphs;
  44. };
  45. /**
  46. * PANGO_TYPE_GLYPH_ITEM:
  47. *
  48. * The #GObject type for #PangoGlyphItem.
  49. */
  50. #define PANGO_TYPE_GLYPH_ITEM (pango_glyph_item_get_type ())
  51. PANGO_AVAILABLE_IN_ALL
  52. GType pango_glyph_item_get_type (void) G_GNUC_CONST;
  53. PANGO_AVAILABLE_IN_1_2
  54. PangoGlyphItem *pango_glyph_item_split (PangoGlyphItem *orig,
  55. const char *text,
  56. int split_index);
  57. PANGO_AVAILABLE_IN_1_20
  58. PangoGlyphItem *pango_glyph_item_copy (PangoGlyphItem *orig);
  59. PANGO_AVAILABLE_IN_1_6
  60. void pango_glyph_item_free (PangoGlyphItem *glyph_item);
  61. PANGO_AVAILABLE_IN_1_2
  62. GSList * pango_glyph_item_apply_attrs (PangoGlyphItem *glyph_item,
  63. const char *text,
  64. PangoAttrList *list);
  65. PANGO_AVAILABLE_IN_1_6
  66. void pango_glyph_item_letter_space (PangoGlyphItem *glyph_item,
  67. const char *text,
  68. PangoLogAttr *log_attrs,
  69. int letter_spacing);
  70. PANGO_AVAILABLE_IN_1_26
  71. void pango_glyph_item_get_logical_widths (PangoGlyphItem *glyph_item,
  72. const char *text,
  73. int *logical_widths);
  74. /**
  75. * PangoGlyphItemIter:
  76. *
  77. * A #PangoGlyphItemIter is an iterator over the clusters in a
  78. * #PangoGlyphItem. The <firstterm>forward direction</firstterm> of the
  79. * iterator is the logical direction of text. That is, with increasing
  80. * @start_index and @start_char values. If @glyph_item is right-to-left
  81. * (that is, if <literal>@glyph_item->item->analysis.level</literal> is odd),
  82. * then @start_glyph decreases as the iterator moves forward. Moreover,
  83. * in right-to-left cases, @start_glyph is greater than @end_glyph.
  84. *
  85. * An iterator should be initialized using either of
  86. * pango_glyph_item_iter_init_start() and
  87. * pango_glyph_item_iter_init_end(), for forward and backward iteration
  88. * respectively, and walked over using any desired mixture of
  89. * pango_glyph_item_iter_next_cluster() and
  90. * pango_glyph_item_iter_prev_cluster(). A common idiom for doing a
  91. * forward iteration over the clusters is:
  92. * <programlisting>
  93. * PangoGlyphItemIter cluster_iter;
  94. * gboolean have_cluster;
  95. *
  96. * for (have_cluster = pango_glyph_item_iter_init_start (&amp;cluster_iter,
  97. * glyph_item, text);
  98. * have_cluster;
  99. * have_cluster = pango_glyph_item_iter_next_cluster (&amp;cluster_iter))
  100. * {
  101. * ...
  102. * }
  103. * </programlisting>
  104. *
  105. * Note that @text is the start of the text for layout, which is then
  106. * indexed by <literal>@glyph_item->item->offset</literal> to get to the
  107. * text of @glyph_item. The @start_index and @end_index values can directly
  108. * index into @text. The @start_glyph, @end_glyph, @start_char, and @end_char
  109. * values however are zero-based for the @glyph_item. For each cluster, the
  110. * item pointed at by the start variables is included in the cluster while
  111. * the one pointed at by end variables is not.
  112. *
  113. * None of the members of a #PangoGlyphItemIter should be modified manually.
  114. *
  115. * Since: 1.22
  116. */
  117. typedef struct _PangoGlyphItemIter PangoGlyphItemIter;
  118. struct _PangoGlyphItemIter
  119. {
  120. PangoGlyphItem *glyph_item;
  121. const gchar *text;
  122. int start_glyph;
  123. int start_index;
  124. int start_char;
  125. int end_glyph;
  126. int end_index;
  127. int end_char;
  128. };
  129. /**
  130. * PANGO_TYPE_GLYPH_ITEM_ITER:
  131. *
  132. * The #GObject type for #PangoGlyphItemIter.
  133. *
  134. * Since: 1.22
  135. */
  136. #define PANGO_TYPE_GLYPH_ITEM_ITER (pango_glyph_item_iter_get_type ())
  137. PANGO_AVAILABLE_IN_1_22
  138. GType pango_glyph_item_iter_get_type (void) G_GNUC_CONST;
  139. PANGO_AVAILABLE_IN_1_22
  140. PangoGlyphItemIter *pango_glyph_item_iter_copy (PangoGlyphItemIter *orig);
  141. PANGO_AVAILABLE_IN_1_22
  142. void pango_glyph_item_iter_free (PangoGlyphItemIter *iter);
  143. PANGO_AVAILABLE_IN_1_22
  144. gboolean pango_glyph_item_iter_init_start (PangoGlyphItemIter *iter,
  145. PangoGlyphItem *glyph_item,
  146. const char *text);
  147. PANGO_AVAILABLE_IN_1_22
  148. gboolean pango_glyph_item_iter_init_end (PangoGlyphItemIter *iter,
  149. PangoGlyphItem *glyph_item,
  150. const char *text);
  151. PANGO_AVAILABLE_IN_1_22
  152. gboolean pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter);
  153. PANGO_AVAILABLE_IN_1_22
  154. gboolean pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter);
  155. G_END_DECLS
  156. #endif /* __PANGO_GLYPH_ITEM_H__ */