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-2012 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_EmboldenXY */
63 /* FT_Outline_Reverse */
64 /* FT_Outline_Check */
66 /* FT_Outline_Get_CBox */
67 /* FT_Outline_Get_BBox */
69 /* FT_Outline_Get_Bitmap */
70 /* FT_Outline_Render */
72 /* FT_Outline_Decompose */
73 /* FT_Outline_Funcs */
74 /* FT_Outline_MoveTo_Func */
75 /* FT_Outline_LineTo_Func */
76 /* FT_Outline_ConicTo_Func */
77 /* FT_Outline_CubicTo_Func */
79 /*************************************************************************/
82 /*************************************************************************/
85 /* FT_Outline_Decompose */
88 /* Walk over an outline's structure to decompose it into individual */
89 /* segments and Bézier arcs. This function also emits `move to' */
90 /* operations to indicate the start 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 /* Create 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 maximum number of points within the outline. */
130 /* numContours :: The maximum number of contours within the outline. */
133 /* anoutline :: A handle to the new outline. */
136 /* FreeType error code. 0~means success. */
139 /* The reason why this function takes a `library' parameter is simply */
140 /* to use the library's memory allocator. */
142 FT_EXPORT( FT_Error
)
143 FT_Outline_New( FT_Library library
,
146 FT_Outline
*anoutline
);
149 FT_EXPORT( FT_Error
)
150 FT_Outline_New_Internal( FT_Memory memory
,
153 FT_Outline
*anoutline
);
156 /*************************************************************************/
159 /* FT_Outline_Done */
162 /* Destroy an outline created with @FT_Outline_New. */
165 /* library :: A handle of the library object used to allocate the */
168 /* outline :: A pointer to the outline object to be discarded. */
171 /* FreeType error code. 0~means success. */
174 /* If the outline's `owner' field is not set, only the outline */
175 /* descriptor will be released. */
177 /* The reason why this function takes an `library' parameter is */
178 /* simply to use ft_mem_free(). */
180 FT_EXPORT( FT_Error
)
181 FT_Outline_Done( FT_Library library
,
182 FT_Outline
* outline
);
185 FT_EXPORT( FT_Error
)
186 FT_Outline_Done_Internal( FT_Memory memory
,
187 FT_Outline
* outline
);
190 /*************************************************************************/
193 /* FT_Outline_Check */
196 /* Check the contents of an outline descriptor. */
199 /* outline :: A handle to a source outline. */
202 /* FreeType error code. 0~means success. */
204 FT_EXPORT( FT_Error
)
205 FT_Outline_Check( FT_Outline
* outline
);
208 /*************************************************************************/
211 /* FT_Outline_Get_CBox */
214 /* Return an outline's `control box'. The control box encloses all */
215 /* the outline's points, including Bézier control points. Though it */
216 /* coincides with the exact bounding box for most glyphs, it can be */
217 /* slightly larger in some situations (like when rotating an outline */
218 /* which contains Bézier outside arcs). */
220 /* Computing the control box is very fast, while getting the bounding */
221 /* box can take much more time as it needs to walk over all segments */
222 /* and arcs in the outline. To get the latter, you can use the */
223 /* `ftbbox' component which is dedicated to this single task. */
226 /* outline :: A pointer to the source outline descriptor. */
229 /* acbox :: The outline's control box. */
232 /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
235 FT_Outline_Get_CBox( const FT_Outline
* outline
,
239 /*************************************************************************/
242 /* FT_Outline_Translate */
245 /* Apply a simple translation to the points of an outline. */
248 /* outline :: A pointer to the target outline descriptor. */
251 /* xOffset :: The horizontal offset. */
253 /* yOffset :: The vertical offset. */
256 FT_Outline_Translate( const FT_Outline
* outline
,
261 /*************************************************************************/
264 /* FT_Outline_Copy */
267 /* Copy an outline into another one. Both objects must have the */
268 /* same sizes (number of points & number of contours) when this */
269 /* function is called. */
272 /* source :: A handle to the source outline. */
275 /* target :: A handle to the target outline. */
278 /* FreeType error code. 0~means success. */
280 FT_EXPORT( FT_Error
)
281 FT_Outline_Copy( const FT_Outline
* source
,
282 FT_Outline
*target
);
285 /*************************************************************************/
288 /* FT_Outline_Transform */
291 /* Apply a simple 2x2 matrix to all of an outline's points. Useful */
292 /* for applying rotations, slanting, flipping, etc. */
295 /* outline :: A pointer to the target outline descriptor. */
298 /* matrix :: A pointer to the transformation matrix. */
301 /* You can use @FT_Outline_Translate if you need to translate the */
302 /* outline's points. */
305 FT_Outline_Transform( const FT_Outline
* outline
,
306 const FT_Matrix
* matrix
);
309 /*************************************************************************/
312 /* FT_Outline_Embolden */
315 /* Embolden an outline. The new outline will be at most 4~times */
316 /* `strength' pixels wider and higher. You may think of the left and */
317 /* bottom borders as unchanged. */
319 /* Negative `strength' values to reduce the outline thickness are */
323 /* outline :: A handle to the target outline. */
326 /* strength :: How strong the glyph is emboldened. Expressed in */
327 /* 26.6 pixel format. */
330 /* FreeType error code. 0~means success. */
333 /* The used algorithm to increase or decrease the thickness of the */
334 /* glyph doesn't change the number of points; this means that certain */
335 /* situations like acute angles or intersections are sometimes */
336 /* handled incorrectly. */
338 /* If you need `better' metrics values you should call */
339 /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */
344 /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
345 /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */
346 /* FT_Outline_Embolden( &face->slot->outline, strength ); */
349 FT_EXPORT( FT_Error
)
350 FT_Outline_Embolden( FT_Outline
* outline
,
354 /*************************************************************************/
357 /* FT_Outline_EmboldenXY */
360 /* Embolden an outline. The new outline will be `xstrength' pixels */
361 /* wider and `ystrength' pixels higher. Otherwise, it is similar to */
362 /* @FT_Outline_Embolden, which uses the same strength in both */
365 FT_EXPORT( FT_Error
)
366 FT_Outline_EmboldenXY( FT_Outline
* outline
,
371 /*************************************************************************/
374 /* FT_Outline_Reverse */
377 /* Reverse the drawing direction of an outline. This is used to */
378 /* ensure consistent fill conventions for mirrored glyphs. */
381 /* outline :: A pointer to the target outline descriptor. */
384 /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
385 /* the outline's `flags' field. */
387 /* It shouldn't be used by a normal client application, unless it */
388 /* knows what it is doing. */
391 FT_Outline_Reverse( FT_Outline
* outline
);
394 /*************************************************************************/
397 /* FT_Outline_Get_Bitmap */
400 /* Render an outline within a bitmap. The outline's image is simply */
401 /* OR-ed to the target bitmap. */
404 /* library :: A handle to a FreeType library object. */
406 /* outline :: A pointer to the source outline descriptor. */
409 /* abitmap :: A pointer to the target bitmap descriptor. */
412 /* FreeType error code. 0~means success. */
415 /* This function does NOT CREATE the bitmap, it only renders an */
416 /* outline image within the one you pass to it! Consequently, the */
417 /* various fields in `abitmap' should be set accordingly. */
419 /* It will use the raster corresponding to the default glyph format. */
421 /* The value of the `num_grays' field in `abitmap' is ignored. If */
422 /* you select the gray-level rasterizer, and you want less than 256 */
423 /* gray levels, you have to use @FT_Outline_Render directly. */
425 FT_EXPORT( FT_Error
)
426 FT_Outline_Get_Bitmap( FT_Library library
,
428 const FT_Bitmap
*abitmap
);
431 /*************************************************************************/
434 /* FT_Outline_Render */
437 /* Render an outline within a bitmap using the current scan-convert. */
438 /* This function uses an @FT_Raster_Params structure as an argument, */
439 /* allowing advanced features like direct composition, translucency, */
443 /* library :: A handle to a FreeType library object. */
445 /* outline :: A pointer to the source outline descriptor. */
448 /* params :: A pointer to an @FT_Raster_Params structure used to */
449 /* describe the rendering operation. */
452 /* FreeType error code. 0~means success. */
455 /* You should know what you are doing and how @FT_Raster_Params works */
456 /* to use this function. */
458 /* The field `params.source' will be set to `outline' before the scan */
459 /* converter is called, which means that the value you give to it is */
460 /* actually ignored. */
462 /* The gray-level rasterizer always uses 256 gray levels. If you */
463 /* want less gray levels, you have to provide your own span callback. */
464 /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */
465 /* @FT_Raster_Params structure for more details. */
467 FT_EXPORT( FT_Error
)
468 FT_Outline_Render( FT_Library library
,
470 FT_Raster_Params
* params
);
473 /**************************************************************************
479 * A list of values used to describe an outline's contour orientation.
481 * The TrueType and PostScript specifications use different conventions
482 * to determine whether outline contours should be filled or unfilled.
485 * FT_ORIENTATION_TRUETYPE ::
486 * According to the TrueType specification, clockwise contours must
487 * be filled, and counter-clockwise ones must be unfilled.
489 * FT_ORIENTATION_POSTSCRIPT ::
490 * According to the PostScript specification, counter-clockwise contours
491 * must be filled, and clockwise ones must be unfilled.
493 * FT_ORIENTATION_FILL_RIGHT ::
494 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
495 * remember that in TrueType, everything that is to the right of
496 * the drawing direction of a contour must be filled.
498 * FT_ORIENTATION_FILL_LEFT ::
499 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
500 * remember that in PostScript, everything that is to the left of
501 * the drawing direction of a contour must be filled.
503 * FT_ORIENTATION_NONE ::
504 * The orientation cannot be determined. That is, different parts of
505 * the glyph have different orientation.
508 typedef enum FT_Orientation_
510 FT_ORIENTATION_TRUETYPE
= 0,
511 FT_ORIENTATION_POSTSCRIPT
= 1,
512 FT_ORIENTATION_FILL_RIGHT
= FT_ORIENTATION_TRUETYPE
,
513 FT_ORIENTATION_FILL_LEFT
= FT_ORIENTATION_POSTSCRIPT
,
519 /**************************************************************************
522 * FT_Outline_Get_Orientation
525 * This function analyzes a glyph outline and tries to compute its
526 * fill orientation (see @FT_Orientation). This is done by computing
527 * the direction of each global horizontal and/or vertical extrema
528 * within the outline.
530 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
535 * A handle to the source outline.
541 FT_EXPORT( FT_Orientation
)
542 FT_Outline_Get_Orientation( FT_Outline
* outline
);
550 #endif /* __FTOUTLN_H__ */
556 /* Local Variables: */