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