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