1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module pango.c.types;
7 
8 public import pango.c.gravity;
9 public import pango.c.language;
10 public import pango.c.matrix;
11 public import pango.c.script;
12 public import pango.c.bidi_type;
13 
14 import glib;
15 import gobject;
16 
17 
18 
19 /* A index of a glyph into a font. Rendering system dependent */
20 /**
21  * PangoGlyph:
22  *
23  * A #PangoGlyph represents a single glyph in the output form of a string.
24  */
25 alias PangoGlyph = guint32;
26 
27 
28 
29 /**
30  * PANGO_SCALE:
31  *
32  * The %PANGO_SCALE macro represents the scale between dimensions used
33  * for Pango distances and device units. (The definition of device
34  * units is dependent on the output device; it will typically be pixels
35  * for a screen, and points for a printer.) %PANGO_SCALE is currently
36  * 1024, but this may be changed in the future.
37  *
38  * When setting font sizes, device units are always considered to be
39  * points (as in "12 point font"), rather than pixels.
40  */
41 /**
42  * PANGO_PIXELS:
43  * @d: a dimension in Pango units.
44  *
45  * Converts a dimension to device units by rounding.
46  *
47  * Return value: rounded dimension in device units.
48  */
49 /**
50  * PANGO_PIXELS_FLOOR:
51  * @d: a dimension in Pango units.
52  *
53  * Converts a dimension to device units by flooring.
54  *
55  * Return value: floored dimension in device units.
56  * Since: 1.14
57  */
58 /**
59  * PANGO_PIXELS_CEIL:
60  * @d: a dimension in Pango units.
61  *
62  * Converts a dimension to device units by ceiling.
63  *
64  * Return value: ceiled dimension in device units.
65  * Since: 1.14
66  */
67 enum PANGO_SCALE = 1024;
68 auto PANGO_PIXELS(D)(D d) { return ((cast(int)d)+512) >> 10; }
69 auto PANGO_PIXELS_FLOOR(D)(D d) { return (cast(int)d) >> 10; }
70 auto PANGO_PIXELS_CEIL(D)(D d) { return ((cast(int)d) + 1023) >> 10; }
71 
72 
73 
74 /* The above expressions are just slightly wrong for floating point d;
75  * For example we'd expect PANGO_PIXELS(-512.5) => -1 but instead we get 0.
76  * That's unlikely to matter for practical use and the expression is much
77  * more compact and faster than alternatives that work exactly for both
78  * integers and floating point.
79  *
80  * PANGO_PIXELS also behaves differently for +512 and -512.
81  */
82 
83 /**
84  * PANGO_UNITS_ROUND:
85  * @d: a dimension in Pango units.
86  *
87  * Rounds a dimension to whole device units, but does not
88  * convert it to device units.
89  *
90  * Return value: rounded dimension in Pango units.
91  * Since: 1.18
92  */
93 auto PANGO_UNITS_ROUND(D)(D d) { (d + (PANGO_SCALE >> 1)) & ~(PANGO_SCALE - 1); }
94 
95 
96 extern (C)
97 pure int    pango_units_from_double (double d);
98 
99 extern (C)
100 pure double pango_units_to_double (int i);
101 
102 
103 /**
104  * PangoRectangle:
105  * @x: X coordinate of the left side of the rectangle.
106  * @y: Y coordinate of the the top side of the rectangle.
107  * @width: width of the rectangle.
108  * @height: height of the rectangle.
109  *
110  * The #PangoRectangle structure represents a rectangle. It is frequently
111  * used to represent the logical or ink extents of a single glyph or section
112  * of text. (See, for instance, pango_font_get_glyph_extents())
113  *
114  */
115 struct PangoRectangle
116 {
117   int x;
118   int y;
119   int width;
120   int height;
121 }
122 
123 /* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
124  */
125 /**
126  * PANGO_ASCENT:
127  * @rect: a #PangoRectangle
128  *
129  * Extracts the <firstterm>ascent</firstterm> from a #PangoRectangle
130  * representing glyph extents. The ascent is the distance from the
131  * baseline to the highest point of the character. This is positive if the
132  * glyph ascends above the baseline.
133  */
134 /**
135  * PANGO_DESCENT:
136  * @rect: a #PangoRectangle
137  *
138  * Extracts the <firstterm>descent</firstterm> from a #PangoRectangle
139  * representing glyph extents. The descent is the distance from the
140  * baseline to the lowest point of the character. This is positive if the
141  * glyph descends below the baseline.
142  */
143 /**
144  * PANGO_LBEARING:
145  * @rect: a #PangoRectangle
146  *
147  * Extracts the <firstterm>left bearing</firstterm> from a #PangoRectangle
148  * representing glyph extents. The left bearing is the distance from the
149  * horizontal origin to the farthest left point of the character.
150  * This is positive for characters drawn completely to the right of the
151  * glyph origin.
152  */
153 /**
154  * PANGO_RBEARING:
155  * @rect: a #PangoRectangle
156  *
157  * Extracts the <firstterm>right bearing</firstterm> from a #PangoRectangle
158  * representing glyph extents. The right bearing is the distance from the
159  * horizontal origin to the farthest right point of the character.
160  * This is positive except for characters drawn completely to the left of the
161  * horizontal origin.
162  */
163 auto PANGO_ASCENT(R)(R rect) { return -rect.y; }
164 auto PANGO_DESCENT(R)(R rect) { return rect.y + rect.height; }
165 auto PANGO_LBEARING(R)(R rect) { return rect.x; }
166 auto PANGO_RBEARING(R)(R rect) { return rect.x + rect.width; }
167 
168 extern (C)
169 void pango_extents_to_pixels (PangoRectangle *inclusive,
170 			      PangoRectangle *nearest);
171 
172