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 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 /* Walks over an outline's structure to decompose it into individual */
88 /* segments and Bézier arcs. This function is also able to emit */
89 /* `move to' and `close to' operations to indicate the start and end */
90 /* of new contours in the outline. */
93 /* outline :: A pointer to the source target. */
95 /* func_interface :: A table of `emitters', i.e,. function pointers */
96 /* called during decomposition to indicate path */
100 /* user :: A typeless pointer which is passed to each */
101 /* emitter during the decomposition. It can be */
102 /* used to store the state during the */
106 /* FreeType error code. 0 means success. */
108 FT_EXPORT( FT_Error
)
109 FT_Outline_Decompose( FT_Outline
* outline
,
110 const FT_Outline_Funcs
* func_interface
,
114 /*************************************************************************/
120 /* Creates a new outline of a given size. */
123 /* library :: A handle to the library object from where the */
124 /* outline is allocated. Note however that the new */
125 /* outline will *not* necessarily be *freed*, when */
126 /* destroying the library, by @FT_Done_FreeType. */
128 /* numPoints :: The maximal number of points within the outline. */
130 /* numContours :: The maximal number of contours within the outline. */
133 /* anoutline :: A handle to the new outline. NULL in case of */
137 /* FreeType error code. 0 means success. */
140 /* The reason why this function takes a `library' parameter is simply */
141 /* to use the library's memory allocator. */
143 FT_EXPORT( FT_Error
)
144 FT_Outline_New( FT_Library library
,
147 FT_Outline
*anoutline
);
150 FT_EXPORT( FT_Error
)
151 FT_Outline_New_Internal( FT_Memory memory
,
154 FT_Outline
*anoutline
);
157 /*************************************************************************/
160 /* FT_Outline_Done */
163 /* Destroys an outline created with @FT_Outline_New. */
166 /* library :: A handle of the library object used to allocate the */
169 /* outline :: A pointer to the outline object to be discarded. */
172 /* FreeType error code. 0 means success. */
175 /* If the outline's `owner' field is not set, only the outline */
176 /* descriptor will be released. */
178 /* The reason why this function takes an `library' parameter is */
179 /* simply to use ft_mem_free(). */
181 FT_EXPORT( FT_Error
)
182 FT_Outline_Done( FT_Library library
,
183 FT_Outline
* outline
);
186 FT_EXPORT( FT_Error
)
187 FT_Outline_Done_Internal( FT_Memory memory
,
188 FT_Outline
* outline
);
191 /*************************************************************************/
194 /* FT_Outline_Check */
197 /* Check the contents of an outline descriptor. */
200 /* outline :: A handle to a source outline. */
203 /* FreeType error code. 0 means success. */
205 FT_EXPORT( FT_Error
)
206 FT_Outline_Check( FT_Outline
* outline
);
209 /*************************************************************************/
212 /* FT_Outline_Get_CBox */
215 /* Returns an outline's `control box'. The control box encloses all */
216 /* the outline's points, including Bézier control points. Though it */
217 /* coincides with the exact bounding box for most glyphs, it can be */
218 /* slightly larger in some situations (like when rotating an outline */
219 /* which contains Bézier outside arcs). */
221 /* Computing the control box is very fast, while getting the bounding */
222 /* box can take much more time as it needs to walk over all segments */
223 /* and arcs in the outline. To get the latter, you can use the */
224 /* `ftbbox' component which is dedicated to this single task. */
227 /* outline :: A pointer to the source outline descriptor. */
230 /* acbox :: The outline's control box. */
233 FT_Outline_Get_CBox( const FT_Outline
* outline
,
237 /*************************************************************************/
240 /* FT_Outline_Translate */
243 /* Applies a simple translation to the points of an outline. */
246 /* outline :: A pointer to the target outline descriptor. */
249 /* xOffset :: The horizontal offset. */
251 /* yOffset :: The vertical offset. */
254 FT_Outline_Translate( const FT_Outline
* outline
,
259 /*************************************************************************/
262 /* FT_Outline_Copy */
265 /* Copies an outline into another one. Both objects must have the */
266 /* same sizes (number of points & number of contours) when this */
267 /* function is called. */
270 /* source :: A handle to the source outline. */
273 /* target :: A handle to the target outline. */
276 /* FreeType error code. 0 means success. */
278 FT_EXPORT( FT_Error
)
279 FT_Outline_Copy( const FT_Outline
* source
,
280 FT_Outline
*target
);
283 /*************************************************************************/
286 /* FT_Outline_Transform */
289 /* Applies a simple 2x2 matrix to all of an outline's points. Useful */
290 /* for applying rotations, slanting, flipping, etc. */
293 /* outline :: A pointer to the target outline descriptor. */
296 /* matrix :: A pointer to the transformation matrix. */
299 /* You can use @FT_Outline_Translate if you need to translate the */
300 /* outline's points. */
303 FT_Outline_Transform( const FT_Outline
* outline
,
304 const FT_Matrix
* matrix
);
307 /*************************************************************************/
310 /* FT_Outline_Embolden */
313 /* Emboldens an outline. The new outline will be at most 4 times */
314 /* `strength' pixels wider and higher. You may think of the left and */
315 /* bottom borders as unchanged. */
317 /* Negative `strength' values to reduce the outline thickness are */
321 /* outline :: A handle to the target outline. */
324 /* strength :: How strong the glyph is emboldened. Expressed in */
325 /* 26.6 pixel format. */
328 /* FreeType error code. 0 means success. */
331 /* The used algorithm to increase or decrease the thickness of the */
332 /* glyph doesn't change the number of points; this means that certain */
333 /* situations like acute angles or intersections are sometimes */
334 /* handled incorrectly. */
339 /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
340 /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */
341 /* FT_Outline_Embolden( &face->slot->outline, strength ); */
344 FT_EXPORT( FT_Error
)
345 FT_Outline_Embolden( FT_Outline
* outline
,
349 /*************************************************************************/
352 /* FT_Outline_Reverse */
355 /* Reverses the drawing direction of an outline. This is used to */
356 /* ensure consistent fill conventions for mirrored glyphs. */
359 /* outline :: A pointer to the target outline descriptor. */
362 /* This functions toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
363 /* the outline's `flags' field. */
365 /* It shouldn't be used by a normal client application, unless it */
366 /* knows what it is doing. */
369 FT_Outline_Reverse( FT_Outline
* outline
);
372 /*************************************************************************/
375 /* FT_Outline_Get_Bitmap */
378 /* Renders an outline within a bitmap. The outline's image is simply */
379 /* OR-ed to the target bitmap. */
382 /* library :: A handle to a FreeType library object. */
384 /* outline :: A pointer to the source outline descriptor. */
387 /* abitmap :: A pointer to the target bitmap descriptor. */
390 /* FreeType error code. 0 means success. */
393 /* This function does NOT CREATE the bitmap, it only renders an */
394 /* outline image within the one you pass to it! */
396 /* It will use the raster corresponding to the default glyph format. */
398 FT_EXPORT( FT_Error
)
399 FT_Outline_Get_Bitmap( FT_Library library
,
401 const FT_Bitmap
*abitmap
);
404 /*************************************************************************/
407 /* FT_Outline_Render */
410 /* Renders an outline within a bitmap using the current scan-convert. */
411 /* This functions uses an @FT_Raster_Params structure as an argument, */
412 /* allowing advanced features like direct composition, translucency, */
416 /* library :: A handle to a FreeType library object. */
418 /* outline :: A pointer to the source outline descriptor. */
421 /* params :: A pointer to an @FT_Raster_Params structure used to */
422 /* describe the rendering operation. */
425 /* FreeType error code. 0 means success. */
428 /* You should know what you are doing and how @FT_Raster_Params works */
429 /* to use this function. */
431 /* The field `params.source' will be set to `outline' before the scan */
432 /* converter is called, which means that the value you give to it is */
433 /* actually ignored. */
435 FT_EXPORT( FT_Error
)
436 FT_Outline_Render( FT_Library library
,
438 FT_Raster_Params
* params
);
441 /**************************************************************************
447 * A list of values used to describe an outline's contour orientation.
449 * The TrueType and Postscript specifications use different conventions
450 * to determine whether outline contours should be filled or unfilled.
453 * FT_ORIENTATION_TRUETYPE ::
454 * According to the TrueType specification, clockwise contours must
455 * be filled, and counter-clockwise ones must be unfilled.
457 * FT_ORIENTATION_POSTSCRIPT ::
458 * According to the Postscript specification, counter-clockwise contours
459 * must be filled, and clockwise ones must be unfilled.
461 * FT_ORIENTATION_FILL_RIGHT ::
462 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
463 * remember that in TrueType, everything that is to the right of
464 * the drawing direction of a contour must be filled.
466 * FT_ORIENTATION_FILL_LEFT ::
467 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
468 * remember that in Postscript, everything that is to the left of
469 * the drawing direction of a contour must be filled.
471 * FT_ORIENTATION_NONE ::
472 * The orientation cannot be determined. That is, different parts of
473 * the glyph have different orientation.
478 FT_ORIENTATION_TRUETYPE
= 0,
479 FT_ORIENTATION_POSTSCRIPT
= 1,
480 FT_ORIENTATION_FILL_RIGHT
= FT_ORIENTATION_TRUETYPE
,
481 FT_ORIENTATION_FILL_LEFT
= FT_ORIENTATION_POSTSCRIPT
,
487 /**************************************************************************
490 * FT_Outline_Get_Orientation
493 * This function analyzes a glyph outline and tries to compute its
494 * fill orientation (see @FT_Orientation). This is done by computing
495 * the direction of each global horizontal and/or vertical extrema
496 * within the outline.
498 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
503 * A handle to the source outline.
509 FT_EXPORT( FT_Orientation
)
510 FT_Outline_Get_Orientation( FT_Outline
* outline
);
518 #endif /* __FTOUTLN_H__ */
524 /* Local Variables: */