1 /***************************************************************************/
5 /* Support for the FT_Outline type used to store glyph shapes of */
6 /* most scalable font formats (specification). */
8 /* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
11 /* This file is part of the FreeType project, and may only be used, */
12 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */
17 /***************************************************************************/
25 #include FT_FREETYPE_H
28 #error "freetype.h of FreeType 1 has been loaded!"
29 #error "Please fix the directory search order for header files"
30 #error "so that freetype.h of FreeType 2 is found first."
37 /*************************************************************************/
40 /* outline_processing */
43 /* Outline Processing */
46 /* Functions to create, transform, and render vectorial glyph images. */
49 /* This section contains routines used to create and destroy scalable */
50 /* glyph images known as `outlines'. These can also be measured, */
51 /* transformed, and converted into bitmaps and pixmaps. */
55 /* FT_OUTLINE_FLAGS */
59 /* FT_Outline_Translate */
60 /* FT_Outline_Transform */
61 /* FT_Outline_Embolden */
62 /* FT_Outline_Reverse */
63 /* FT_Outline_Check */
65 /* FT_Outline_Get_CBox */
66 /* FT_Outline_Get_BBox */
68 /* FT_Outline_Get_Bitmap */
69 /* FT_Outline_Render */
71 /* FT_Outline_Decompose */
72 /* FT_Outline_Funcs */
73 /* FT_Outline_MoveTo_Func */
74 /* FT_Outline_LineTo_Func */
75 /* FT_Outline_ConicTo_Func */
76 /* FT_Outline_CubicTo_Func */
78 /*************************************************************************/
81 /*************************************************************************/
84 /* FT_Outline_Decompose */
87 /* Walk over an outline's structure to decompose it into individual */
88 /* segments and Bézier arcs. This function also emits `move to' */
89 /* operations to indicate the start of new contours in the outline. */
92 /* outline :: A pointer to the source target. */
94 /* func_interface :: A table of `emitters', i.e., function pointers */
95 /* called during decomposition to indicate path */
99 /* user :: A typeless pointer which is passed to each */
100 /* emitter during the decomposition. It can be */
101 /* used to store the state during the */
105 /* FreeType error code. 0~means success. */
107 FT_EXPORT( FT_Error
)
108 FT_Outline_Decompose( FT_Outline
* outline
,
109 const FT_Outline_Funcs
* func_interface
,
113 /*************************************************************************/
119 /* Create a new outline of a given size. */
122 /* library :: A handle to the library object from where the */
123 /* outline is allocated. Note however that the new */
124 /* outline will *not* necessarily be *freed*, when */
125 /* destroying the library, by @FT_Done_FreeType. */
127 /* numPoints :: The maximal number of points within the outline. */
129 /* numContours :: The maximal number of contours within the outline. */
132 /* anoutline :: A handle to the new outline. */
135 /* FreeType error code. 0~means success. */
138 /* The reason why this function takes a `library' parameter is simply */
139 /* to use the library's memory allocator. */
141 FT_EXPORT( FT_Error
)
142 FT_Outline_New( FT_Library library
,
145 FT_Outline
*anoutline
);
148 FT_EXPORT( FT_Error
)
149 FT_Outline_New_Internal( FT_Memory memory
,
152 FT_Outline
*anoutline
);
155 /*************************************************************************/
158 /* FT_Outline_Done */
161 /* Destroy an outline created with @FT_Outline_New. */
164 /* library :: A handle of the library object used to allocate the */
167 /* outline :: A pointer to the outline object to be discarded. */
170 /* FreeType error code. 0~means success. */
173 /* If the outline's `owner' field is not set, only the outline */
174 /* descriptor will be released. */
176 /* The reason why this function takes an `library' parameter is */
177 /* simply to use ft_mem_free(). */
179 FT_EXPORT( FT_Error
)
180 FT_Outline_Done( FT_Library library
,
181 FT_Outline
* outline
);
184 FT_EXPORT( FT_Error
)
185 FT_Outline_Done_Internal( FT_Memory memory
,
186 FT_Outline
* outline
);
189 /*************************************************************************/
192 /* FT_Outline_Check */
195 /* Check the contents of an outline descriptor. */
198 /* outline :: A handle to a source outline. */
201 /* FreeType error code. 0~means success. */
203 FT_EXPORT( FT_Error
)
204 FT_Outline_Check( FT_Outline
* outline
);
207 /*************************************************************************/
210 /* FT_Outline_Get_CBox */
213 /* Return an outline's `control box'. The control box encloses all */
214 /* the outline's points, including Bézier control points. Though it */
215 /* coincides with the exact bounding box for most glyphs, it can be */
216 /* slightly larger in some situations (like when rotating an outline */
217 /* which contains Bézier outside arcs). */
219 /* Computing the control box is very fast, while getting the bounding */
220 /* box can take much more time as it needs to walk over all segments */
221 /* and arcs in the outline. To get the latter, you can use the */
222 /* `ftbbox' component which is dedicated to this single task. */
225 /* outline :: A pointer to the source outline descriptor. */
228 /* acbox :: The outline's control box. */
231 FT_Outline_Get_CBox( const FT_Outline
* outline
,
235 /*************************************************************************/
238 /* FT_Outline_Translate */
241 /* Apply a simple translation to the points of an outline. */
244 /* outline :: A pointer to the target outline descriptor. */
247 /* xOffset :: The horizontal offset. */
249 /* yOffset :: The vertical offset. */
252 FT_Outline_Translate( const FT_Outline
* outline
,
257 /*************************************************************************/
260 /* FT_Outline_Copy */
263 /* Copy an outline into another one. Both objects must have the */
264 /* same sizes (number of points & number of contours) when this */
265 /* function is called. */
268 /* source :: A handle to the source outline. */
271 /* target :: A handle to the target outline. */
274 /* FreeType error code. 0~means success. */
276 FT_EXPORT( FT_Error
)
277 FT_Outline_Copy( const FT_Outline
* source
,
278 FT_Outline
*target
);
281 /*************************************************************************/
284 /* FT_Outline_Transform */
287 /* Apply a simple 2x2 matrix to all of an outline's points. Useful */
288 /* for applying rotations, slanting, flipping, etc. */
291 /* outline :: A pointer to the target outline descriptor. */
294 /* matrix :: A pointer to the transformation matrix. */
297 /* You can use @FT_Outline_Translate if you need to translate the */
298 /* outline's points. */
301 FT_Outline_Transform( const FT_Outline
* outline
,
302 const FT_Matrix
* matrix
);
305 /*************************************************************************/
308 /* FT_Outline_Embolden */
311 /* Embolden an outline. The new outline will be at most 4~times */
312 /* `strength' pixels wider and higher. You may think of the left and */
313 /* bottom borders as unchanged. */
315 /* Negative `strength' values to reduce the outline thickness are */
319 /* outline :: A handle to the target outline. */
322 /* strength :: How strong the glyph is emboldened. Expressed in */
323 /* 26.6 pixel format. */
326 /* FreeType error code. 0~means success. */
329 /* The used algorithm to increase or decrease the thickness of the */
330 /* glyph doesn't change the number of points; this means that certain */
331 /* situations like acute angles or intersections are sometimes */
332 /* handled incorrectly. */
334 /* If you need `better' metrics values you should call */
335 /* @FT_Outline_Get_CBox ot @FT_Outline_Get_BBox. */
340 /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
341 /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */
342 /* FT_Outline_Embolden( &face->slot->outline, strength ); */
345 FT_EXPORT( FT_Error
)
346 FT_Outline_Embolden( FT_Outline
* outline
,
350 /*************************************************************************/
353 /* FT_Outline_Reverse */
356 /* Reverse the drawing direction of an outline. This is used to */
357 /* ensure consistent fill conventions for mirrored glyphs. */
360 /* outline :: A pointer to the target outline descriptor. */
363 /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
364 /* the outline's `flags' field. */
366 /* It shouldn't be used by a normal client application, unless it */
367 /* knows what it is doing. */
370 FT_Outline_Reverse( FT_Outline
* outline
);
373 /*************************************************************************/
376 /* FT_Outline_Get_Bitmap */
379 /* Render an outline within a bitmap. The outline's image is simply */
380 /* OR-ed to the target bitmap. */
383 /* library :: A handle to a FreeType library object. */
385 /* outline :: A pointer to the source outline descriptor. */
388 /* abitmap :: A pointer to the target bitmap descriptor. */
391 /* FreeType error code. 0~means success. */
394 /* This function does NOT CREATE the bitmap, it only renders an */
395 /* outline image within the one you pass to it! Consequently, the */
396 /* various fields in `abitmap' should be set accordingly. */
398 /* It will use the raster corresponding to the default glyph format. */
400 /* The value of the `num_grays' field in `abitmap' is ignored. If */
401 /* you select the gray-level rasterizer, and you want less than 256 */
402 /* gray levels, you have to use @FT_Outline_Render directly. */
404 FT_EXPORT( FT_Error
)
405 FT_Outline_Get_Bitmap( FT_Library library
,
407 const FT_Bitmap
*abitmap
);
410 /*************************************************************************/
413 /* FT_Outline_Render */
416 /* Render an outline within a bitmap using the current scan-convert. */
417 /* This function uses an @FT_Raster_Params structure as an argument, */
418 /* allowing advanced features like direct composition, translucency, */
422 /* library :: A handle to a FreeType library object. */
424 /* outline :: A pointer to the source outline descriptor. */
427 /* params :: A pointer to an @FT_Raster_Params structure used to */
428 /* describe the rendering operation. */
431 /* FreeType error code. 0~means success. */
434 /* You should know what you are doing and how @FT_Raster_Params works */
435 /* to use this function. */
437 /* The field `params.source' will be set to `outline' before the scan */
438 /* converter is called, which means that the value you give to it is */
439 /* actually ignored. */
441 /* The gray-level rasterizer always uses 256 gray levels. If you */
442 /* want less gray levels, you have to provide your own span callback. */
443 /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */
444 /* @FT_Raster_Params structure for more details. */
446 FT_EXPORT( FT_Error
)
447 FT_Outline_Render( FT_Library library
,
449 FT_Raster_Params
* params
);
452 /**************************************************************************
458 * A list of values used to describe an outline's contour orientation.
460 * The TrueType and PostScript specifications use different conventions
461 * to determine whether outline contours should be filled or unfilled.
464 * FT_ORIENTATION_TRUETYPE ::
465 * According to the TrueType specification, clockwise contours must
466 * be filled, and counter-clockwise ones must be unfilled.
468 * FT_ORIENTATION_POSTSCRIPT ::
469 * According to the PostScript specification, counter-clockwise contours
470 * must be filled, and clockwise ones must be unfilled.
472 * FT_ORIENTATION_FILL_RIGHT ::
473 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
474 * remember that in TrueType, everything that is to the right of
475 * the drawing direction of a contour must be filled.
477 * FT_ORIENTATION_FILL_LEFT ::
478 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
479 * remember that in PostScript, everything that is to the left of
480 * the drawing direction of a contour must be filled.
482 * FT_ORIENTATION_NONE ::
483 * The orientation cannot be determined. That is, different parts of
484 * the glyph have different orientation.
487 typedef enum FT_Orientation_
489 FT_ORIENTATION_TRUETYPE
= 0,
490 FT_ORIENTATION_POSTSCRIPT
= 1,
491 FT_ORIENTATION_FILL_RIGHT
= FT_ORIENTATION_TRUETYPE
,
492 FT_ORIENTATION_FILL_LEFT
= FT_ORIENTATION_POSTSCRIPT
,
498 /**************************************************************************
501 * FT_Outline_Get_Orientation
504 * This function analyzes a glyph outline and tries to compute its
505 * fill orientation (see @FT_Orientation). This is done by computing
506 * the direction of each global horizontal and/or vertical extrema
507 * within the outline.
509 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
514 * A handle to the source outline.
520 FT_EXPORT( FT_Orientation
)
521 FT_Outline_Get_Orientation( FT_Outline
* outline
);
529 #endif /* __FTOUTLN_H__ */
535 /* Local Variables: */