1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* ftstroke.c */ |
3 * ftstroke.c |
4 /* */ |
4 * |
5 /* FreeType path stroker (body). */ |
5 * FreeType path stroker (body). |
6 /* */ |
6 * |
7 /* Copyright 2002-2018 by */ |
7 * Copyright (C) 2002-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
10 * This file is part of the FreeType project, and may only be used, |
11 /* modified, and distributed under the terms of the FreeType project */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <ft2build.h> |
19 #include <ft2build.h> |
20 #include FT_STROKER_H |
20 #include FT_STROKER_H |
21 #include FT_TRIGONOMETRY_H |
21 #include FT_TRIGONOMETRY_H |
22 #include FT_OUTLINE_H |
22 #include FT_OUTLINE_H |
23 #include FT_INTERNAL_MEMORY_H |
23 #include FT_INTERNAL_MEMORY_H |
24 #include FT_INTERNAL_DEBUG_H |
24 #include FT_INTERNAL_DEBUG_H |
25 #include FT_INTERNAL_OBJECTS_H |
25 #include FT_INTERNAL_OBJECTS_H |
26 |
26 |
27 #include "basepic.h" |
27 |
28 |
28 /* declare an extern to access `ft_outline_glyph_class' globally */ |
29 |
29 /* allocated in `ftglyph.c' */ |
30 /* declare an extern to access `ft_outline_glyph_class' globally */ |
|
31 /* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */ |
|
32 /* macro to access it when FT_CONFIG_OPTION_PIC is defined */ |
|
33 #ifndef FT_CONFIG_OPTION_PIC |
|
34 FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class; |
30 FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class; |
35 #endif |
|
36 |
31 |
37 |
32 |
38 /* documentation is in ftstroke.h */ |
33 /* documentation is in ftstroke.h */ |
39 |
34 |
40 FT_EXPORT_DEF( FT_StrokerBorder ) |
35 FT_EXPORT_DEF( FT_StrokerBorder ) |
370 { |
365 { |
371 /* copy the last point to the start of this sub-path, since */ |
366 /* copy the last point to the start of this sub-path, since */ |
372 /* it contains the `adjusted' starting coordinates */ |
367 /* it contains the `adjusted' starting coordinates */ |
373 border->num_points = --count; |
368 border->num_points = --count; |
374 border->points[start] = border->points[count]; |
369 border->points[start] = border->points[count]; |
|
370 border->tags[start] = border->tags[count]; |
375 |
371 |
376 if ( reverse ) |
372 if ( reverse ) |
377 { |
373 { |
378 /* reverse the points */ |
374 /* reverse the points */ |
379 { |
375 { |
434 /* move last point */ |
430 /* move last point */ |
435 border->points[border->num_points - 1] = *to; |
431 border->points[border->num_points - 1] = *to; |
436 } |
432 } |
437 else |
433 else |
438 { |
434 { |
439 /* don't add zero-length lineto */ |
435 /* don't add zero-length lineto, but always add moveto */ |
440 if ( border->num_points > 0 && |
436 if ( border->num_points > (FT_UInt)border->start && |
441 FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) && |
437 FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) && |
442 FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) ) |
438 FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) ) |
443 return error; |
439 return error; |
444 |
440 |
445 /* add one point */ |
441 /* add one point */ |
2085 |
2081 |
2086 |
2082 |
2087 /* documentation is in ftstroke.h */ |
2083 /* documentation is in ftstroke.h */ |
2088 |
2084 |
2089 /* |
2085 /* |
2090 * The following is very similar to FT_Outline_Decompose, except |
2086 * The following is very similar to FT_Outline_Decompose, except |
2091 * that we do support opened paths, and do not scale the outline. |
2087 * that we do support opened paths, and do not scale the outline. |
2092 */ |
2088 */ |
2093 FT_EXPORT_DEF( FT_Error ) |
2089 FT_EXPORT_DEF( FT_Error ) |
2094 FT_Stroker_ParseOutline( FT_Stroker stroker, |
2090 FT_Stroker_ParseOutline( FT_Stroker stroker, |
2095 FT_Outline* outline, |
2091 FT_Outline* outline, |
2096 FT_Bool opened ) |
2092 FT_Bool opened ) |