1 /****************************************************************************
5 * Support for the FT_Outline type used to store glyph shapes of
6 * most scalable font formats (specification).
8 * Copyright (C) 1996-2019 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.
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 /**************************************************************************
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.
58 * FT_Outline_Translate
59 * FT_Outline_Transform
61 * FT_Outline_EmboldenXY
68 * FT_Outline_Get_Bitmap
70 * FT_Outline_Decompose
72 * FT_Outline_MoveToFunc
73 * FT_Outline_LineToFunc
74 * FT_Outline_ConicToFunc
75 * FT_Outline_CubicToFunc
78 * FT_Outline_Get_Orientation
85 /**************************************************************************
88 * FT_Outline_Decompose
91 * Walk over an outline's structure to decompose it into individual
92 * segments and Bezier arcs. This function also emits 'move to'
93 * operations to indicate the start of new contours in the outline.
97 * A pointer to the source target.
100 * A table of 'emitters', i.e., function pointers called during
101 * decomposition to indicate path operations.
105 * A typeless pointer that is passed to each emitter during the
106 * decomposition. It can be used to store the state during the
110 * FreeType error code. 0~means success.
113 * A contour that contains a single point only is represented by a 'move
114 * to' operation followed by 'line to' to the same point. In most cases,
115 * it is best to filter this out before using the outline for stroking
116 * purposes (otherwise it would result in a visible dot when round caps
119 * Similarly, the function returns success for an empty outline also
120 * (doing nothing, this is, not calling any emitter); if necessary, you
121 * should filter this out, too.
123 FT_EXPORT( FT_Error )
124 FT_Outline_Decompose( FT_Outline* outline,
125 const FT_Outline_Funcs* func_interface,
129 /**************************************************************************
135 * Create a new outline of a given size.
139 * A handle to the library object from where the outline is allocated.
140 * Note however that the new outline will **not** necessarily be
141 * **freed**, when destroying the library, by @FT_Done_FreeType.
144 * The maximum number of points within the outline. Must be smaller
145 * than or equal to 0xFFFF (65535).
148 * The maximum number of contours within the outline. This value must
149 * be in the range 0 to `numPoints`.
153 * A handle to the new outline.
156 * FreeType error code. 0~means success.
159 * The reason why this function takes a `library` parameter is simply to
160 * use the library's memory allocator.
162 FT_EXPORT( FT_Error )
163 FT_Outline_New( FT_Library library,
166 FT_Outline *anoutline );
169 /**************************************************************************
175 * Destroy an outline created with @FT_Outline_New.
179 * A handle of the library object used to allocate the outline.
182 * A pointer to the outline object to be discarded.
185 * FreeType error code. 0~means success.
188 * If the outline's 'owner' field is not set, only the outline descriptor
191 FT_EXPORT( FT_Error )
192 FT_Outline_Done( FT_Library library,
193 FT_Outline* outline );
196 /**************************************************************************
202 * Check the contents of an outline descriptor.
206 * A handle to a source outline.
209 * FreeType error code. 0~means success.
212 * An empty outline, or an outline with a single point only is also
215 FT_EXPORT( FT_Error )
216 FT_Outline_Check( FT_Outline* outline );
219 /**************************************************************************
222 * FT_Outline_Get_CBox
225 * Return an outline's 'control box'. The control box encloses all the
226 * outline's points, including Bezier control points. Though it
227 * coincides with the exact bounding box for most glyphs, it can be
228 * slightly larger in some situations (like when rotating an outline that
229 * contains Bezier outside arcs).
231 * Computing the control box is very fast, while getting the bounding box
232 * can take much more time as it needs to walk over all segments and arcs
233 * in the outline. To get the latter, you can use the 'ftbbox'
234 * component, which is dedicated to this single task.
238 * A pointer to the source outline descriptor.
242 * The outline's control box.
245 * See @FT_Glyph_Get_CBox for a discussion of tricky fonts.
248 FT_Outline_Get_CBox( const FT_Outline* outline,
252 /**************************************************************************
255 * FT_Outline_Translate
258 * Apply a simple translation to the points of an outline.
262 * A pointer to the target outline descriptor.
266 * The horizontal offset.
269 * The vertical offset.
272 FT_Outline_Translate( const FT_Outline* outline,
277 /**************************************************************************
283 * Copy an outline into another one. Both objects must have the same
284 * sizes (number of points & number of contours) when this function is
289 * A handle to the source outline.
293 * A handle to the target outline.
296 * FreeType error code. 0~means success.
298 FT_EXPORT( FT_Error )
299 FT_Outline_Copy( const FT_Outline* source,
300 FT_Outline *target );
303 /**************************************************************************
306 * FT_Outline_Transform
309 * Apply a simple 2x2 matrix to all of an outline's points. Useful for
310 * applying rotations, slanting, flipping, etc.
314 * A pointer to the target outline descriptor.
318 * A pointer to the transformation matrix.
321 * You can use @FT_Outline_Translate if you need to translate the
325 FT_Outline_Transform( const FT_Outline* outline,
326 const FT_Matrix* matrix );
329 /**************************************************************************
332 * FT_Outline_Embolden
335 * Embolden an outline. The new outline will be at most 4~times
336 * `strength` pixels wider and higher. You may think of the left and
337 * bottom borders as unchanged.
339 * Negative `strength` values to reduce the outline thickness are
344 * A handle to the target outline.
348 * How strong the glyph is emboldened. Expressed in 26.6 pixel format.
351 * FreeType error code. 0~means success.
354 * The used algorithm to increase or decrease the thickness of the glyph
355 * doesn't change the number of points; this means that certain
356 * situations like acute angles or intersections are sometimes handled
359 * If you need 'better' metrics values you should call
360 * @FT_Outline_Get_CBox or @FT_Outline_Get_BBox.
362 * To get meaningful results, font scaling values must be set with
363 * functions like @FT_Set_Char_Size before calling FT_Render_Glyph.
367 * FT_Load_Glyph( face, index, FT_LOAD_DEFAULT );
369 * if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
370 * FT_Outline_Embolden( &face->glyph->outline, strength );
374 FT_EXPORT( FT_Error )
375 FT_Outline_Embolden( FT_Outline* outline,
379 /**************************************************************************
382 * FT_Outline_EmboldenXY
385 * Embolden an outline. The new outline will be `xstrength` pixels wider
386 * and `ystrength` pixels higher. Otherwise, it is similar to
387 * @FT_Outline_Embolden, which uses the same strength in both directions.
392 FT_EXPORT( FT_Error )
393 FT_Outline_EmboldenXY( FT_Outline* outline,
398 /**************************************************************************
404 * Reverse the drawing direction of an outline. This is used to ensure
405 * consistent fill conventions for mirrored glyphs.
409 * A pointer to the target outline descriptor.
412 * This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the
413 * outline's `flags` field.
415 * It shouldn't be used by a normal client application, unless it knows
419 FT_Outline_Reverse( FT_Outline* outline );
422 /**************************************************************************
425 * FT_Outline_Get_Bitmap
428 * Render an outline within a bitmap. The outline's image is simply
429 * OR-ed to the target bitmap.
433 * A handle to a FreeType library object.
436 * A pointer to the source outline descriptor.
440 * A pointer to the target bitmap descriptor.
443 * FreeType error code. 0~means success.
446 * This function does **not create** the bitmap, it only renders an
447 * outline image within the one you pass to it! Consequently, the
448 * various fields in `abitmap` should be set accordingly.
450 * It will use the raster corresponding to the default glyph format.
452 * The value of the `num_grays` field in `abitmap` is ignored. If you
453 * select the gray-level rasterizer, and you want less than 256 gray
454 * levels, you have to use @FT_Outline_Render directly.
456 FT_EXPORT( FT_Error )
457 FT_Outline_Get_Bitmap( FT_Library library,
459 const FT_Bitmap *abitmap );
462 /**************************************************************************
468 * Render an outline within a bitmap using the current scan-convert.
472 * A handle to a FreeType library object.
475 * A pointer to the source outline descriptor.
479 * A pointer to an @FT_Raster_Params structure used to describe the
480 * rendering operation.
483 * FreeType error code. 0~means success.
486 * This advanced function uses @FT_Raster_Params as an argument,
487 * allowing FreeType rasterizer to be used for direct composition,
488 * translucency, etc. You should know how to set up @FT_Raster_Params
489 * for this function to work.
491 * The field `params.source` will be set to `outline` before the scan
492 * converter is called, which means that the value you give to it is
495 * The gray-level rasterizer always uses 256 gray levels. If you want
496 * less gray levels, you have to provide your own span callback. See the
497 * @FT_RASTER_FLAG_DIRECT value of the `flags` field in the
498 * @FT_Raster_Params structure for more details.
500 FT_EXPORT( FT_Error )
501 FT_Outline_Render( FT_Library library,
503 FT_Raster_Params* params );
506 /**************************************************************************
512 * A list of values used to describe an outline's contour orientation.
514 * The TrueType and PostScript specifications use different conventions
515 * to determine whether outline contours should be filled or unfilled.
518 * FT_ORIENTATION_TRUETYPE ::
519 * According to the TrueType specification, clockwise contours must be
520 * filled, and counter-clockwise ones must be unfilled.
522 * FT_ORIENTATION_POSTSCRIPT ::
523 * According to the PostScript specification, counter-clockwise
524 * contours must be filled, and clockwise ones must be unfilled.
526 * FT_ORIENTATION_FILL_RIGHT ::
527 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
528 * remember that in TrueType, everything that is to the right of the
529 * drawing direction of a contour must be filled.
531 * FT_ORIENTATION_FILL_LEFT ::
532 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
533 * remember that in PostScript, everything that is to the left of the
534 * drawing direction of a contour must be filled.
536 * FT_ORIENTATION_NONE ::
537 * The orientation cannot be determined. That is, different parts of
538 * the glyph have different orientation.
541 typedef enum FT_Orientation_
543 FT_ORIENTATION_TRUETYPE = 0,
544 FT_ORIENTATION_POSTSCRIPT = 1,
545 FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
546 FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
552 /**************************************************************************
555 * FT_Outline_Get_Orientation
558 * This function analyzes a glyph outline and tries to compute its fill
559 * orientation (see @FT_Orientation). This is done by integrating the
560 * total area covered by the outline. The positive integral corresponds
561 * to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is
562 * returned. The negative integral corresponds to the counter-clockwise
563 * orientation and @FT_ORIENTATION_TRUETYPE is returned.
565 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
570 * A handle to the source outline.
576 FT_EXPORT( FT_Orientation )
577 FT_Outline_Get_Orientation( FT_Outline* outline );
585 #endif /* FTOUTLN_H_ */
591 /* Local Variables: */