Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /***************************************************************************/ |
michael@0 | 2 | /* */ |
michael@0 | 3 | /* ftglyph.h */ |
michael@0 | 4 | /* */ |
michael@0 | 5 | /* FreeType convenience functions to handle glyphs (specification). */ |
michael@0 | 6 | /* */ |
michael@0 | 7 | /* Copyright 1996-2003, 2006, 2008, 2009, 2011, 2013 by */ |
michael@0 | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
michael@0 | 9 | /* */ |
michael@0 | 10 | /* This file is part of the FreeType project, and may only be used, */ |
michael@0 | 11 | /* modified, and distributed under the terms of the FreeType project */ |
michael@0 | 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
michael@0 | 13 | /* this file you indicate that you have read the license and */ |
michael@0 | 14 | /* understand and accept it fully. */ |
michael@0 | 15 | /* */ |
michael@0 | 16 | /***************************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | |
michael@0 | 19 | /*************************************************************************/ |
michael@0 | 20 | /* */ |
michael@0 | 21 | /* This file contains the definition of several convenience functions */ |
michael@0 | 22 | /* that can be used by client applications to easily retrieve glyph */ |
michael@0 | 23 | /* bitmaps and outlines from a given face. */ |
michael@0 | 24 | /* */ |
michael@0 | 25 | /* These functions should be optional if you are writing a font server */ |
michael@0 | 26 | /* or text layout engine on top of FreeType. However, they are pretty */ |
michael@0 | 27 | /* handy for many other simple uses of the library. */ |
michael@0 | 28 | /* */ |
michael@0 | 29 | /*************************************************************************/ |
michael@0 | 30 | |
michael@0 | 31 | |
michael@0 | 32 | #ifndef __FTGLYPH_H__ |
michael@0 | 33 | #define __FTGLYPH_H__ |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | #include <ft2build.h> |
michael@0 | 37 | #include FT_FREETYPE_H |
michael@0 | 38 | |
michael@0 | 39 | #ifdef FREETYPE_H |
michael@0 | 40 | #error "freetype.h of FreeType 1 has been loaded!" |
michael@0 | 41 | #error "Please fix the directory search order for header files" |
michael@0 | 42 | #error "so that freetype.h of FreeType 2 is found first." |
michael@0 | 43 | #endif |
michael@0 | 44 | |
michael@0 | 45 | |
michael@0 | 46 | FT_BEGIN_HEADER |
michael@0 | 47 | |
michael@0 | 48 | |
michael@0 | 49 | /*************************************************************************/ |
michael@0 | 50 | /* */ |
michael@0 | 51 | /* <Section> */ |
michael@0 | 52 | /* glyph_management */ |
michael@0 | 53 | /* */ |
michael@0 | 54 | /* <Title> */ |
michael@0 | 55 | /* Glyph Management */ |
michael@0 | 56 | /* */ |
michael@0 | 57 | /* <Abstract> */ |
michael@0 | 58 | /* Generic interface to manage individual glyph data. */ |
michael@0 | 59 | /* */ |
michael@0 | 60 | /* <Description> */ |
michael@0 | 61 | /* This section contains definitions used to manage glyph data */ |
michael@0 | 62 | /* through generic FT_Glyph objects. Each of them can contain a */ |
michael@0 | 63 | /* bitmap, a vector outline, or even images in other formats. */ |
michael@0 | 64 | /* */ |
michael@0 | 65 | /*************************************************************************/ |
michael@0 | 66 | |
michael@0 | 67 | |
michael@0 | 68 | /* forward declaration to a private type */ |
michael@0 | 69 | typedef struct FT_Glyph_Class_ FT_Glyph_Class; |
michael@0 | 70 | |
michael@0 | 71 | |
michael@0 | 72 | /*************************************************************************/ |
michael@0 | 73 | /* */ |
michael@0 | 74 | /* <Type> */ |
michael@0 | 75 | /* FT_Glyph */ |
michael@0 | 76 | /* */ |
michael@0 | 77 | /* <Description> */ |
michael@0 | 78 | /* Handle to an object used to model generic glyph images. It is a */ |
michael@0 | 79 | /* pointer to the @FT_GlyphRec structure and can contain a glyph */ |
michael@0 | 80 | /* bitmap or pointer. */ |
michael@0 | 81 | /* */ |
michael@0 | 82 | /* <Note> */ |
michael@0 | 83 | /* Glyph objects are not owned by the library. You must thus release */ |
michael@0 | 84 | /* them manually (through @FT_Done_Glyph) _before_ calling */ |
michael@0 | 85 | /* @FT_Done_FreeType. */ |
michael@0 | 86 | /* */ |
michael@0 | 87 | typedef struct FT_GlyphRec_* FT_Glyph; |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | /*************************************************************************/ |
michael@0 | 91 | /* */ |
michael@0 | 92 | /* <Struct> */ |
michael@0 | 93 | /* FT_GlyphRec */ |
michael@0 | 94 | /* */ |
michael@0 | 95 | /* <Description> */ |
michael@0 | 96 | /* The root glyph structure contains a given glyph image plus its */ |
michael@0 | 97 | /* advance width in 16.16 fixed-point format. */ |
michael@0 | 98 | /* */ |
michael@0 | 99 | /* <Fields> */ |
michael@0 | 100 | /* library :: A handle to the FreeType library object. */ |
michael@0 | 101 | /* */ |
michael@0 | 102 | /* clazz :: A pointer to the glyph's class. Private. */ |
michael@0 | 103 | /* */ |
michael@0 | 104 | /* format :: The format of the glyph's image. */ |
michael@0 | 105 | /* */ |
michael@0 | 106 | /* advance :: A 16.16 vector that gives the glyph's advance width. */ |
michael@0 | 107 | /* */ |
michael@0 | 108 | typedef struct FT_GlyphRec_ |
michael@0 | 109 | { |
michael@0 | 110 | FT_Library library; |
michael@0 | 111 | const FT_Glyph_Class* clazz; |
michael@0 | 112 | FT_Glyph_Format format; |
michael@0 | 113 | FT_Vector advance; |
michael@0 | 114 | |
michael@0 | 115 | } FT_GlyphRec; |
michael@0 | 116 | |
michael@0 | 117 | |
michael@0 | 118 | /*************************************************************************/ |
michael@0 | 119 | /* */ |
michael@0 | 120 | /* <Type> */ |
michael@0 | 121 | /* FT_BitmapGlyph */ |
michael@0 | 122 | /* */ |
michael@0 | 123 | /* <Description> */ |
michael@0 | 124 | /* A handle to an object used to model a bitmap glyph image. This is */ |
michael@0 | 125 | /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ |
michael@0 | 126 | /* */ |
michael@0 | 127 | typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; |
michael@0 | 128 | |
michael@0 | 129 | |
michael@0 | 130 | /*************************************************************************/ |
michael@0 | 131 | /* */ |
michael@0 | 132 | /* <Struct> */ |
michael@0 | 133 | /* FT_BitmapGlyphRec */ |
michael@0 | 134 | /* */ |
michael@0 | 135 | /* <Description> */ |
michael@0 | 136 | /* A structure used for bitmap glyph images. This really is a */ |
michael@0 | 137 | /* `sub-class' of @FT_GlyphRec. */ |
michael@0 | 138 | /* */ |
michael@0 | 139 | /* <Fields> */ |
michael@0 | 140 | /* root :: The root @FT_Glyph fields. */ |
michael@0 | 141 | /* */ |
michael@0 | 142 | /* left :: The left-side bearing, i.e., the horizontal distance */ |
michael@0 | 143 | /* from the current pen position to the left border of the */ |
michael@0 | 144 | /* glyph bitmap. */ |
michael@0 | 145 | /* */ |
michael@0 | 146 | /* top :: The top-side bearing, i.e., the vertical distance from */ |
michael@0 | 147 | /* the current pen position to the top border of the glyph */ |
michael@0 | 148 | /* bitmap. This distance is positive for upwards~y! */ |
michael@0 | 149 | /* */ |
michael@0 | 150 | /* bitmap :: A descriptor for the bitmap. */ |
michael@0 | 151 | /* */ |
michael@0 | 152 | /* <Note> */ |
michael@0 | 153 | /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ |
michael@0 | 154 | /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ |
michael@0 | 155 | /* the bitmap's contents easily. */ |
michael@0 | 156 | /* */ |
michael@0 | 157 | /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ |
michael@0 | 158 | /* and is thus created and destroyed with it. */ |
michael@0 | 159 | /* */ |
michael@0 | 160 | typedef struct FT_BitmapGlyphRec_ |
michael@0 | 161 | { |
michael@0 | 162 | FT_GlyphRec root; |
michael@0 | 163 | FT_Int left; |
michael@0 | 164 | FT_Int top; |
michael@0 | 165 | FT_Bitmap bitmap; |
michael@0 | 166 | |
michael@0 | 167 | } FT_BitmapGlyphRec; |
michael@0 | 168 | |
michael@0 | 169 | |
michael@0 | 170 | /*************************************************************************/ |
michael@0 | 171 | /* */ |
michael@0 | 172 | /* <Type> */ |
michael@0 | 173 | /* FT_OutlineGlyph */ |
michael@0 | 174 | /* */ |
michael@0 | 175 | /* <Description> */ |
michael@0 | 176 | /* A handle to an object used to model an outline glyph image. This */ |
michael@0 | 177 | /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ |
michael@0 | 178 | /* */ |
michael@0 | 179 | typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; |
michael@0 | 180 | |
michael@0 | 181 | |
michael@0 | 182 | /*************************************************************************/ |
michael@0 | 183 | /* */ |
michael@0 | 184 | /* <Struct> */ |
michael@0 | 185 | /* FT_OutlineGlyphRec */ |
michael@0 | 186 | /* */ |
michael@0 | 187 | /* <Description> */ |
michael@0 | 188 | /* A structure used for outline (vectorial) glyph images. This */ |
michael@0 | 189 | /* really is a `sub-class' of @FT_GlyphRec. */ |
michael@0 | 190 | /* */ |
michael@0 | 191 | /* <Fields> */ |
michael@0 | 192 | /* root :: The root @FT_Glyph fields. */ |
michael@0 | 193 | /* */ |
michael@0 | 194 | /* outline :: A descriptor for the outline. */ |
michael@0 | 195 | /* */ |
michael@0 | 196 | /* <Note> */ |
michael@0 | 197 | /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ |
michael@0 | 198 | /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ |
michael@0 | 199 | /* the outline's content easily. */ |
michael@0 | 200 | /* */ |
michael@0 | 201 | /* As the outline is extracted from a glyph slot, its coordinates are */ |
michael@0 | 202 | /* expressed normally in 26.6 pixels, unless the flag */ |
michael@0 | 203 | /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ |
michael@0 | 204 | /* */ |
michael@0 | 205 | /* The outline's tables are always owned by the object and are */ |
michael@0 | 206 | /* destroyed with it. */ |
michael@0 | 207 | /* */ |
michael@0 | 208 | typedef struct FT_OutlineGlyphRec_ |
michael@0 | 209 | { |
michael@0 | 210 | FT_GlyphRec root; |
michael@0 | 211 | FT_Outline outline; |
michael@0 | 212 | |
michael@0 | 213 | } FT_OutlineGlyphRec; |
michael@0 | 214 | |
michael@0 | 215 | |
michael@0 | 216 | /*************************************************************************/ |
michael@0 | 217 | /* */ |
michael@0 | 218 | /* <Function> */ |
michael@0 | 219 | /* FT_Get_Glyph */ |
michael@0 | 220 | /* */ |
michael@0 | 221 | /* <Description> */ |
michael@0 | 222 | /* A function used to extract a glyph image from a slot. Note that */ |
michael@0 | 223 | /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ |
michael@0 | 224 | /* */ |
michael@0 | 225 | /* <Input> */ |
michael@0 | 226 | /* slot :: A handle to the source glyph slot. */ |
michael@0 | 227 | /* */ |
michael@0 | 228 | /* <Output> */ |
michael@0 | 229 | /* aglyph :: A handle to the glyph object. */ |
michael@0 | 230 | /* */ |
michael@0 | 231 | /* <Return> */ |
michael@0 | 232 | /* FreeType error code. 0~means success. */ |
michael@0 | 233 | /* */ |
michael@0 | 234 | FT_EXPORT( FT_Error ) |
michael@0 | 235 | FT_Get_Glyph( FT_GlyphSlot slot, |
michael@0 | 236 | FT_Glyph *aglyph ); |
michael@0 | 237 | |
michael@0 | 238 | |
michael@0 | 239 | /*************************************************************************/ |
michael@0 | 240 | /* */ |
michael@0 | 241 | /* <Function> */ |
michael@0 | 242 | /* FT_Glyph_Copy */ |
michael@0 | 243 | /* */ |
michael@0 | 244 | /* <Description> */ |
michael@0 | 245 | /* A function used to copy a glyph image. Note that the created */ |
michael@0 | 246 | /* @FT_Glyph object must be released with @FT_Done_Glyph. */ |
michael@0 | 247 | /* */ |
michael@0 | 248 | /* <Input> */ |
michael@0 | 249 | /* source :: A handle to the source glyph object. */ |
michael@0 | 250 | /* */ |
michael@0 | 251 | /* <Output> */ |
michael@0 | 252 | /* target :: A handle to the target glyph object. 0~in case of */ |
michael@0 | 253 | /* error. */ |
michael@0 | 254 | /* */ |
michael@0 | 255 | /* <Return> */ |
michael@0 | 256 | /* FreeType error code. 0~means success. */ |
michael@0 | 257 | /* */ |
michael@0 | 258 | FT_EXPORT( FT_Error ) |
michael@0 | 259 | FT_Glyph_Copy( FT_Glyph source, |
michael@0 | 260 | FT_Glyph *target ); |
michael@0 | 261 | |
michael@0 | 262 | |
michael@0 | 263 | /*************************************************************************/ |
michael@0 | 264 | /* */ |
michael@0 | 265 | /* <Function> */ |
michael@0 | 266 | /* FT_Glyph_Transform */ |
michael@0 | 267 | /* */ |
michael@0 | 268 | /* <Description> */ |
michael@0 | 269 | /* Transform a glyph image if its format is scalable. */ |
michael@0 | 270 | /* */ |
michael@0 | 271 | /* <InOut> */ |
michael@0 | 272 | /* glyph :: A handle to the target glyph object. */ |
michael@0 | 273 | /* */ |
michael@0 | 274 | /* <Input> */ |
michael@0 | 275 | /* matrix :: A pointer to a 2x2 matrix to apply. */ |
michael@0 | 276 | /* */ |
michael@0 | 277 | /* delta :: A pointer to a 2d vector to apply. Coordinates are */ |
michael@0 | 278 | /* expressed in 1/64th of a pixel. */ |
michael@0 | 279 | /* */ |
michael@0 | 280 | /* <Return> */ |
michael@0 | 281 | /* FreeType error code (if not 0, the glyph format is not scalable). */ |
michael@0 | 282 | /* */ |
michael@0 | 283 | /* <Note> */ |
michael@0 | 284 | /* The 2x2 transformation matrix is also applied to the glyph's */ |
michael@0 | 285 | /* advance vector. */ |
michael@0 | 286 | /* */ |
michael@0 | 287 | FT_EXPORT( FT_Error ) |
michael@0 | 288 | FT_Glyph_Transform( FT_Glyph glyph, |
michael@0 | 289 | FT_Matrix* matrix, |
michael@0 | 290 | FT_Vector* delta ); |
michael@0 | 291 | |
michael@0 | 292 | |
michael@0 | 293 | /*************************************************************************/ |
michael@0 | 294 | /* */ |
michael@0 | 295 | /* <Enum> */ |
michael@0 | 296 | /* FT_Glyph_BBox_Mode */ |
michael@0 | 297 | /* */ |
michael@0 | 298 | /* <Description> */ |
michael@0 | 299 | /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ |
michael@0 | 300 | /* */ |
michael@0 | 301 | /* <Values> */ |
michael@0 | 302 | /* FT_GLYPH_BBOX_UNSCALED :: */ |
michael@0 | 303 | /* Return unscaled font units. */ |
michael@0 | 304 | /* */ |
michael@0 | 305 | /* FT_GLYPH_BBOX_SUBPIXELS :: */ |
michael@0 | 306 | /* Return unfitted 26.6 coordinates. */ |
michael@0 | 307 | /* */ |
michael@0 | 308 | /* FT_GLYPH_BBOX_GRIDFIT :: */ |
michael@0 | 309 | /* Return grid-fitted 26.6 coordinates. */ |
michael@0 | 310 | /* */ |
michael@0 | 311 | /* FT_GLYPH_BBOX_TRUNCATE :: */ |
michael@0 | 312 | /* Return coordinates in integer pixels. */ |
michael@0 | 313 | /* */ |
michael@0 | 314 | /* FT_GLYPH_BBOX_PIXELS :: */ |
michael@0 | 315 | /* Return grid-fitted pixel coordinates. */ |
michael@0 | 316 | /* */ |
michael@0 | 317 | typedef enum FT_Glyph_BBox_Mode_ |
michael@0 | 318 | { |
michael@0 | 319 | FT_GLYPH_BBOX_UNSCALED = 0, |
michael@0 | 320 | FT_GLYPH_BBOX_SUBPIXELS = 0, |
michael@0 | 321 | FT_GLYPH_BBOX_GRIDFIT = 1, |
michael@0 | 322 | FT_GLYPH_BBOX_TRUNCATE = 2, |
michael@0 | 323 | FT_GLYPH_BBOX_PIXELS = 3 |
michael@0 | 324 | |
michael@0 | 325 | } FT_Glyph_BBox_Mode; |
michael@0 | 326 | |
michael@0 | 327 | |
michael@0 | 328 | /*************************************************************************/ |
michael@0 | 329 | /* */ |
michael@0 | 330 | /* <Enum> */ |
michael@0 | 331 | /* ft_glyph_bbox_xxx */ |
michael@0 | 332 | /* */ |
michael@0 | 333 | /* <Description> */ |
michael@0 | 334 | /* These constants are deprecated. Use the corresponding */ |
michael@0 | 335 | /* @FT_Glyph_BBox_Mode values instead. */ |
michael@0 | 336 | /* */ |
michael@0 | 337 | /* <Values> */ |
michael@0 | 338 | /* ft_glyph_bbox_unscaled :: See @FT_GLYPH_BBOX_UNSCALED. */ |
michael@0 | 339 | /* ft_glyph_bbox_subpixels :: See @FT_GLYPH_BBOX_SUBPIXELS. */ |
michael@0 | 340 | /* ft_glyph_bbox_gridfit :: See @FT_GLYPH_BBOX_GRIDFIT. */ |
michael@0 | 341 | /* ft_glyph_bbox_truncate :: See @FT_GLYPH_BBOX_TRUNCATE. */ |
michael@0 | 342 | /* ft_glyph_bbox_pixels :: See @FT_GLYPH_BBOX_PIXELS. */ |
michael@0 | 343 | /* */ |
michael@0 | 344 | #define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED |
michael@0 | 345 | #define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS |
michael@0 | 346 | #define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT |
michael@0 | 347 | #define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE |
michael@0 | 348 | #define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS |
michael@0 | 349 | |
michael@0 | 350 | |
michael@0 | 351 | /*************************************************************************/ |
michael@0 | 352 | /* */ |
michael@0 | 353 | /* <Function> */ |
michael@0 | 354 | /* FT_Glyph_Get_CBox */ |
michael@0 | 355 | /* */ |
michael@0 | 356 | /* <Description> */ |
michael@0 | 357 | /* Return a glyph's `control box'. The control box encloses all the */ |
michael@0 | 358 | /* outline's points, including Bézier control points. Though it */ |
michael@0 | 359 | /* coincides with the exact bounding box for most glyphs, it can be */ |
michael@0 | 360 | /* slightly larger in some situations (like when rotating an outline */ |
michael@0 | 361 | /* that contains Bézier outside arcs). */ |
michael@0 | 362 | /* */ |
michael@0 | 363 | /* Computing the control box is very fast, while getting the bounding */ |
michael@0 | 364 | /* box can take much more time as it needs to walk over all segments */ |
michael@0 | 365 | /* and arcs in the outline. To get the latter, you can use the */ |
michael@0 | 366 | /* `ftbbox' component, which is dedicated to this single task. */ |
michael@0 | 367 | /* */ |
michael@0 | 368 | /* <Input> */ |
michael@0 | 369 | /* glyph :: A handle to the source glyph object. */ |
michael@0 | 370 | /* */ |
michael@0 | 371 | /* mode :: The mode that indicates how to interpret the returned */ |
michael@0 | 372 | /* bounding box values. */ |
michael@0 | 373 | /* */ |
michael@0 | 374 | /* <Output> */ |
michael@0 | 375 | /* acbox :: The glyph coordinate bounding box. Coordinates are */ |
michael@0 | 376 | /* expressed in 1/64th of pixels if it is grid-fitted. */ |
michael@0 | 377 | /* */ |
michael@0 | 378 | /* <Note> */ |
michael@0 | 379 | /* Coordinates are relative to the glyph origin, using the y~upwards */ |
michael@0 | 380 | /* convention. */ |
michael@0 | 381 | /* */ |
michael@0 | 382 | /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ |
michael@0 | 383 | /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ |
michael@0 | 384 | /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ |
michael@0 | 385 | /* is another name for this constant. */ |
michael@0 | 386 | /* */ |
michael@0 | 387 | /* If the font is tricky and the glyph has been loaded with */ |
michael@0 | 388 | /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ |
michael@0 | 389 | /* reasonable values for the CBox it is necessary to load the glyph */ |
michael@0 | 390 | /* at a large ppem value (so that the hinting instructions can */ |
michael@0 | 391 | /* properly shift and scale the subglyphs), then extracting the CBox, */ |
michael@0 | 392 | /* which can be eventually converted back to font units. */ |
michael@0 | 393 | /* */ |
michael@0 | 394 | /* Note that the maximum coordinates are exclusive, which means that */ |
michael@0 | 395 | /* one can compute the width and height of the glyph image (be it in */ |
michael@0 | 396 | /* integer or 26.6 pixels) as: */ |
michael@0 | 397 | /* */ |
michael@0 | 398 | /* { */ |
michael@0 | 399 | /* width = bbox.xMax - bbox.xMin; */ |
michael@0 | 400 | /* height = bbox.yMax - bbox.yMin; */ |
michael@0 | 401 | /* } */ |
michael@0 | 402 | /* */ |
michael@0 | 403 | /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ |
michael@0 | 404 | /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ |
michael@0 | 405 | /* which corresponds to: */ |
michael@0 | 406 | /* */ |
michael@0 | 407 | /* { */ |
michael@0 | 408 | /* bbox.xMin = FLOOR(bbox.xMin); */ |
michael@0 | 409 | /* bbox.yMin = FLOOR(bbox.yMin); */ |
michael@0 | 410 | /* bbox.xMax = CEILING(bbox.xMax); */ |
michael@0 | 411 | /* bbox.yMax = CEILING(bbox.yMax); */ |
michael@0 | 412 | /* } */ |
michael@0 | 413 | /* */ |
michael@0 | 414 | /* To get the bbox in pixel coordinates, set `bbox_mode' to */ |
michael@0 | 415 | /* @FT_GLYPH_BBOX_TRUNCATE. */ |
michael@0 | 416 | /* */ |
michael@0 | 417 | /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ |
michael@0 | 418 | /* to @FT_GLYPH_BBOX_PIXELS. */ |
michael@0 | 419 | /* */ |
michael@0 | 420 | FT_EXPORT( void ) |
michael@0 | 421 | FT_Glyph_Get_CBox( FT_Glyph glyph, |
michael@0 | 422 | FT_UInt bbox_mode, |
michael@0 | 423 | FT_BBox *acbox ); |
michael@0 | 424 | |
michael@0 | 425 | |
michael@0 | 426 | /*************************************************************************/ |
michael@0 | 427 | /* */ |
michael@0 | 428 | /* <Function> */ |
michael@0 | 429 | /* FT_Glyph_To_Bitmap */ |
michael@0 | 430 | /* */ |
michael@0 | 431 | /* <Description> */ |
michael@0 | 432 | /* Convert a given glyph object to a bitmap glyph object. */ |
michael@0 | 433 | /* */ |
michael@0 | 434 | /* <InOut> */ |
michael@0 | 435 | /* the_glyph :: A pointer to a handle to the target glyph. */ |
michael@0 | 436 | /* */ |
michael@0 | 437 | /* <Input> */ |
michael@0 | 438 | /* render_mode :: An enumeration that describes how the data is */ |
michael@0 | 439 | /* rendered. */ |
michael@0 | 440 | /* */ |
michael@0 | 441 | /* origin :: A pointer to a vector used to translate the glyph */ |
michael@0 | 442 | /* image before rendering. Can be~0 (if no */ |
michael@0 | 443 | /* translation). The origin is expressed in */ |
michael@0 | 444 | /* 26.6 pixels. */ |
michael@0 | 445 | /* */ |
michael@0 | 446 | /* destroy :: A boolean that indicates that the original glyph */ |
michael@0 | 447 | /* image should be destroyed by this function. It is */ |
michael@0 | 448 | /* never destroyed in case of error. */ |
michael@0 | 449 | /* */ |
michael@0 | 450 | /* <Return> */ |
michael@0 | 451 | /* FreeType error code. 0~means success. */ |
michael@0 | 452 | /* */ |
michael@0 | 453 | /* <Note> */ |
michael@0 | 454 | /* This function does nothing if the glyph format isn't scalable. */ |
michael@0 | 455 | /* */ |
michael@0 | 456 | /* The glyph image is translated with the `origin' vector before */ |
michael@0 | 457 | /* rendering. */ |
michael@0 | 458 | /* */ |
michael@0 | 459 | /* The first parameter is a pointer to an @FT_Glyph handle, that will */ |
michael@0 | 460 | /* be _replaced_ by this function (with newly allocated data). */ |
michael@0 | 461 | /* Typically, you would use (omitting error handling): */ |
michael@0 | 462 | /* */ |
michael@0 | 463 | /* */ |
michael@0 | 464 | /* { */ |
michael@0 | 465 | /* FT_Glyph glyph; */ |
michael@0 | 466 | /* FT_BitmapGlyph glyph_bitmap; */ |
michael@0 | 467 | /* */ |
michael@0 | 468 | /* */ |
michael@0 | 469 | /* // load glyph */ |
michael@0 | 470 | /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ |
michael@0 | 471 | /* */ |
michael@0 | 472 | /* // extract glyph image */ |
michael@0 | 473 | /* error = FT_Get_Glyph( face->glyph, &glyph ); */ |
michael@0 | 474 | /* */ |
michael@0 | 475 | /* // convert to a bitmap (default render mode + destroying old) */ |
michael@0 | 476 | /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ |
michael@0 | 477 | /* { */ |
michael@0 | 478 | /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ |
michael@0 | 479 | /* 0, 1 ); */ |
michael@0 | 480 | /* if ( error ) // `glyph' unchanged */ |
michael@0 | 481 | /* ... */ |
michael@0 | 482 | /* } */ |
michael@0 | 483 | /* */ |
michael@0 | 484 | /* // access bitmap content by typecasting */ |
michael@0 | 485 | /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ |
michael@0 | 486 | /* */ |
michael@0 | 487 | /* // do funny stuff with it, like blitting/drawing */ |
michael@0 | 488 | /* ... */ |
michael@0 | 489 | /* */ |
michael@0 | 490 | /* // discard glyph image (bitmap or not) */ |
michael@0 | 491 | /* FT_Done_Glyph( glyph ); */ |
michael@0 | 492 | /* } */ |
michael@0 | 493 | /* */ |
michael@0 | 494 | /* */ |
michael@0 | 495 | /* Here another example, again without error handling: */ |
michael@0 | 496 | /* */ |
michael@0 | 497 | /* */ |
michael@0 | 498 | /* { */ |
michael@0 | 499 | /* FT_Glyph glyphs[MAX_GLYPHS] */ |
michael@0 | 500 | /* */ |
michael@0 | 501 | /* */ |
michael@0 | 502 | /* ... */ |
michael@0 | 503 | /* */ |
michael@0 | 504 | /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ |
michael@0 | 505 | /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ |
michael@0 | 506 | /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ |
michael@0 | 507 | /* */ |
michael@0 | 508 | /* ... */ |
michael@0 | 509 | /* */ |
michael@0 | 510 | /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ |
michael@0 | 511 | /* { */ |
michael@0 | 512 | /* FT_Glyph bitmap = glyphs[idx]; */ |
michael@0 | 513 | /* */ |
michael@0 | 514 | /* */ |
michael@0 | 515 | /* ... */ |
michael@0 | 516 | /* */ |
michael@0 | 517 | /* // after this call, `bitmap' no longer points into */ |
michael@0 | 518 | /* // the `glyphs' array (and the old value isn't destroyed) */ |
michael@0 | 519 | /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ |
michael@0 | 520 | /* */ |
michael@0 | 521 | /* ... */ |
michael@0 | 522 | /* */ |
michael@0 | 523 | /* FT_Done_Glyph( bitmap ); */ |
michael@0 | 524 | /* } */ |
michael@0 | 525 | /* */ |
michael@0 | 526 | /* ... */ |
michael@0 | 527 | /* */ |
michael@0 | 528 | /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ |
michael@0 | 529 | /* FT_Done_Glyph( glyphs[idx] ); */ |
michael@0 | 530 | /* } */ |
michael@0 | 531 | /* */ |
michael@0 | 532 | FT_EXPORT( FT_Error ) |
michael@0 | 533 | FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, |
michael@0 | 534 | FT_Render_Mode render_mode, |
michael@0 | 535 | FT_Vector* origin, |
michael@0 | 536 | FT_Bool destroy ); |
michael@0 | 537 | |
michael@0 | 538 | |
michael@0 | 539 | /*************************************************************************/ |
michael@0 | 540 | /* */ |
michael@0 | 541 | /* <Function> */ |
michael@0 | 542 | /* FT_Done_Glyph */ |
michael@0 | 543 | /* */ |
michael@0 | 544 | /* <Description> */ |
michael@0 | 545 | /* Destroy a given glyph. */ |
michael@0 | 546 | /* */ |
michael@0 | 547 | /* <Input> */ |
michael@0 | 548 | /* glyph :: A handle to the target glyph object. */ |
michael@0 | 549 | /* */ |
michael@0 | 550 | FT_EXPORT( void ) |
michael@0 | 551 | FT_Done_Glyph( FT_Glyph glyph ); |
michael@0 | 552 | |
michael@0 | 553 | /* */ |
michael@0 | 554 | |
michael@0 | 555 | |
michael@0 | 556 | /* other helpful functions */ |
michael@0 | 557 | |
michael@0 | 558 | /*************************************************************************/ |
michael@0 | 559 | /* */ |
michael@0 | 560 | /* <Section> */ |
michael@0 | 561 | /* computations */ |
michael@0 | 562 | /* */ |
michael@0 | 563 | /*************************************************************************/ |
michael@0 | 564 | |
michael@0 | 565 | |
michael@0 | 566 | /*************************************************************************/ |
michael@0 | 567 | /* */ |
michael@0 | 568 | /* <Function> */ |
michael@0 | 569 | /* FT_Matrix_Multiply */ |
michael@0 | 570 | /* */ |
michael@0 | 571 | /* <Description> */ |
michael@0 | 572 | /* Perform the matrix operation `b = a*b'. */ |
michael@0 | 573 | /* */ |
michael@0 | 574 | /* <Input> */ |
michael@0 | 575 | /* a :: A pointer to matrix `a'. */ |
michael@0 | 576 | /* */ |
michael@0 | 577 | /* <InOut> */ |
michael@0 | 578 | /* b :: A pointer to matrix `b'. */ |
michael@0 | 579 | /* */ |
michael@0 | 580 | /* <Note> */ |
michael@0 | 581 | /* The result is undefined if either `a' or `b' is zero. */ |
michael@0 | 582 | /* */ |
michael@0 | 583 | FT_EXPORT( void ) |
michael@0 | 584 | FT_Matrix_Multiply( const FT_Matrix* a, |
michael@0 | 585 | FT_Matrix* b ); |
michael@0 | 586 | |
michael@0 | 587 | |
michael@0 | 588 | /*************************************************************************/ |
michael@0 | 589 | /* */ |
michael@0 | 590 | /* <Function> */ |
michael@0 | 591 | /* FT_Matrix_Invert */ |
michael@0 | 592 | /* */ |
michael@0 | 593 | /* <Description> */ |
michael@0 | 594 | /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ |
michael@0 | 595 | /* */ |
michael@0 | 596 | /* <InOut> */ |
michael@0 | 597 | /* matrix :: A pointer to the target matrix. Remains untouched in */ |
michael@0 | 598 | /* case of error. */ |
michael@0 | 599 | /* */ |
michael@0 | 600 | /* <Return> */ |
michael@0 | 601 | /* FreeType error code. 0~means success. */ |
michael@0 | 602 | /* */ |
michael@0 | 603 | FT_EXPORT( FT_Error ) |
michael@0 | 604 | FT_Matrix_Invert( FT_Matrix* matrix ); |
michael@0 | 605 | |
michael@0 | 606 | |
michael@0 | 607 | /* */ |
michael@0 | 608 | |
michael@0 | 609 | |
michael@0 | 610 | FT_END_HEADER |
michael@0 | 611 | |
michael@0 | 612 | #endif /* __FTGLYPH_H__ */ |
michael@0 | 613 | |
michael@0 | 614 | |
michael@0 | 615 | /* END */ |
michael@0 | 616 | |
michael@0 | 617 | |
michael@0 | 618 | /* Local Variables: */ |
michael@0 | 619 | /* coding: utf-8 */ |
michael@0 | 620 | /* End: */ |