1/* Pango
2 * pango-glyph.h: Glyph storage
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_GLYPH_H__
23#define __PANGO_GLYPH_H__
24
25#include <pango/pango-types.h>
26#include <pango/pango-item.h>
27
28G_BEGIN_DECLS
29
30typedef struct _PangoGlyphGeometry PangoGlyphGeometry;
31typedef struct _PangoGlyphVisAttr PangoGlyphVisAttr;
32typedef struct _PangoGlyphInfo PangoGlyphInfo;
33typedef struct _PangoGlyphString PangoGlyphString;
34
35/* 1024ths of a device unit */
36/**
37 * PangoGlyphUnit:
38 *
39 * The #PangoGlyphUnit type is used to store dimensions within
40 * Pango. Dimensions are stored in 1/%PANGO_SCALE of a device unit.
41 * (A device unit might be a pixel for screen display, or
42 * a point on a printer.) %PANGO_SCALE is currently 1024, and
43 * may change in the future (unlikely though), but you should not
44 * depend on its exact value. The PANGO_PIXELS() macro can be used
45 * to convert from glyph units into device units with correct rounding.
46 */
47typedef gint32 PangoGlyphUnit;
48
49/* Positioning information about a glyph
50 */
51/**
52 * PangoGlyphGeometry:
53 * @width: the logical width to use for the the character.
54 * @x_offset: horizontal offset from nominal character position.
55 * @y_offset: vertical offset from nominal character position.
56 *
57 * The #PangoGlyphGeometry structure contains width and positioning
58 * information for a single glyph.
59 */
60struct _PangoGlyphGeometry
61{
62 PangoGlyphUnit width;
63 PangoGlyphUnit x_offset;
64 PangoGlyphUnit y_offset;
65};
66
67/* Visual attributes of a glyph
68 */
69/**
70 * PangoGlyphVisAttr:
71 * @is_cluster_start: set for the first logical glyph in each cluster. (Clusters
72 * are stored in visual order, within the cluster, glyphs
73 * are always ordered in logical order, since visual
74 * order is meaningless; that is, in Arabic text, accent glyphs
75 * follow the glyphs for the base character.)
76 *
77 * The PangoGlyphVisAttr is used to communicate information between
78 * the shaping phase and the rendering phase. More attributes may be
79 * added in the future.
80 */
81struct _PangoGlyphVisAttr
82{
83 guint is_cluster_start : 1;
84};
85
86/* A single glyph
87 */
88/**
89 * PangoGlyphInfo:
90 * @glyph: the glyph itself.
91 * @geometry: the positional information about the glyph.
92 * @attr: the visual attributes of the glyph.
93 *
94 * The #PangoGlyphInfo structure represents a single glyph together with
95 * positioning information and visual attributes.
96 * It contains the following fields.
97 */
98struct _PangoGlyphInfo
99{
100 PangoGlyph glyph;
101 PangoGlyphGeometry geometry;
102 PangoGlyphVisAttr attr;
103};
104
105/* A string of glyphs with positional information and visual attributes -
106 * ready for drawing
107 */
108/**
109 * PangoGlyphString:
110 * @num_glyphs: number of the glyphs in this glyph string.
111 * @glyphs: (array length=num_glyphs): array of glyph information
112 * for the glyph string.
113 * @log_clusters: logical cluster info, indexed by the byte index
114 * within the text corresponding to the glyph string.
115 *
116 * The #PangoGlyphString structure is used to store strings
117 * of glyphs with geometry and visual attribute information.
118 * The storage for the glyph information is owned
119 * by the structure which simplifies memory management.
120 */
121struct _PangoGlyphString {
122 gint num_glyphs;
123
124 PangoGlyphInfo *glyphs;
125
126 /* This is a memory inefficient way of representing the information
127 * here - each value gives the byte index within the text
128 * corresponding to the glyph string of the start of the cluster to
129 * which the glyph belongs.
130 */
131 gint *log_clusters;
132
133 /*< private >*/
134 gint space;
135};
136
137/**
138 * PANGO_TYPE_GLYPH_STRING:
139 *
140 * The #GObject type for #PangoGlyphString.
141 */
142#define PANGO_TYPE_GLYPH_STRING (pango_glyph_string_get_type ())
143
144PANGO_AVAILABLE_IN_ALL
145PangoGlyphString *pango_glyph_string_new (void);
146PANGO_AVAILABLE_IN_ALL
147void pango_glyph_string_set_size (PangoGlyphString *string,
148 gint new_len);
149PANGO_AVAILABLE_IN_ALL
150GType pango_glyph_string_get_type (void) G_GNUC_CONST;
151PANGO_AVAILABLE_IN_ALL
152PangoGlyphString *pango_glyph_string_copy (PangoGlyphString *string);
153PANGO_AVAILABLE_IN_ALL
154void pango_glyph_string_free (PangoGlyphString *string);
155PANGO_AVAILABLE_IN_ALL
156void pango_glyph_string_extents (PangoGlyphString *glyphs,
157 PangoFont *font,
158 PangoRectangle *ink_rect,
159 PangoRectangle *logical_rect);
160PANGO_AVAILABLE_IN_1_14
161int pango_glyph_string_get_width(PangoGlyphString *glyphs);
162
163PANGO_AVAILABLE_IN_ALL
164void pango_glyph_string_extents_range (PangoGlyphString *glyphs,
165 int start,
166 int end,
167 PangoFont *font,
168 PangoRectangle *ink_rect,
169 PangoRectangle *logical_rect);
170
171PANGO_AVAILABLE_IN_ALL
172void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
173 const char *text,
174 int length,
175 int embedding_level,
176 int *logical_widths);
177
178PANGO_AVAILABLE_IN_ALL
179void pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
180 char *text,
181 int length,
182 PangoAnalysis *analysis,
183 int index_,
184 gboolean trailing,
185 int *x_pos);
186PANGO_AVAILABLE_IN_ALL
187void pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
188 char *text,
189 int length,
190 PangoAnalysis *analysis,
191 int x_pos,
192 int *index_,
193 int *trailing);
194
195/* Turn a string of characters into a string of glyphs
196 */
197PANGO_AVAILABLE_IN_ALL
198void pango_shape (const gchar *text,
199 gint length,
200 const PangoAnalysis *analysis,
201 PangoGlyphString *glyphs);
202
203PANGO_AVAILABLE_IN_1_32
204void pango_shape_full (const gchar *item_text,
205 gint item_length,
206 const gchar *paragraph_text,
207 gint paragraph_length,
208 const PangoAnalysis *analysis,
209 PangoGlyphString *glyphs);
210
211PANGO_AVAILABLE_IN_ALL
212GList *pango_reorder_items (GList *logical_items);
213
214G_END_DECLS
215
216#endif /* __PANGO_GLYPH_H__ */
217