sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftoutln.h
Go to the documentation of this file.
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 (C) 1996-2025 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 */
18
19
24#ifndef FTOUTLN_H_
25#define FTOUTLN_H_
26
27
28#include <freetype/freetype.h>
29
30#ifdef FREETYPE_H
31#error "freetype.h of FreeType 1 has been loaded!"
32#error "Please fix the directory search order for header files"
33#error "so that freetype.h of FreeType 2 is found first."
34#endif
35
36
37FT_BEGIN_HEADER
38
39
40 /**************************************************************************
41 *
42 * @section:
43 * outline_processing
44 *
45 * @title:
46 * Outline Processing
47 *
48 * @abstract:
49 * Functions to create, transform, and render vectorial glyph images.
50 *
51 * @description:
52 * This section contains routines used to create and destroy scalable
53 * glyph images known as 'outlines'. These can also be measured,
54 * transformed, and converted into bitmaps and pixmaps.
55 *
56 * @order:
57 * FT_Outline
58 * FT_Outline_New
59 * FT_Outline_Done
60 * FT_Outline_Copy
61 * FT_Outline_Translate
62 * FT_Outline_Transform
63 * FT_Outline_Embolden
64 * FT_Outline_EmboldenXY
65 * FT_Outline_Reverse
66 * FT_Outline_Check
67 *
68 * FT_Outline_Get_CBox
69 * FT_Outline_Get_BBox
70 *
71 * FT_Outline_Get_Bitmap
72 * FT_Outline_Render
73 * FT_Outline_Decompose
74 * FT_Outline_Funcs
75 * FT_Outline_MoveToFunc
76 * FT_Outline_LineToFunc
77 * FT_Outline_ConicToFunc
78 * FT_Outline_CubicToFunc
79 *
80 * FT_Orientation
81 * FT_Outline_Get_Orientation
82 *
83 * FT_OUTLINE_XXX
84 *
85 */
86
87
88 /**************************************************************************
89 *
90 * @function:
91 * FT_Outline_Decompose
92 *
93 * @description:
94 * Walk over an outline's structure to decompose it into individual
95 * segments and Bezier arcs. This function also emits 'move to'
96 * operations to indicate the start of new contours in the outline.
97 *
98 * @input:
99 * outline ::
100 * A pointer to the source target.
101 *
102 * func_interface ::
103 * A table of 'emitters', i.e., function pointers called during
104 * decomposition to indicate path operations.
105 *
106 * @inout:
107 * user ::
108 * A typeless pointer that is passed to each emitter during the
109 * decomposition. It can be used to store the state during the
110 * decomposition.
111 *
112 * @return:
113 * FreeType error code. 0~means success.
114 *
115 * @note:
116 * Degenerate contours, segments, and Bezier arcs may be reported. In
117 * most cases, it is best to filter these out before using the outline
118 * for stroking or other path modification purposes (which may cause
119 * degenerate segments to become non-degenerate and visible, like when
120 * stroke caps are used or the path is otherwise outset). Some glyph
121 * outlines may contain deliberate degenerate single points for mark
122 * attachement.
123 *
124 * Similarly, the function returns success for an empty outline also
125 * (doing nothing, that is, not calling any emitter); if necessary, you
126 * should filter this out, too.
127 */
128 FT_EXPORT( FT_Error )
129 FT_Outline_Decompose( FT_Outline* outline,
130 const FT_Outline_Funcs* func_interface,
131 void* user );
132
133
134 /**************************************************************************
135 *
136 * @function:
137 * FT_Outline_New
138 *
139 * @description:
140 * Create a new outline of a given size.
141 *
142 * @input:
143 * library ::
144 * A handle to the library object from where the outline is allocated.
145 * Note however that the new outline will **not** necessarily be
146 * **freed**, when destroying the library, by @FT_Done_FreeType.
147 *
148 * numPoints ::
149 * The maximum number of points within the outline. Must be smaller
150 * than or equal to 0xFFFF (65535).
151 *
152 * numContours ::
153 * The maximum number of contours within the outline. This value must
154 * be in the range 0 to `numPoints`.
155 *
156 * @output:
157 * anoutline ::
158 * A handle to the new outline.
159 *
160 * @return:
161 * FreeType error code. 0~means success.
162 *
163 * @note:
164 * The reason why this function takes a `library` parameter is simply to
165 * use the library's memory allocator.
166 */
167 FT_EXPORT( FT_Error )
168 FT_Outline_New( FT_Library library,
169 FT_UInt numPoints,
170 FT_Int numContours,
171 FT_Outline *anoutline );
172
173
174 /**************************************************************************
175 *
176 * @function:
177 * FT_Outline_Done
178 *
179 * @description:
180 * Destroy an outline created with @FT_Outline_New.
181 *
182 * @input:
183 * library ::
184 * A handle of the library object used to allocate the outline.
185 *
186 * outline ::
187 * A pointer to the outline object to be discarded.
188 *
189 * @return:
190 * FreeType error code. 0~means success.
191 *
192 * @note:
193 * If the outline's 'owner' field is not set, only the outline descriptor
194 * will be released.
195 */
196 FT_EXPORT( FT_Error )
197 FT_Outline_Done( FT_Library library,
198 FT_Outline* outline );
199
200
201 /**************************************************************************
202 *
203 * @function:
204 * FT_Outline_Check
205 *
206 * @description:
207 * Check the contents of an outline descriptor.
208 *
209 * @input:
210 * outline ::
211 * A handle to a source outline.
212 *
213 * @return:
214 * FreeType error code. 0~means success.
215 *
216 * @note:
217 * An empty outline, or an outline with a single point only is also
218 * valid.
219 */
220 FT_EXPORT( FT_Error )
221 FT_Outline_Check( FT_Outline* outline );
222
223
224 /**************************************************************************
225 *
226 * @function:
227 * FT_Outline_Get_CBox
228 *
229 * @description:
230 * Return an outline's 'control box'. The control box encloses all the
231 * outline's points, including Bezier control points. Though it
232 * coincides with the exact bounding box for most glyphs, it can be
233 * slightly larger in some situations (like when rotating an outline that
234 * contains Bezier outside arcs).
235 *
236 * Computing the control box is very fast, while getting the bounding box
237 * can take much more time as it needs to walk over all segments and arcs
238 * in the outline. To get the latter, you can use the 'ftbbox'
239 * component, which is dedicated to this single task.
240 *
241 * @input:
242 * outline ::
243 * A pointer to the source outline descriptor.
244 *
245 * @output:
246 * acbox ::
247 * The outline's control box.
248 *
249 * @note:
250 * See @FT_Glyph_Get_CBox for a discussion of tricky fonts.
251 */
252 FT_EXPORT( void )
253 FT_Outline_Get_CBox( const FT_Outline* outline,
254 FT_BBox *acbox );
255
256
257 /**************************************************************************
258 *
259 * @function:
260 * FT_Outline_Translate
261 *
262 * @description:
263 * Apply a simple translation to the points of an outline.
264 *
265 * @inout:
266 * outline ::
267 * A pointer to the target outline descriptor.
268 *
269 * @input:
270 * xOffset ::
271 * The horizontal offset.
272 *
273 * yOffset ::
274 * The vertical offset.
275 */
276 FT_EXPORT( void )
277 FT_Outline_Translate( const FT_Outline* outline,
278 FT_Pos xOffset,
279 FT_Pos yOffset );
280
281
282 /**************************************************************************
283 *
284 * @function:
285 * FT_Outline_Copy
286 *
287 * @description:
288 * Copy an outline into another one. Both objects must have the same
289 * sizes (number of points & number of contours) when this function is
290 * called.
291 *
292 * @input:
293 * source ::
294 * A handle to the source outline.
295 *
296 * @output:
297 * target ::
298 * A handle to the target outline.
299 *
300 * @return:
301 * FreeType error code. 0~means success.
302 */
303 FT_EXPORT( FT_Error )
304 FT_Outline_Copy( const FT_Outline* source,
305 FT_Outline *target );
306
307
308 /**************************************************************************
309 *
310 * @function:
311 * FT_Outline_Transform
312 *
313 * @description:
314 * Apply a simple 2x2 matrix to all of an outline's points. Useful for
315 * applying rotations, slanting, flipping, etc.
316 *
317 * @inout:
318 * outline ::
319 * A pointer to the target outline descriptor.
320 *
321 * @input:
322 * matrix ::
323 * A pointer to the transformation matrix.
324 *
325 * @note:
326 * You can use @FT_Outline_Translate if you need to translate the
327 * outline's points.
328 */
329 FT_EXPORT( void )
330 FT_Outline_Transform( const FT_Outline* outline,
331 const FT_Matrix* matrix );
332
333
334 /**************************************************************************
335 *
336 * @function:
337 * FT_Outline_Embolden
338 *
339 * @description:
340 * Embolden an outline. The new outline will be at most 4~times
341 * `strength` pixels wider and higher. You may think of the left and
342 * bottom borders as unchanged.
343 *
344 * Negative `strength` values to reduce the outline thickness are
345 * possible also.
346 *
347 * @inout:
348 * outline ::
349 * A handle to the target outline.
350 *
351 * @input:
352 * strength ::
353 * How strong the glyph is emboldened. Expressed in 26.6 pixel format.
354 *
355 * @return:
356 * FreeType error code. 0~means success.
357 *
358 * @note:
359 * The used algorithm to increase or decrease the thickness of the glyph
360 * doesn't change the number of points; this means that certain
361 * situations like acute angles or intersections are sometimes handled
362 * incorrectly.
363 *
364 * If you need 'better' metrics values you should call
365 * @FT_Outline_Get_CBox or @FT_Outline_Get_BBox.
366 *
367 * To get meaningful results, font scaling values must be set with
368 * functions like @FT_Set_Char_Size before calling FT_Render_Glyph.
369 *
370 * @example:
371 * ```
372 * FT_Load_Glyph( face, index, FT_LOAD_DEFAULT );
373 *
374 * if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
375 * FT_Outline_Embolden( &face->glyph->outline, strength );
376 * ```
377 *
378 */
379 FT_EXPORT( FT_Error )
380 FT_Outline_Embolden( FT_Outline* outline,
381 FT_Pos strength );
382
383
384 /**************************************************************************
385 *
386 * @function:
387 * FT_Outline_EmboldenXY
388 *
389 * @description:
390 * Embolden an outline. The new outline will be `xstrength` pixels wider
391 * and `ystrength` pixels higher. Otherwise, it is similar to
392 * @FT_Outline_Embolden, which uses the same strength in both directions.
393 *
394 * @since:
395 * 2.4.10
396 */
397 FT_EXPORT( FT_Error )
398 FT_Outline_EmboldenXY( FT_Outline* outline,
399 FT_Pos xstrength,
400 FT_Pos ystrength );
401
402
403 /**************************************************************************
404 *
405 * @function:
406 * FT_Outline_Reverse
407 *
408 * @description:
409 * Reverse the drawing direction of an outline. This is used to ensure
410 * consistent fill conventions for mirrored glyphs.
411 *
412 * @inout:
413 * outline ::
414 * A pointer to the target outline descriptor.
415 *
416 * @note:
417 * This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the
418 * outline's `flags` field.
419 *
420 * It shouldn't be used by a normal client application, unless it knows
421 * what it is doing.
422 */
423 FT_EXPORT( void )
424 FT_Outline_Reverse( FT_Outline* outline );
425
426
427 /**************************************************************************
428 *
429 * @function:
430 * FT_Outline_Get_Bitmap
431 *
432 * @description:
433 * Render an outline within a bitmap. The outline's image is simply
434 * OR-ed to the target bitmap.
435 *
436 * @input:
437 * library ::
438 * A handle to a FreeType library object.
439 *
440 * outline ::
441 * A pointer to the source outline descriptor.
442 *
443 * @inout:
444 * abitmap ::
445 * A pointer to the target bitmap descriptor.
446 *
447 * @return:
448 * FreeType error code. 0~means success.
449 *
450 * @note:
451 * This function does **not create** the bitmap, it only renders an
452 * outline image within the one you pass to it! Consequently, the
453 * various fields in `abitmap` should be set accordingly.
454 *
455 * It will use the raster corresponding to the default glyph format.
456 *
457 * The value of the `num_grays` field in `abitmap` is ignored. If you
458 * select the gray-level rasterizer, and you want less than 256 gray
459 * levels, you have to use @FT_Outline_Render directly.
460 */
461 FT_EXPORT( FT_Error )
462 FT_Outline_Get_Bitmap( FT_Library library,
463 FT_Outline* outline,
464 const FT_Bitmap *abitmap );
465
466
467 /**************************************************************************
468 *
469 * @function:
470 * FT_Outline_Render
471 *
472 * @description:
473 * Render an outline within a bitmap using the current scan-convert.
474 *
475 * @input:
476 * library ::
477 * A handle to a FreeType library object.
478 *
479 * outline ::
480 * A pointer to the source outline descriptor.
481 *
482 * @inout:
483 * params ::
484 * A pointer to an @FT_Raster_Params structure used to describe the
485 * rendering operation.
486 *
487 * @return:
488 * FreeType error code. 0~means success.
489 *
490 * @note:
491 * This advanced function uses @FT_Raster_Params as an argument.
492 * The field `params.source` will be set to `outline` before the scan
493 * converter is called, which means that the value you give to it is
494 * actually ignored. Either `params.target` must point to preallocated
495 * bitmap, or @FT_RASTER_FLAG_DIRECT must be set in `params.flags`
496 * allowing FreeType rasterizer to be used for direct composition,
497 * translucency, etc. See @FT_Raster_Params for more details.
498 */
499 FT_EXPORT( FT_Error )
500 FT_Outline_Render( FT_Library library,
501 FT_Outline* outline,
502 FT_Raster_Params* params );
503
504
505 /**************************************************************************
506 *
507 * @enum:
508 * FT_Orientation
509 *
510 * @description:
511 * A list of values used to describe an outline's contour orientation.
512 *
513 * The TrueType and PostScript specifications use different conventions
514 * to determine whether outline contours should be filled or unfilled.
515 *
516 * @values:
517 * FT_ORIENTATION_TRUETYPE ::
518 * According to the TrueType specification, clockwise contours must be
519 * filled, and counter-clockwise ones must be unfilled.
520 *
521 * FT_ORIENTATION_POSTSCRIPT ::
522 * According to the PostScript specification, counter-clockwise
523 * contours must be filled, and clockwise ones must be unfilled.
524 *
525 * FT_ORIENTATION_FILL_RIGHT ::
526 * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
527 * remember that in TrueType, everything that is to the right of the
528 * drawing direction of a contour must be filled.
529 *
530 * FT_ORIENTATION_FILL_LEFT ::
531 * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
532 * remember that in PostScript, everything that is to the left of the
533 * drawing direction of a contour must be filled.
534 *
535 * FT_ORIENTATION_NONE ::
536 * The orientation cannot be determined. That is, different parts of
537 * the glyph have different orientation.
538 *
539 */
540 typedef enum FT_Orientation_
541 {
542 FT_ORIENTATION_TRUETYPE = 0,
543 FT_ORIENTATION_POSTSCRIPT = 1,
544 FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
545 FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
546 FT_ORIENTATION_NONE
547
548 } FT_Orientation;
549
550
551 /**************************************************************************
552 *
553 * @function:
554 * FT_Outline_Get_Orientation
555 *
556 * @description:
557 * This function analyzes a glyph outline and tries to compute its fill
558 * orientation (see @FT_Orientation). This is done by integrating the
559 * total area covered by the outline. The positive integral corresponds
560 * to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is
561 * returned. The negative integral corresponds to the counter-clockwise
562 * orientation and @FT_ORIENTATION_TRUETYPE is returned.
563 *
564 * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
565 * outlines.
566 *
567 * @input:
568 * outline ::
569 * A handle to the source outline.
570 *
571 * @return:
572 * The orientation.
573 *
574 */
575 FT_EXPORT( FT_Orientation )
576 FT_Outline_Get_Orientation( FT_Outline* outline );
577
578
579 /* */
580
581
582FT_END_HEADER
583
584#endif /* FTOUTLN_H_ */
585
586
587/* END */
588
589
590/* Local Variables: */
591/* coding: utf-8 */
592/* End: */