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
28G_BEGIN_DECLS
29
30typedef struct _PangoLogAttr PangoLogAttr;
31
32typedef struct _PangoEngineLang PangoEngineLang;
33typedef struct _PangoEngineShape PangoEngineShape;
34
35typedef struct _PangoFont PangoFont;
36typedef struct _PangoFontMap PangoFontMap;
37
38typedef struct _PangoRectangle PangoRectangle;
39
40
41
42/* A index of a glyph into a font. Rendering system dependent */
43/**
44 * PangoGlyph:
45 *
46 * A #PangoGlyph represents a single glyph in the output form of a string.
47 */
48typedef guint32 PangoGlyph;
49
50
51
52/**
53 * PANGO_SCALE:
54 *
55 * The %PANGO_SCALE macro represents the scale between dimensions used
56 * for Pango distances and device units. (The definition of device
57 * units is dependent on the output device; it will typically be pixels
58 * for a screen, and points for a printer.) %PANGO_SCALE is currently
59 * 1024, but this may be changed in the future.
60 *
61 * When setting font sizes, device units are always considered to be
62 * points (as in "12 point font"), rather than pixels.
63 */
64/**
65 * PANGO_PIXELS:
66 * @d: a dimension in Pango units.
67 *
68 * Converts a dimension to device units by rounding.
69 *
70 * Return value: rounded dimension in device units.
71 */
72/**
73 * PANGO_PIXELS_FLOOR:
74 * @d: a dimension in Pango units.
75 *
76 * Converts a dimension to device units by flooring.
77 *
78 * Return value: floored dimension in device units.
79 * Since: 1.14
80 */
81/**
82 * PANGO_PIXELS_CEIL:
83 * @d: a dimension in Pango units.
84 *
85 * Converts a dimension to device units by ceiling.
86 *
87 * Return value: ceiled dimension in device units.
88 * Since: 1.14
89 */
90#define PANGO_SCALE 1024
91#define PANGO_PIXELS(d) (((int)(d) + 512) >> 10)
92#define PANGO_PIXELS_FLOOR(d) (((int)(d)) >> 10)
93#define PANGO_PIXELS_CEIL(d) (((int)(d) + 1023) >> 10)
94/* The above expressions are just slightly wrong for floating point d;
95 * For example we'd expect PANGO_PIXELS(-512.5) => -1 but instead we get 0.
96 * That's unlikely to matter for practical use and the expression is much
97 * more compact and faster than alternatives that work exactly for both
98 * integers and floating point.
99 *
100 * PANGO_PIXELS also behaves differently for +512 and -512.
101 */
102
103/**
104 * PANGO_UNITS_ROUND:
105 * @d: a dimension in Pango units.
106 *
107 * Rounds a dimension to whole device units, but does not
108 * convert it to device units.
109 *
110 * Return value: rounded dimension in Pango units.
111 * Since: 1.18
112 */
113#define PANGO_UNITS_ROUND(d) \
114 (((d) + (PANGO_SCALE >> 1)) & ~(PANGO_SCALE - 1))
115
116
117int pango_units_from_double (double d) G_GNUC_CONST;
118double pango_units_to_double (int i) G_GNUC_CONST;
119
120
121
122/**
123 * PangoRectangle:
124 * @x: X coordinate of the left side of the rectangle.
125 * @y: Y coordinate of the the top side of the rectangle.
126 * @width: width of the rectangle.
127 * @height: height of the rectangle.
128 *
129 * The #PangoRectangle structure represents a rectangle. It is frequently
130 * used to represent the logical or ink extents of a single glyph or section
131 * of text. (See, for instance, pango_font_get_glyph_extents())
132 *
133 */
134struct _PangoRectangle
135{
136 int x;
137 int y;
138 int width;
139 int height;
140};
141
142/* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
143 */
144/**
145 * PANGO_ASCENT:
146 * @rect: a #PangoRectangle
147 *
148 * Extracts the <firstterm>ascent</firstterm> from a #PangoRectangle
149 * representing glyph extents. The ascent is the distance from the
150 * baseline to the highest point of the character. This is positive if the
151 * glyph ascends above the baseline.
152 */
153/**
154 * PANGO_DESCENT:
155 * @rect: a #PangoRectangle
156 *
157 * Extracts the <firstterm>descent</firstterm> from a #PangoRectangle
158 * representing glyph extents. The descent is the distance from the
159 * baseline to the lowest point of the character. This is positive if the
160 * glyph descends below the baseline.
161 */
162/**
163 * PANGO_LBEARING:
164 * @rect: a #PangoRectangle
165 *
166 * Extracts the <firstterm>left bearing</firstterm> from a #PangoRectangle
167 * representing glyph extents. The left bearing is the distance from the
168 * horizontal origin to the farthest left point of the character.
169 * This is positive for characters drawn completely to the right of the
170 * glyph origin.
171 */
172/**
173 * PANGO_RBEARING:
174 * @rect: a #PangoRectangle
175 *
176 * Extracts the <firstterm>right bearing</firstterm> from a #PangoRectangle
177 * representing glyph extents. The right bearing is the distance from the
178 * horizontal origin to the farthest right point of the character.
179 * This is positive except for characters drawn completely to the left of the
180 * horizontal origin.
181 */
182#define PANGO_ASCENT(rect) (-(rect).y)
183#define PANGO_DESCENT(rect) ((rect).y + (rect).height)
184#define PANGO_LBEARING(rect) ((rect).x)
185#define PANGO_RBEARING(rect) ((rect).x + (rect).width)
186
187void pango_extents_to_pixels (PangoRectangle *inclusive,
188 PangoRectangle *nearest);
189
190
191#include <pango/pango-gravity.h>
192#include <pango/pango-language.h>
193#include <pango/pango-matrix.h>
194#include <pango/pango-script.h>
195#include <pango/pango-bidi-type.h>
196
197
198G_END_DECLS
199
200#endif /* __PANGO_TYPES_H__ */
201