pango-glyph-item.h 5.5 KB

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