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