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