Git init
[external/pango1.0.git] / pango / pango-types.h
1 /* Pango
2  * pango-types.h:
3  *
4  * Copyright (C) 1999 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_TYPES_H__
23 #define __PANGO_TYPES_H__
24
25 #include <glib.h>
26 #include <glib-object.h>
27
28 G_BEGIN_DECLS
29
30 typedef struct _PangoLogAttr PangoLogAttr;
31
32 typedef struct _PangoEngineLang PangoEngineLang;
33 typedef struct _PangoEngineShape PangoEngineShape;
34
35 typedef struct _PangoFont    PangoFont;
36 typedef struct _PangoFontMap PangoFontMap;
37
38 typedef struct _PangoRectangle PangoRectangle;
39
40
41
42 /* A index of a glyph into a font. Rendering system dependent */
43 typedef guint32 PangoGlyph;
44
45
46
47 #define PANGO_SCALE 1024
48 #define PANGO_PIXELS(d) (((int)(d) + 512) >> 10)
49 #define PANGO_PIXELS_FLOOR(d) (((int)(d)) >> 10)
50 #define PANGO_PIXELS_CEIL(d) (((int)(d) + 1023) >> 10)
51 /* The above expressions are just slightly wrong for floating point d;
52  * For example we'd expect PANGO_PIXELS(-512.5) => -1 but instead we get 0.
53  * That's unlikely to matter for practical use and the expression is much
54  * more compact and faster than alternatives that work exactly for both
55  * integers and floating point.
56  *
57  * PANGO_PIXELS also behaves differently for +512 and -512.
58  */
59
60 #define PANGO_UNITS_ROUND(d)                            \
61   (((d) + (PANGO_SCALE >> 1)) & ~(PANGO_SCALE - 1))
62
63
64 int    pango_units_from_double (double d) G_GNUC_CONST;
65 double pango_units_to_double (int i) G_GNUC_CONST;
66
67
68
69 /* A rectangle. Used to store logical and physical extents of glyphs,
70  * runs, strings, etc.
71  */
72 struct _PangoRectangle
73 {
74   int x;
75   int y;
76   int width;
77   int height;
78 };
79
80 /* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
81  */
82 #define PANGO_ASCENT(rect) (-(rect).y)
83 #define PANGO_DESCENT(rect) ((rect).y + (rect).height)
84 #define PANGO_LBEARING(rect) ((rect).x)
85 #define PANGO_RBEARING(rect) ((rect).x + (rect).width)
86
87 void pango_extents_to_pixels (PangoRectangle *inclusive,
88                               PangoRectangle *nearest);
89
90
91 #include <pango/pango-gravity.h>
92 #include <pango/pango-language.h>
93 #include <pango/pango-matrix.h>
94 #include <pango/pango-script.h>
95 #include <pango/pango-bidi-type.h>
96
97
98 G_END_DECLS
99
100 #endif /* __PANGO_TYPES_H__ */