Git init
[external/pango1.0.git] / pango / pango-glyph.h
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
28 G_BEGIN_DECLS
29
30 typedef struct _PangoGlyphGeometry PangoGlyphGeometry;
31 typedef struct _PangoGlyphVisAttr PangoGlyphVisAttr;
32 typedef struct _PangoGlyphInfo PangoGlyphInfo;
33 typedef struct _PangoGlyphString PangoGlyphString;
34
35 /* 1024ths of a device unit */
36 typedef gint32 PangoGlyphUnit;
37
38 /* Positioning information about a glyph
39  */
40 struct _PangoGlyphGeometry
41 {
42   PangoGlyphUnit width;
43   PangoGlyphUnit x_offset;
44   PangoGlyphUnit y_offset;
45 };
46
47 /* Visual attributes of a glyph
48  */
49 struct _PangoGlyphVisAttr
50 {
51   guint is_cluster_start : 1;
52 };
53
54 /* A single glyph
55  */
56 struct _PangoGlyphInfo
57 {
58   PangoGlyph    glyph;
59   PangoGlyphGeometry geometry;
60   PangoGlyphVisAttr  attr;
61 };
62
63 /* A string of glyphs with positional information and visual attributes -
64  * ready for drawing
65  */
66 struct _PangoGlyphString {
67   gint num_glyphs;
68
69   PangoGlyphInfo *glyphs;
70
71   /* This is a memory inefficient way of representing the information
72    * here - each value gives the byte index within the text
73    * corresponding to the glyph string of the start of the cluster to
74    * which the glyph belongs.
75    */
76   gint *log_clusters;
77
78   /*< private >*/
79   gint space;
80 };
81
82 #define PANGO_TYPE_GLYPH_STRING (pango_glyph_string_get_type ())
83
84 PangoGlyphString *pango_glyph_string_new      (void);
85 void              pango_glyph_string_set_size (PangoGlyphString *string,
86                                                gint              new_len);
87 GType             pango_glyph_string_get_type (void) G_GNUC_CONST;
88 PangoGlyphString *pango_glyph_string_copy     (PangoGlyphString *string);
89 void              pango_glyph_string_free     (PangoGlyphString *string);
90 void              pango_glyph_string_extents  (PangoGlyphString *glyphs,
91                                                PangoFont        *font,
92                                                PangoRectangle   *ink_rect,
93                                                PangoRectangle   *logical_rect);
94 int               pango_glyph_string_get_width(PangoGlyphString *glyphs);
95
96 void              pango_glyph_string_extents_range  (PangoGlyphString *glyphs,
97                                                      int               start,
98                                                      int               end,
99                                                      PangoFont        *font,
100                                                      PangoRectangle   *ink_rect,
101                                                      PangoRectangle   *logical_rect);
102
103 void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
104                                             const char       *text,
105                                             int               length,
106                                             int               embedding_level,
107                                             int              *logical_widths);
108
109 void pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
110                                     char             *text,
111                                     int               length,
112                                     PangoAnalysis    *analysis,
113                                     int               index_,
114                                     gboolean          trailing,
115                                     int              *x_pos);
116 void pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
117                                     char             *text,
118                                     int               length,
119                                     PangoAnalysis    *analysis,
120                                     int               x_pos,
121                                     int              *index_,
122                                     int              *trailing);
123
124 /* Turn a string of characters into a string of glyphs
125  */
126 void pango_shape (const gchar      *text,
127                   gint              length,
128                   const PangoAnalysis *analysis,
129                   PangoGlyphString *glyphs);
130
131 GList *pango_reorder_items (GList *logical_items);
132
133 G_END_DECLS
134
135 #endif /* __PANGO_GLYPH_H__ */