Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: third_party/freetype/src/base/ftstroke.c

Issue 815103002: Update freetype to 2.5.4. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Adjust GYP and GN Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/freetype/src/base/ftstream.c ('k') | third_party/freetype/src/base/ftsynth.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2006, 2008-2011, 2013 by */ 7 /* Copyright 2002-2006, 2008-2011, 2013, 2014 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 "../../include/ft2build.h" 19 #include <ft2build.h>
20 #include "../../include/freetype/ftstroke.h" 20 #include FT_STROKER_H
21 #include "../../include/freetype/fttrigon.h" 21 #include FT_TRIGONOMETRY_H
22 #include "../../include/freetype/ftoutln.h" 22 #include FT_OUTLINE_H
23 #include "../../include/freetype/internal/ftmemory.h" 23 #include FT_INTERNAL_MEMORY_H
24 #include "../../include/freetype/internal/ftdebug.h" 24 #include FT_INTERNAL_DEBUG_H
25 #include "../../include/freetype/internal/ftobjs.h" 25 #include FT_INTERNAL_OBJECTS_H
26 26
27 27
28 /* documentation is in ftstroke.h */ 28 /* documentation is in ftstroke.h */
29 29
30 FT_EXPORT_DEF( FT_StrokerBorder ) 30 FT_EXPORT_DEF( FT_StrokerBorder )
31 FT_Outline_GetInsideBorder( FT_Outline* outline ) 31 FT_Outline_GetInsideBorder( FT_Outline* outline )
32 { 32 {
33 FT_Orientation o = FT_Outline_Get_Orientation( outline ); 33 FT_Orientation o = FT_Outline_Get_Orientation( outline );
34 34
35 35
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 FT_EXPORT_DEF( FT_Error ) 788 FT_EXPORT_DEF( FT_Error )
789 FT_Stroker_New( FT_Library library, 789 FT_Stroker_New( FT_Library library,
790 FT_Stroker *astroker ) 790 FT_Stroker *astroker )
791 { 791 {
792 FT_Error error; /* assigned in FT_NEW */ 792 FT_Error error; /* assigned in FT_NEW */
793 FT_Memory memory; 793 FT_Memory memory;
794 FT_Stroker stroker = NULL; 794 FT_Stroker stroker = NULL;
795 795
796 796
797 if ( !library ) 797 if ( !library )
798 return FT_THROW( Invalid_Library_Handle );
799
800 if ( !astroker )
798 return FT_THROW( Invalid_Argument ); 801 return FT_THROW( Invalid_Argument );
799 802
800 memory = library->memory; 803 memory = library->memory;
801 804
802 if ( !FT_NEW( stroker ) ) 805 if ( !FT_NEW( stroker ) )
803 { 806 {
804 stroker->library = library; 807 stroker->library = library;
805 808
806 ft_stroke_border_init( &stroker->borders[0], memory ); 809 ft_stroke_border_init( &stroker->borders[0], memory );
807 ft_stroke_border_init( &stroker->borders[1], memory ); 810 ft_stroke_border_init( &stroker->borders[1], memory );
808 } 811 }
809 812
810 *astroker = stroker; 813 *astroker = stroker;
811 814
812 return error; 815 return error;
813 } 816 }
814 817
815 818
816 /* documentation is in ftstroke.h */ 819 /* documentation is in ftstroke.h */
817 820
818 FT_EXPORT_DEF( void ) 821 FT_EXPORT_DEF( void )
819 FT_Stroker_Set( FT_Stroker stroker, 822 FT_Stroker_Set( FT_Stroker stroker,
820 FT_Fixed radius, 823 FT_Fixed radius,
821 FT_Stroker_LineCap line_cap, 824 FT_Stroker_LineCap line_cap,
822 FT_Stroker_LineJoin line_join, 825 FT_Stroker_LineJoin line_join,
823 FT_Fixed miter_limit ) 826 FT_Fixed miter_limit )
824 { 827 {
828 if ( !stroker )
829 return;
830
825 stroker->radius = radius; 831 stroker->radius = radius;
826 stroker->line_cap = line_cap; 832 stroker->line_cap = line_cap;
827 stroker->line_join = line_join; 833 stroker->line_join = line_join;
828 stroker->miter_limit = miter_limit; 834 stroker->miter_limit = miter_limit;
829 835
830 /* ensure miter limit has sensible value */ 836 /* ensure miter limit has sensible value */
831 if ( stroker->miter_limit < 0x10000 ) 837 if ( stroker->miter_limit < 0x10000 )
832 stroker->miter_limit = 0x10000; 838 stroker->miter_limit = 0x10000;
833 839
834 /* save line join style: */ 840 /* save line join style: */
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 /* lines are long enough (line_length is zero for curves). */ 1001 /* lines are long enough (line_length is zero for curves). */
996 if ( !border->movable || line_length == 0 ) 1002 if ( !border->movable || line_length == 0 )
997 intersect = FALSE; 1003 intersect = FALSE;
998 else 1004 else
999 { 1005 {
1000 /* compute minimum required length of lines */ 1006 /* compute minimum required length of lines */
1001 FT_Fixed min_length = ft_pos_abs( FT_MulFix( stroker->radius, 1007 FT_Fixed min_length = ft_pos_abs( FT_MulFix( stroker->radius,
1002 FT_Tan( theta ) ) ); 1008 FT_Tan( theta ) ) );
1003 1009
1004 1010
1005 intersect = FT_BOOL( stroker->line_length >= min_length && 1011 intersect = FT_BOOL( min_length &&
1012 stroker->line_length >= min_length &&
1006 line_length >= min_length ); 1013 line_length >= min_length );
1007 } 1014 }
1008 1015
1009 if ( !intersect ) 1016 if ( !intersect )
1010 { 1017 {
1011 FT_Vector_From_Polar( &delta, stroker->radius, 1018 FT_Vector_From_Polar( &delta, stroker->radius,
1012 stroker->angle_out + rotate ); 1019 stroker->angle_out + rotate );
1013 delta.x += stroker->center.x; 1020 delta.x += stroker->center.x;
1014 delta.y += stroker->center.y; 1021 delta.y += stroker->center.y;
1015 1022
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 FT_Vector* to ) 1287 FT_Vector* to )
1281 { 1288 {
1282 FT_Error error = FT_Err_Ok; 1289 FT_Error error = FT_Err_Ok;
1283 FT_StrokeBorder border; 1290 FT_StrokeBorder border;
1284 FT_Vector delta; 1291 FT_Vector delta;
1285 FT_Angle angle; 1292 FT_Angle angle;
1286 FT_Int side; 1293 FT_Int side;
1287 FT_Fixed line_length; 1294 FT_Fixed line_length;
1288 1295
1289 1296
1297 if ( !stroker || !to )
1298 return FT_THROW( Invalid_Argument );
1299
1290 delta.x = to->x - stroker->center.x; 1300 delta.x = to->x - stroker->center.x;
1291 delta.y = to->y - stroker->center.y; 1301 delta.y = to->y - stroker->center.y;
1292 1302
1293 /* a zero-length lineto is a no-op; avoid creating a spurious corner */ 1303 /* a zero-length lineto is a no-op; avoid creating a spurious corner */
1294 if ( delta.x == 0 && delta.y == 0 ) 1304 if ( delta.x == 0 && delta.y == 0 )
1295 goto Exit; 1305 goto Exit;
1296 1306
1297 /* compute length of line */ 1307 /* compute length of line */
1298 line_length = FT_Vector_Length( &delta ); 1308 line_length = FT_Vector_Length( &delta );
1299 1309
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 FT_Vector* control, 1363 FT_Vector* control,
1354 FT_Vector* to ) 1364 FT_Vector* to )
1355 { 1365 {
1356 FT_Error error = FT_Err_Ok; 1366 FT_Error error = FT_Err_Ok;
1357 FT_Vector bez_stack[34]; 1367 FT_Vector bez_stack[34];
1358 FT_Vector* arc; 1368 FT_Vector* arc;
1359 FT_Vector* limit = bez_stack + 30; 1369 FT_Vector* limit = bez_stack + 30;
1360 FT_Bool first_arc = TRUE; 1370 FT_Bool first_arc = TRUE;
1361 1371
1362 1372
1373 if ( !stroker || !control || !to )
1374 {
1375 error = FT_THROW( Invalid_Argument );
1376 goto Exit;
1377 }
1378
1363 /* if all control points are coincident, this is a no-op; */ 1379 /* if all control points are coincident, this is a no-op; */
1364 /* avoid creating a spurious corner */ 1380 /* avoid creating a spurious corner */
1365 if ( FT_IS_SMALL( stroker->center.x - control->x ) && 1381 if ( FT_IS_SMALL( stroker->center.x - control->x ) &&
1366 FT_IS_SMALL( stroker->center.y - control->y ) && 1382 FT_IS_SMALL( stroker->center.y - control->y ) &&
1367 FT_IS_SMALL( control->x - to->x ) && 1383 FT_IS_SMALL( control->x - to->x ) &&
1368 FT_IS_SMALL( control->y - to->y ) ) 1384 FT_IS_SMALL( control->y - to->y ) )
1369 { 1385 {
1370 stroker->center = *to; 1386 stroker->center = *to;
1371 goto Exit; 1387 goto Exit;
1372 } 1388 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 FT_Vector* control2, 1565 FT_Vector* control2,
1550 FT_Vector* to ) 1566 FT_Vector* to )
1551 { 1567 {
1552 FT_Error error = FT_Err_Ok; 1568 FT_Error error = FT_Err_Ok;
1553 FT_Vector bez_stack[37]; 1569 FT_Vector bez_stack[37];
1554 FT_Vector* arc; 1570 FT_Vector* arc;
1555 FT_Vector* limit = bez_stack + 32; 1571 FT_Vector* limit = bez_stack + 32;
1556 FT_Bool first_arc = TRUE; 1572 FT_Bool first_arc = TRUE;
1557 1573
1558 1574
1575 if ( !stroker || !control1 || !control2 || !to )
1576 {
1577 error = FT_THROW( Invalid_Argument );
1578 goto Exit;
1579 }
1580
1559 /* if all control points are coincident, this is a no-op; */ 1581 /* if all control points are coincident, this is a no-op; */
1560 /* avoid creating a spurious corner */ 1582 /* avoid creating a spurious corner */
1561 if ( FT_IS_SMALL( stroker->center.x - control1->x ) && 1583 if ( FT_IS_SMALL( stroker->center.x - control1->x ) &&
1562 FT_IS_SMALL( stroker->center.y - control1->y ) && 1584 FT_IS_SMALL( stroker->center.y - control1->y ) &&
1563 FT_IS_SMALL( control1->x - control2->x ) && 1585 FT_IS_SMALL( control1->x - control2->x ) &&
1564 FT_IS_SMALL( control1->y - control2->y ) && 1586 FT_IS_SMALL( control1->y - control2->y ) &&
1565 FT_IS_SMALL( control2->x - to->x ) && 1587 FT_IS_SMALL( control2->x - to->x ) &&
1566 FT_IS_SMALL( control2->y - to->y ) ) 1588 FT_IS_SMALL( control2->y - to->y ) )
1567 { 1589 {
1568 stroker->center = *to; 1590 stroker->center = *to;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 } 1773 }
1752 1774
1753 1775
1754 /* documentation is in ftstroke.h */ 1776 /* documentation is in ftstroke.h */
1755 1777
1756 FT_EXPORT_DEF( FT_Error ) 1778 FT_EXPORT_DEF( FT_Error )
1757 FT_Stroker_BeginSubPath( FT_Stroker stroker, 1779 FT_Stroker_BeginSubPath( FT_Stroker stroker,
1758 FT_Vector* to, 1780 FT_Vector* to,
1759 FT_Bool open ) 1781 FT_Bool open )
1760 { 1782 {
1783 if ( !stroker || !to )
1784 return FT_THROW( Invalid_Argument );
1785
1761 /* We cannot process the first point, because there is not enough */ 1786 /* We cannot process the first point, because there is not enough */
1762 /* information regarding its corner/cap. The latter will be processed */ 1787 /* information regarding its corner/cap. The latter will be processed */
1763 /* in the `FT_Stroker_EndSubPath' routine. */ 1788 /* in the `FT_Stroker_EndSubPath' routine. */
1764 /* */ 1789 /* */
1765 stroker->first_point = TRUE; 1790 stroker->first_point = TRUE;
1766 stroker->center = *to; 1791 stroker->center = *to;
1767 stroker->subpath_open = open; 1792 stroker->subpath_open = open;
1768 1793
1769 /* Determine if we need to check whether the border radius is greater */ 1794 /* Determine if we need to check whether the border radius is greater */
1770 /* than the radius of curvature of a curve, to handle this case */ 1795 /* than the radius of curvature of a curve, to handle this case */
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 1876
1852 /* documentation is in ftstroke.h */ 1877 /* documentation is in ftstroke.h */
1853 1878
1854 /* there's a lot of magic in this function! */ 1879 /* there's a lot of magic in this function! */
1855 FT_EXPORT_DEF( FT_Error ) 1880 FT_EXPORT_DEF( FT_Error )
1856 FT_Stroker_EndSubPath( FT_Stroker stroker ) 1881 FT_Stroker_EndSubPath( FT_Stroker stroker )
1857 { 1882 {
1858 FT_Error error = FT_Err_Ok; 1883 FT_Error error = FT_Err_Ok;
1859 1884
1860 1885
1886 if ( !stroker )
1887 {
1888 error = FT_THROW( Invalid_Argument );
1889 goto Exit;
1890 }
1891
1861 if ( stroker->subpath_open ) 1892 if ( stroker->subpath_open )
1862 { 1893 {
1863 FT_StrokeBorder right = stroker->borders; 1894 FT_StrokeBorder right = stroker->borders;
1864 1895
1865 1896
1866 /* All right, this is an opened path, we need to add a cap between */ 1897 /* All right, this is an opened path, we need to add a cap between */
1867 /* right & left, add the reverse of left, then add a final cap */ 1898 /* right & left, add the reverse of left, then add a final cap */
1868 /* between left & right. */ 1899 /* between left & right. */
1869 error = ft_stroker_cap( stroker, stroker->angle_in, 0 ); 1900 error = ft_stroker_cap( stroker, stroker->angle_in, 0 );
1870 if ( error ) 1901 if ( error )
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 FT_EXPORT_DEF( FT_Error ) 2007 FT_EXPORT_DEF( FT_Error )
1977 FT_Stroker_GetCounts( FT_Stroker stroker, 2008 FT_Stroker_GetCounts( FT_Stroker stroker,
1978 FT_UInt *anum_points, 2009 FT_UInt *anum_points,
1979 FT_UInt *anum_contours ) 2010 FT_UInt *anum_contours )
1980 { 2011 {
1981 FT_UInt count1, count2, num_points = 0; 2012 FT_UInt count1, count2, num_points = 0;
1982 FT_UInt count3, count4, num_contours = 0; 2013 FT_UInt count3, count4, num_contours = 0;
1983 FT_Error error; 2014 FT_Error error;
1984 2015
1985 2016
2017 if ( !stroker )
2018 {
2019 error = FT_THROW( Invalid_Argument );
2020 goto Exit;
2021 }
2022
1986 error = ft_stroke_border_get_counts( stroker->borders + 0, 2023 error = ft_stroke_border_get_counts( stroker->borders + 0,
1987 &count1, &count2 ); 2024 &count1, &count2 );
1988 if ( error ) 2025 if ( error )
1989 goto Exit; 2026 goto Exit;
1990 2027
1991 error = ft_stroke_border_get_counts( stroker->borders + 1, 2028 error = ft_stroke_border_get_counts( stroker->borders + 1,
1992 &count3, &count4 ); 2029 &count3, &count4 );
1993 if ( error ) 2030 if ( error )
1994 goto Exit; 2031 goto Exit;
1995 2032
1996 num_points = count1 + count3; 2033 num_points = count1 + count3;
1997 num_contours = count2 + count4; 2034 num_contours = count2 + count4;
1998 2035
1999 Exit: 2036 Exit:
2000 *anum_points = num_points; 2037 if ( anum_points )
2001 *anum_contours = num_contours; 2038 *anum_points = num_points;
2039
2040 if ( anum_contours )
2041 *anum_contours = num_contours;
2042
2002 return error; 2043 return error;
2003 } 2044 }
2004 2045
2005 2046
2006 /* documentation is in ftstroke.h */ 2047 /* documentation is in ftstroke.h */
2007 2048
2008 FT_EXPORT_DEF( void ) 2049 FT_EXPORT_DEF( void )
2009 FT_Stroker_ExportBorder( FT_Stroker stroker, 2050 FT_Stroker_ExportBorder( FT_Stroker stroker,
2010 FT_StrokerBorder border, 2051 FT_StrokerBorder border,
2011 FT_Outline* outline ) 2052 FT_Outline* outline )
2012 { 2053 {
2054 if ( !stroker || !outline )
2055 return;
2056
2013 if ( border == FT_STROKER_BORDER_LEFT || 2057 if ( border == FT_STROKER_BORDER_LEFT ||
2014 border == FT_STROKER_BORDER_RIGHT ) 2058 border == FT_STROKER_BORDER_RIGHT )
2015 { 2059 {
2016 FT_StrokeBorder sborder = & stroker->borders[border]; 2060 FT_StrokeBorder sborder = & stroker->borders[border];
2017 2061
2018 2062
2019 if ( sborder->valid ) 2063 if ( sborder->valid )
2020 ft_stroke_border_export( sborder, outline ); 2064 ft_stroke_border_export( sborder, outline );
2021 } 2065 }
2022 } 2066 }
(...skipping 29 matching lines...) Expand all
2052 FT_Vector* limit; 2096 FT_Vector* limit;
2053 char* tags; 2097 char* tags;
2054 2098
2055 FT_Error error; 2099 FT_Error error;
2056 2100
2057 FT_Int n; /* index of contour in outline */ 2101 FT_Int n; /* index of contour in outline */
2058 FT_UInt first; /* index of first point in contour */ 2102 FT_UInt first; /* index of first point in contour */
2059 FT_Int tag; /* current point's state */ 2103 FT_Int tag; /* current point's state */
2060 2104
2061 2105
2062 if ( !outline || !stroker ) 2106 if ( !outline )
2107 return FT_THROW( Invalid_Outline );
2108
2109 if ( !stroker )
2063 return FT_THROW( Invalid_Argument ); 2110 return FT_THROW( Invalid_Argument );
2064 2111
2065 FT_Stroker_Rewind( stroker ); 2112 FT_Stroker_Rewind( stroker );
2066 2113
2067 first = 0; 2114 first = 0;
2068 2115
2069 for ( n = 0; n < outline->n_contours; n++ ) 2116 for ( n = 0; n < outline->n_contours; n++ )
2070 { 2117 {
2071 FT_UInt last; /* index of last point in contour */ 2118 FT_UInt last; /* index of last point in contour */
2072 2119
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 #include "basepic.h" 2298 #include "basepic.h"
2252 2299
2253 2300
2254 /* documentation is in ftstroke.h */ 2301 /* documentation is in ftstroke.h */
2255 2302
2256 FT_EXPORT_DEF( FT_Error ) 2303 FT_EXPORT_DEF( FT_Error )
2257 FT_Glyph_Stroke( FT_Glyph *pglyph, 2304 FT_Glyph_Stroke( FT_Glyph *pglyph,
2258 FT_Stroker stroker, 2305 FT_Stroker stroker,
2259 FT_Bool destroy ) 2306 FT_Bool destroy )
2260 { 2307 {
2261 FT_Error error = FT_ERR( Invalid_Argument ); 2308 FT_Error error = FT_ERR( Invalid_Argument );
2262 FT_Glyph glyph = NULL; 2309 FT_Glyph glyph = NULL;
2310
2311 /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
2263 FT_Library library = stroker->library; 2312 FT_Library library = stroker->library;
2264 2313
2265 FT_UNUSED( library ); 2314 FT_UNUSED( library );
2266 2315
2267 2316
2268 if ( pglyph == NULL ) 2317 if ( !pglyph )
2269 goto Exit; 2318 goto Exit;
2270 2319
2271 glyph = *pglyph; 2320 glyph = *pglyph;
2272 if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) 2321 if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
2273 goto Exit; 2322 goto Exit;
2274 2323
2275 { 2324 {
2276 FT_Glyph copy; 2325 FT_Glyph copy;
2277 2326
2278 2327
2279 error = FT_Glyph_Copy( glyph, &copy ); 2328 error = FT_Glyph_Copy( glyph, &copy );
2280 if ( error ) 2329 if ( error )
2281 goto Exit; 2330 goto Exit;
2282 2331
2283 glyph = copy; 2332 glyph = copy;
2284 } 2333 }
2285 2334
2286 { 2335 {
2287 FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph; 2336 FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
2288 FT_Outline* outline = &oglyph->outline; 2337 FT_Outline* outline = &oglyph->outline;
2289 FT_UInt num_points, num_contours; 2338 FT_UInt num_points, num_contours;
2290 2339
2291 2340
2292 error = FT_Stroker_ParseOutline( stroker, outline, FALSE ); 2341 error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
2293 if ( error ) 2342 if ( error )
2294 goto Fail; 2343 goto Fail;
2295 2344
2296 (void)FT_Stroker_GetCounts( stroker, &num_points, &num_contours ); 2345 FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
2297 2346
2298 FT_Outline_Done( glyph->library, outline ); 2347 FT_Outline_Done( glyph->library, outline );
2299 2348
2300 error = FT_Outline_New( glyph->library, 2349 error = FT_Outline_New( glyph->library,
2301 num_points, num_contours, outline ); 2350 num_points, num_contours, outline );
2302 if ( error ) 2351 if ( error )
2303 goto Fail; 2352 goto Fail;
2304 2353
2305 outline->n_points = 0; 2354 outline->n_points = 0;
2306 outline->n_contours = 0; 2355 outline->n_contours = 0;
(...skipping 20 matching lines...) Expand all
2327 2376
2328 2377
2329 /* documentation is in ftstroke.h */ 2378 /* documentation is in ftstroke.h */
2330 2379
2331 FT_EXPORT_DEF( FT_Error ) 2380 FT_EXPORT_DEF( FT_Error )
2332 FT_Glyph_StrokeBorder( FT_Glyph *pglyph, 2381 FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
2333 FT_Stroker stroker, 2382 FT_Stroker stroker,
2334 FT_Bool inside, 2383 FT_Bool inside,
2335 FT_Bool destroy ) 2384 FT_Bool destroy )
2336 { 2385 {
2337 FT_Error error = FT_ERR( Invalid_Argument ); 2386 FT_Error error = FT_ERR( Invalid_Argument );
2338 FT_Glyph glyph = NULL; 2387 FT_Glyph glyph = NULL;
2388
2389 /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
2339 FT_Library library = stroker->library; 2390 FT_Library library = stroker->library;
2340 2391
2341 FT_UNUSED( library ); 2392 FT_UNUSED( library );
2342 2393
2343 2394
2344 if ( pglyph == NULL ) 2395 if ( !pglyph )
2345 goto Exit; 2396 goto Exit;
2346 2397
2347 glyph = *pglyph; 2398 glyph = *pglyph;
2348 if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) 2399 if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
2349 goto Exit; 2400 goto Exit;
2350 2401
2351 { 2402 {
2352 FT_Glyph copy; 2403 FT_Glyph copy;
2353 2404
2354 2405
2355 error = FT_Glyph_Copy( glyph, &copy ); 2406 error = FT_Glyph_Copy( glyph, &copy );
2356 if ( error ) 2407 if ( error )
2357 goto Exit; 2408 goto Exit;
2358 2409
(...skipping 13 matching lines...) Expand all
2372 if ( border == FT_STROKER_BORDER_LEFT ) 2423 if ( border == FT_STROKER_BORDER_LEFT )
2373 border = FT_STROKER_BORDER_RIGHT; 2424 border = FT_STROKER_BORDER_RIGHT;
2374 else 2425 else
2375 border = FT_STROKER_BORDER_LEFT; 2426 border = FT_STROKER_BORDER_LEFT;
2376 } 2427 }
2377 2428
2378 error = FT_Stroker_ParseOutline( stroker, outline, FALSE ); 2429 error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
2379 if ( error ) 2430 if ( error )
2380 goto Fail; 2431 goto Fail;
2381 2432
2382 (void)FT_Stroker_GetBorderCounts( stroker, border, 2433 FT_Stroker_GetBorderCounts( stroker, border,
2383 &num_points, &num_contours ); 2434 &num_points, &num_contours );
2384 2435
2385 FT_Outline_Done( glyph->library, outline ); 2436 FT_Outline_Done( glyph->library, outline );
2386 2437
2387 error = FT_Outline_New( glyph->library, 2438 error = FT_Outline_New( glyph->library,
2388 num_points, 2439 num_points,
2389 num_contours, 2440 num_contours,
2390 outline ); 2441 outline );
2391 if ( error ) 2442 if ( error )
2392 goto Fail; 2443 goto Fail;
2393 2444
(...skipping 15 matching lines...) Expand all
2409 2460
2410 if ( !destroy ) 2461 if ( !destroy )
2411 *pglyph = NULL; 2462 *pglyph = NULL;
2412 2463
2413 Exit: 2464 Exit:
2414 return error; 2465 return error;
2415 } 2466 }
2416 2467
2417 2468
2418 /* END */ 2469 /* END */
OLDNEW
« no previous file with comments | « third_party/freetype/src/base/ftstream.c ('k') | third_party/freetype/src/base/ftsynth.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698