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 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 Bezier 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 sucess. */
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_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 Bezier 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 Bezier 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. */
318 /* outline :: A handle to the target outline. */
321 /* strength :: How strong the glyph is emboldened. Expressed in */
322 /* 26.6 pixel format. */
325 /* FreeType error code. 0 means success. */
327 FT_EXPORT_DEF( FT_Error )
328 FT_Outline_Embolden( FT_Outline* outline,
332 /*************************************************************************/
335 /* FT_Outline_Reverse */
338 /* Reverses the drawing direction of an outline. This is used to */
339 /* ensure consistent fill conventions for mirrored glyphs. */
342 /* outline :: A pointer to the target outline descriptor. */
345 /* This functions toggles the bit flag `FT_OUTLINE_REVERSE_FILL' in */
346 /* the outline's `flags' field. */
348 /* It shouldn't be used by a normal client application, unless it */
349 /* knows what it is doing. */
352 FT_Outline_Reverse( FT_Outline* outline );
355 /*************************************************************************/
358 /* FT_Outline_Get_Bitmap */
361 /* Renders an outline within a bitmap. The outline's image is simply */
362 /* OR-ed to the target bitmap. */
365 /* library :: A handle to a FreeType library object. */
367 /* outline :: A pointer to the source outline descriptor. */
370 /* abitmap :: A pointer to the target bitmap descriptor. */
373 /* FreeType error code. 0 means success. */
376 /* This function does NOT CREATE the bitmap, it only renders an */
377 /* outline image within the one you pass to it! */
379 /* It will use the raster correponding to the default glyph format. */
381 FT_EXPORT( FT_Error )
382 FT_Outline_Get_Bitmap( FT_Library library,
384 const FT_Bitmap *abitmap );
387 /*************************************************************************/
390 /* FT_Outline_Render */
393 /* Renders an outline within a bitmap using the current scan-convert. */
394 /* This functions uses an FT_Raster_Params structure as an argument, */
395 /* allowing advanced features like direct composition, translucency, */
399 /* library :: A handle to a FreeType library object. */
401 /* outline :: A pointer to the source outline descriptor. */
404 /* params :: A pointer to a FT_Raster_Params structure used to */
405 /* describe the rendering operation. */
408 /* FreeType error code. 0 means success. */
411 /* You should know what you are doing and how FT_Raster_Params works */
412 /* to use this function. */
414 /* The field `params.source' will be set to `outline' before the scan */
415 /* converter is called, which means that the value you give to it is */
416 /* actually ignored. */
418 FT_EXPORT( FT_Error )
419 FT_Outline_Render( FT_Library library,
421 FT_Raster_Params* params );
424 /**************************************************************************
430 * A list of values used to describe an outline's contour orientation.
432 * The TrueType and Postscript specifications use different conventions
433 * to determine whether outline contours should be filled or unfilled.
436 * FT_ORIENTATION_TRUETYPE ::
437 * According to the TrueType specification, clockwise contours must
438 * be filled, and counter-clockwise ones must be unfilled.
440 * FT_ORIENTATION_POSTSCRIPT ::
441 * According to the Postscript specification, counter-clockwise contours
442 * must be filled, and clockwise ones must be unfilled.
444 * FT_ORIENTATION_FILL_RIGHT ::
445 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
446 * remember that in TrueType, everything that is to the right of
447 * the drawing direction of a contour must be filled.
449 * FT_ORIENTATION_FILL_LEFT ::
450 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
451 * remember that in Postscript, everything that is to the left of
452 * the drawing direction of a contour must be filled.
456 FT_ORIENTATION_TRUETYPE = 0,
457 FT_ORIENTATION_POSTSCRIPT = 1,
458 FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
459 FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT
464 /**************************************************************************
467 * FT_Outline_Get_Orientation
470 * This function analyzes a glyph outline and tries to compute its
471 * fill orientation (see @FT_Orientation). This is done by computing
472 * the direction of each global horizontal and/or vertical extrema
473 * within the outline.
475 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
480 * A handle to the source outline.
486 FT_EXPORT( FT_Orientation )
487 FT_Outline_Get_Orientation( FT_Outline* outline );
495 #endif /* __FTOUTLN_H__ */