1 /***************************************************************************/
5 /* Support for the FT_Outline type used to store glyph shapes of */
6 /* most scalable font formats (specification). */
8 /* Copyright 1996-2003, 2005-2011 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 /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
234 FT_Outline_Get_CBox( const FT_Outline* outline,
238 /*************************************************************************/
241 /* FT_Outline_Translate */
244 /* Apply a simple translation to the points of an outline. */
247 /* outline :: A pointer to the target outline descriptor. */
250 /* xOffset :: The horizontal offset. */
252 /* yOffset :: The vertical offset. */
255 FT_Outline_Translate( const FT_Outline* outline,
260 /*************************************************************************/
263 /* FT_Outline_Copy */
266 /* Copy an outline into another one. Both objects must have the */
267 /* same sizes (number of points & number of contours) when this */
268 /* function is called. */
271 /* source :: A handle to the source outline. */
274 /* target :: A handle to the target outline. */
277 /* FreeType error code. 0~means success. */
279 FT_EXPORT( FT_Error )
280 FT_Outline_Copy( const FT_Outline* source,
281 FT_Outline *target );
284 /*************************************************************************/
287 /* FT_Outline_Transform */
290 /* Apply a simple 2x2 matrix to all of an outline's points. Useful */
291 /* for applying rotations, slanting, flipping, etc. */
294 /* outline :: A pointer to the target outline descriptor. */
297 /* matrix :: A pointer to the transformation matrix. */
300 /* You can use @FT_Outline_Translate if you need to translate the */
301 /* outline's points. */
304 FT_Outline_Transform( const FT_Outline* outline,
305 const FT_Matrix* matrix );
308 /*************************************************************************/
311 /* FT_Outline_Embolden */
314 /* Embolden an outline. The new outline will be at most 4~times */
315 /* `strength' pixels wider and higher. You may think of the left and */
316 /* bottom borders as unchanged. */
318 /* Negative `strength' values to reduce the outline thickness are */
322 /* outline :: A handle to the target outline. */
325 /* strength :: How strong the glyph is emboldened. Expressed in */
326 /* 26.6 pixel format. */
329 /* FreeType error code. 0~means success. */
332 /* The used algorithm to increase or decrease the thickness of the */
333 /* glyph doesn't change the number of points; this means that certain */
334 /* situations like acute angles or intersections are sometimes */
335 /* handled incorrectly. */
337 /* If you need `better' metrics values you should call */
338 /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */
343 /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
344 /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */
345 /* FT_Outline_Embolden( &face->slot->outline, strength ); */
348 FT_EXPORT( FT_Error )
349 FT_Outline_Embolden( FT_Outline* outline,
353 /*************************************************************************/
356 /* FT_Outline_Reverse */
359 /* Reverse the drawing direction of an outline. This is used to */
360 /* ensure consistent fill conventions for mirrored glyphs. */
363 /* outline :: A pointer to the target outline descriptor. */
366 /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
367 /* the outline's `flags' field. */
369 /* It shouldn't be used by a normal client application, unless it */
370 /* knows what it is doing. */
373 FT_Outline_Reverse( FT_Outline* outline );
376 /*************************************************************************/
379 /* FT_Outline_Get_Bitmap */
382 /* Render an outline within a bitmap. The outline's image is simply */
383 /* OR-ed to the target bitmap. */
386 /* library :: A handle to a FreeType library object. */
388 /* outline :: A pointer to the source outline descriptor. */
391 /* abitmap :: A pointer to the target bitmap descriptor. */
394 /* FreeType error code. 0~means success. */
397 /* This function does NOT CREATE the bitmap, it only renders an */
398 /* outline image within the one you pass to it! Consequently, the */
399 /* various fields in `abitmap' should be set accordingly. */
401 /* It will use the raster corresponding to the default glyph format. */
403 /* The value of the `num_grays' field in `abitmap' is ignored. If */
404 /* you select the gray-level rasterizer, and you want less than 256 */
405 /* gray levels, you have to use @FT_Outline_Render directly. */
407 FT_EXPORT( FT_Error )
408 FT_Outline_Get_Bitmap( FT_Library library,
410 const FT_Bitmap *abitmap );
413 /*************************************************************************/
416 /* FT_Outline_Render */
419 /* Render an outline within a bitmap using the current scan-convert. */
420 /* This function uses an @FT_Raster_Params structure as an argument, */
421 /* allowing advanced features like direct composition, translucency, */
425 /* library :: A handle to a FreeType library object. */
427 /* outline :: A pointer to the source outline descriptor. */
430 /* params :: A pointer to an @FT_Raster_Params structure used to */
431 /* describe the rendering operation. */
434 /* FreeType error code. 0~means success. */
437 /* You should know what you are doing and how @FT_Raster_Params works */
438 /* to use this function. */
440 /* The field `params.source' will be set to `outline' before the scan */
441 /* converter is called, which means that the value you give to it is */
442 /* actually ignored. */
444 /* The gray-level rasterizer always uses 256 gray levels. If you */
445 /* want less gray levels, you have to provide your own span callback. */
446 /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */
447 /* @FT_Raster_Params structure for more details. */
449 FT_EXPORT( FT_Error )
450 FT_Outline_Render( FT_Library library,
452 FT_Raster_Params* params );
455 /**************************************************************************
461 * A list of values used to describe an outline's contour orientation.
463 * The TrueType and PostScript specifications use different conventions
464 * to determine whether outline contours should be filled or unfilled.
467 * FT_ORIENTATION_TRUETYPE ::
468 * According to the TrueType specification, clockwise contours must
469 * be filled, and counter-clockwise ones must be unfilled.
471 * FT_ORIENTATION_POSTSCRIPT ::
472 * According to the PostScript specification, counter-clockwise contours
473 * must be filled, and clockwise ones must be unfilled.
475 * FT_ORIENTATION_FILL_RIGHT ::
476 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
477 * remember that in TrueType, everything that is to the right of
478 * the drawing direction of a contour must be filled.
480 * FT_ORIENTATION_FILL_LEFT ::
481 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
482 * remember that in PostScript, everything that is to the left of
483 * the drawing direction of a contour must be filled.
485 * FT_ORIENTATION_NONE ::
486 * The orientation cannot be determined. That is, different parts of
487 * the glyph have different orientation.
490 typedef enum FT_Orientation_
492 FT_ORIENTATION_TRUETYPE = 0,
493 FT_ORIENTATION_POSTSCRIPT = 1,
494 FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
495 FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
501 /**************************************************************************
504 * FT_Outline_Get_Orientation
507 * This function analyzes a glyph outline and tries to compute its
508 * fill orientation (see @FT_Orientation). This is done by computing
509 * the direction of each global horizontal and/or vertical extrema
510 * within the outline.
512 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
517 * A handle to the source outline.
523 FT_EXPORT( FT_Orientation )
524 FT_Outline_Get_Orientation( FT_Outline* outline );
532 #endif /* __FTOUTLN_H__ */
538 /* Local Variables: */