Update readme.md
[openttd-joker.git] / lib / shared / include / freetype / ftoutln.h
blobe733f391ea2b49eb2517e7f14d2c18184b7b0d47
1 /***************************************************************************/
2 /* */
3 /* ftoutln.h */
4 /* */
5 /* Support for the FT_Outline type used to store glyph shapes of */
6 /* most scalable font formats (specification). */
7 /* */
8 /* Copyright 1996-2003, 2005-2012 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* */
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. */
16 /* */
17 /***************************************************************************/
20 #ifndef __FTOUTLN_H__
21 #define __FTOUTLN_H__
24 #include <ft2build.h>
25 #include FT_FREETYPE_H
27 #ifdef 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."
31 #endif
34 FT_BEGIN_HEADER
37 /*************************************************************************/
38 /* */
39 /* <Section> */
40 /* outline_processing */
41 /* */
42 /* <Title> */
43 /* Outline Processing */
44 /* */
45 /* <Abstract> */
46 /* Functions to create, transform, and render vectorial glyph images. */
47 /* */
48 /* <Description> */
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. */
52 /* */
53 /* <Order> */
54 /* FT_Outline */
55 /* FT_OUTLINE_FLAGS */
56 /* FT_Outline_New */
57 /* FT_Outline_Done */
58 /* FT_Outline_Copy */
59 /* FT_Outline_Translate */
60 /* FT_Outline_Transform */
61 /* FT_Outline_Embolden */
62 /* FT_Outline_EmboldenXY */
63 /* FT_Outline_Reverse */
64 /* FT_Outline_Check */
65 /* */
66 /* FT_Outline_Get_CBox */
67 /* FT_Outline_Get_BBox */
68 /* */
69 /* FT_Outline_Get_Bitmap */
70 /* FT_Outline_Render */
71 /* */
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 */
78 /* */
79 /*************************************************************************/
82 /*************************************************************************/
83 /* */
84 /* <Function> */
85 /* FT_Outline_Decompose */
86 /* */
87 /* <Description> */
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. */
91 /* */
92 /* <Input> */
93 /* outline :: A pointer to the source target. */
94 /* */
95 /* func_interface :: A table of `emitters', i.e., function pointers */
96 /* called during decomposition to indicate path */
97 /* operations. */
98 /* */
99 /* <InOut> */
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 */
103 /* decomposition. */
104 /* */
105 /* <Return> */
106 /* FreeType error code. 0~means success. */
107 /* */
108 FT_EXPORT( FT_Error )
109 FT_Outline_Decompose( FT_Outline* outline,
110 const FT_Outline_Funcs* func_interface,
111 void* user );
114 /*************************************************************************/
115 /* */
116 /* <Function> */
117 /* FT_Outline_New */
118 /* */
119 /* <Description> */
120 /* Create a new outline of a given size. */
121 /* */
122 /* <Input> */
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. */
127 /* */
128 /* numPoints :: The maximum number of points within the outline. */
129 /* */
130 /* numContours :: The maximum number of contours within the outline. */
131 /* */
132 /* <Output> */
133 /* anoutline :: A handle to the new outline. */
134 /* */
135 /* <Return> */
136 /* FreeType error code. 0~means success. */
137 /* */
138 /* <Note> */
139 /* The reason why this function takes a `library' parameter is simply */
140 /* to use the library's memory allocator. */
141 /* */
142 FT_EXPORT( FT_Error )
143 FT_Outline_New( FT_Library library,
144 FT_UInt numPoints,
145 FT_Int numContours,
146 FT_Outline *anoutline );
149 FT_EXPORT( FT_Error )
150 FT_Outline_New_Internal( FT_Memory memory,
151 FT_UInt numPoints,
152 FT_Int numContours,
153 FT_Outline *anoutline );
156 /*************************************************************************/
157 /* */
158 /* <Function> */
159 /* FT_Outline_Done */
160 /* */
161 /* <Description> */
162 /* Destroy an outline created with @FT_Outline_New. */
163 /* */
164 /* <Input> */
165 /* library :: A handle of the library object used to allocate the */
166 /* outline. */
167 /* */
168 /* outline :: A pointer to the outline object to be discarded. */
169 /* */
170 /* <Return> */
171 /* FreeType error code. 0~means success. */
172 /* */
173 /* <Note> */
174 /* If the outline's `owner' field is not set, only the outline */
175 /* descriptor will be released. */
176 /* */
177 /* The reason why this function takes an `library' parameter is */
178 /* simply to use ft_mem_free(). */
179 /* */
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 /*************************************************************************/
191 /* */
192 /* <Function> */
193 /* FT_Outline_Check */
194 /* */
195 /* <Description> */
196 /* Check the contents of an outline descriptor. */
197 /* */
198 /* <Input> */
199 /* outline :: A handle to a source outline. */
200 /* */
201 /* <Return> */
202 /* FreeType error code. 0~means success. */
203 /* */
204 FT_EXPORT( FT_Error )
205 FT_Outline_Check( FT_Outline* outline );
208 /*************************************************************************/
209 /* */
210 /* <Function> */
211 /* FT_Outline_Get_CBox */
212 /* */
213 /* <Description> */
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). */
219 /* */
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. */
224 /* */
225 /* <Input> */
226 /* outline :: A pointer to the source outline descriptor. */
227 /* */
228 /* <Output> */
229 /* acbox :: The outline's control box. */
230 /* */
231 /* <Note> */
232 /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
233 /* */
234 FT_EXPORT( void )
235 FT_Outline_Get_CBox( const FT_Outline* outline,
236 FT_BBox *acbox );
239 /*************************************************************************/
240 /* */
241 /* <Function> */
242 /* FT_Outline_Translate */
243 /* */
244 /* <Description> */
245 /* Apply a simple translation to the points of an outline. */
246 /* */
247 /* <InOut> */
248 /* outline :: A pointer to the target outline descriptor. */
249 /* */
250 /* <Input> */
251 /* xOffset :: The horizontal offset. */
252 /* */
253 /* yOffset :: The vertical offset. */
254 /* */
255 FT_EXPORT( void )
256 FT_Outline_Translate( const FT_Outline* outline,
257 FT_Pos xOffset,
258 FT_Pos yOffset );
261 /*************************************************************************/
262 /* */
263 /* <Function> */
264 /* FT_Outline_Copy */
265 /* */
266 /* <Description> */
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. */
270 /* */
271 /* <Input> */
272 /* source :: A handle to the source outline. */
273 /* */
274 /* <Output> */
275 /* target :: A handle to the target outline. */
276 /* */
277 /* <Return> */
278 /* FreeType error code. 0~means success. */
279 /* */
280 FT_EXPORT( FT_Error )
281 FT_Outline_Copy( const FT_Outline* source,
282 FT_Outline *target );
285 /*************************************************************************/
286 /* */
287 /* <Function> */
288 /* FT_Outline_Transform */
289 /* */
290 /* <Description> */
291 /* Apply a simple 2x2 matrix to all of an outline's points. Useful */
292 /* for applying rotations, slanting, flipping, etc. */
293 /* */
294 /* <InOut> */
295 /* outline :: A pointer to the target outline descriptor. */
296 /* */
297 /* <Input> */
298 /* matrix :: A pointer to the transformation matrix. */
299 /* */
300 /* <Note> */
301 /* You can use @FT_Outline_Translate if you need to translate the */
302 /* outline's points. */
303 /* */
304 FT_EXPORT( void )
305 FT_Outline_Transform( const FT_Outline* outline,
306 const FT_Matrix* matrix );
309 /*************************************************************************/
310 /* */
311 /* <Function> */
312 /* FT_Outline_Embolden */
313 /* */
314 /* <Description> */
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. */
318 /* */
319 /* Negative `strength' values to reduce the outline thickness are */
320 /* possible also. */
321 /* */
322 /* <InOut> */
323 /* outline :: A handle to the target outline. */
324 /* */
325 /* <Input> */
326 /* strength :: How strong the glyph is emboldened. Expressed in */
327 /* 26.6 pixel format. */
328 /* */
329 /* <Return> */
330 /* FreeType error code. 0~means success. */
331 /* */
332 /* <Note> */
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. */
337 /* */
338 /* If you need `better' metrics values you should call */
339 /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */
340 /* */
341 /* Example call: */
342 /* */
343 /* { */
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 ); */
347 /* } */
348 /* */
349 FT_EXPORT( FT_Error )
350 FT_Outline_Embolden( FT_Outline* outline,
351 FT_Pos strength );
354 /*************************************************************************/
355 /* */
356 /* <Function> */
357 /* FT_Outline_EmboldenXY */
358 /* */
359 /* <Description> */
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 */
363 /* directions. */
364 /* */
365 FT_EXPORT( FT_Error )
366 FT_Outline_EmboldenXY( FT_Outline* outline,
367 FT_Pos xstrength,
368 FT_Pos ystrength );
371 /*************************************************************************/
372 /* */
373 /* <Function> */
374 /* FT_Outline_Reverse */
375 /* */
376 /* <Description> */
377 /* Reverse the drawing direction of an outline. This is used to */
378 /* ensure consistent fill conventions for mirrored glyphs. */
379 /* */
380 /* <InOut> */
381 /* outline :: A pointer to the target outline descriptor. */
382 /* */
383 /* <Note> */
384 /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
385 /* the outline's `flags' field. */
386 /* */
387 /* It shouldn't be used by a normal client application, unless it */
388 /* knows what it is doing. */
389 /* */
390 FT_EXPORT( void )
391 FT_Outline_Reverse( FT_Outline* outline );
394 /*************************************************************************/
395 /* */
396 /* <Function> */
397 /* FT_Outline_Get_Bitmap */
398 /* */
399 /* <Description> */
400 /* Render an outline within a bitmap. The outline's image is simply */
401 /* OR-ed to the target bitmap. */
402 /* */
403 /* <Input> */
404 /* library :: A handle to a FreeType library object. */
405 /* */
406 /* outline :: A pointer to the source outline descriptor. */
407 /* */
408 /* <InOut> */
409 /* abitmap :: A pointer to the target bitmap descriptor. */
410 /* */
411 /* <Return> */
412 /* FreeType error code. 0~means success. */
413 /* */
414 /* <Note> */
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. */
418 /* */
419 /* It will use the raster corresponding to the default glyph format. */
420 /* */
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. */
424 /* */
425 FT_EXPORT( FT_Error )
426 FT_Outline_Get_Bitmap( FT_Library library,
427 FT_Outline* outline,
428 const FT_Bitmap *abitmap );
431 /*************************************************************************/
432 /* */
433 /* <Function> */
434 /* FT_Outline_Render */
435 /* */
436 /* <Description> */
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, */
440 /* etc. */
441 /* */
442 /* <Input> */
443 /* library :: A handle to a FreeType library object. */
444 /* */
445 /* outline :: A pointer to the source outline descriptor. */
446 /* */
447 /* <InOut> */
448 /* params :: A pointer to an @FT_Raster_Params structure used to */
449 /* describe the rendering operation. */
450 /* */
451 /* <Return> */
452 /* FreeType error code. 0~means success. */
453 /* */
454 /* <Note> */
455 /* You should know what you are doing and how @FT_Raster_Params works */
456 /* to use this function. */
457 /* */
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. */
461 /* */
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. */
466 /* */
467 FT_EXPORT( FT_Error )
468 FT_Outline_Render( FT_Library library,
469 FT_Outline* outline,
470 FT_Raster_Params* params );
473 /**************************************************************************
475 * @enum:
476 * FT_Orientation
478 * @description:
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.
484 * @values:
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,
514 FT_ORIENTATION_NONE
516 } FT_Orientation;
519 /**************************************************************************
521 * @function:
522 * FT_Outline_Get_Orientation
524 * @description:
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
531 * outlines.
533 * @input:
534 * outline ::
535 * A handle to the source outline.
537 * @return:
538 * The orientation.
541 FT_EXPORT( FT_Orientation )
542 FT_Outline_Get_Orientation( FT_Outline* outline );
545 /* */
548 FT_END_HEADER
550 #endif /* __FTOUTLN_H__ */
553 /* END */
556 /* Local Variables: */
557 /* coding: utf-8 */
558 /* End: */