1/* Pango
2 * pango-item.h: Structure for storing run information
3 *
4 * Copyright (C) 2000 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_ITEM_H__
23#define __PANGO_ITEM_H__
24
25#include <pango/pango-types.h>
26#include <pango/pango-attributes.h>
27
28G_BEGIN_DECLS
29
30typedef struct _PangoAnalysis PangoAnalysis;
31typedef struct _PangoItem PangoItem;
32
33/**
34 * PANGO_ANALYSIS_FLAG_CENTERED_BASELINE:
35 *
36 * Whether the segment should be shifted to center around the baseline.
37 *
38 * This is mainly used in vertical writing directions.
39 *
40 * Since: 1.16
41 */
42#define PANGO_ANALYSIS_FLAG_CENTERED_BASELINE (1 << 0)
43
44/**
45 * PANGO_ANALYSIS_FLAG_IS_ELLIPSIS:
46 *
47 * Whether this run holds ellipsized text.
48 *
49 * Since: 1.36.7
50 */
51#define PANGO_ANALYSIS_FLAG_IS_ELLIPSIS (1 << 1)
52
53/**
54 * PANGO_ANALYSIS_FLAG_NEED_HYPHEN:
55 *
56 * Whether to add a hyphen at the end of the run during shaping.
57 *
58 * Since: 1.44
59 */
60#define PANGO_ANALYSIS_FLAG_NEED_HYPHEN (1 << 2)
61
62/**
63 * PangoAnalysis:
64 * @shape_engine: unused, reserved
65 * @lang_engine: unused, reserved
66 * @font: the font for this segment.
67 * @level: the bidirectional level for this segment.
68 * @gravity: the glyph orientation for this segment (A `PangoGravity`).
69 * @flags: boolean flags for this segment (Since: 1.16).
70 * @script: the detected script for this segment (A `PangoScript`) (Since: 1.18).
71 * @language: the detected language for this segment.
72 * @extra_attrs: extra attributes for this segment.
73 *
74 * The `PangoAnalysis` structure stores information about
75 * the properties of a segment of text.
76 */
77struct _PangoAnalysis
78{
79#ifndef __GI_SCANNER__
80 PangoEngineShape *shape_engine;
81 PangoEngineLang *lang_engine;
82#else
83 gpointer shape_engine;
84 gpointer lang_engine;
85#endif
86 PangoFont *font;
87
88 guint8 level;
89 guint8 gravity;
90 guint8 flags;
91
92 guint8 script;
93 PangoLanguage *language;
94
95 GSList *extra_attrs;
96};
97
98/**
99 * PangoItem:
100 * @offset: byte offset of the start of this item in text.
101 * @length: length of this item in bytes.
102 * @num_chars: number of Unicode characters in the item.
103 * @analysis: analysis results for the item.
104 *
105 * The `PangoItem` structure stores information about a segment of text.
106 *
107 * You typically obtain `PangoItems` by itemizing a piece of text
108 * with [func@itemize].
109 */
110struct _PangoItem
111{
112 int offset;
113 int length;
114 int num_chars;
115 PangoAnalysis analysis;
116};
117
118#define PANGO_TYPE_ITEM (pango_item_get_type ())
119
120PANGO_AVAILABLE_IN_ALL
121GType pango_item_get_type (void) G_GNUC_CONST;
122
123PANGO_AVAILABLE_IN_ALL
124PangoItem * pango_item_new (void);
125PANGO_AVAILABLE_IN_ALL
126PangoItem * pango_item_copy (PangoItem *item);
127PANGO_AVAILABLE_IN_ALL
128void pango_item_free (PangoItem *item);
129
130
131PANGO_AVAILABLE_IN_1_54
132int pango_item_get_char_offset (PangoItem *item);
133
134PANGO_AVAILABLE_IN_ALL
135PangoItem * pango_item_split (PangoItem *orig,
136 int split_index,
137 int split_offset);
138
139PANGO_AVAILABLE_IN_1_44
140void pango_item_apply_attrs (PangoItem *item,
141 PangoAttrIterator *iter);
142
143PANGO_AVAILABLE_IN_ALL
144GList * pango_reorder_items (GList *items);
145
146/* Itemization */
147
148PANGO_AVAILABLE_IN_ALL
149GList * pango_itemize (PangoContext *context,
150 const char *text,
151 int start_index,
152 int length,
153 PangoAttrList *attrs,
154 PangoAttrIterator *cached_iter);
155
156PANGO_AVAILABLE_IN_1_4
157GList * pango_itemize_with_base_dir (PangoContext *context,
158 PangoDirection base_dir,
159 const char *text,
160 int start_index,
161 int length,
162 PangoAttrList *attrs,
163 PangoAttrIterator *cached_iter);
164
165G_END_DECLS
166
167#endif /* __PANGO_ITEM_H__ */
168