ReactOS  0.4.15-dev-2528-g5506091
ftstroke.h File Reference
#include <ft2build.h>
Include dependency graph for ftstroke.h:

Go to the source code of this file.

Typedefs

typedef typedefFT_BEGIN_HEADER struct FT_StrokerRec_FT_Stroker
 
typedef enum FT_Stroker_LineJoin_ FT_Stroker_LineJoin
 
typedef enum FT_Stroker_LineCap_ FT_Stroker_LineCap
 
typedef enum FT_StrokerBorder_ FT_StrokerBorder
 

Enumerations

enum  FT_Stroker_LineJoin_ {
  FT_STROKER_LINEJOIN_ROUND = 0, FT_STROKER_LINEJOIN_BEVEL = 1, FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE,
  FT_STROKER_LINEJOIN_MITER_FIXED = 3
}
 
enum  FT_Stroker_LineCap_ { FT_STROKER_LINECAP_BUTT = 0, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINECAP_SQUARE }
 
enum  FT_StrokerBorder_ { FT_STROKER_BORDER_LEFT = 0, FT_STROKER_BORDER_RIGHT }
 

Functions

 FT_Outline_GetInsideBorder (FT_Outline *outline)
 
 FT_Outline_GetOutsideBorder (FT_Outline *outline)
 
 FT_Stroker_New (FT_Library library, FT_Stroker *astroker)
 
 FT_Stroker_Set (FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap, FT_Stroker_LineJoin line_join, FT_Fixed miter_limit)
 
 FT_Stroker_Rewind (FT_Stroker stroker)
 
 FT_Stroker_ParseOutline (FT_Stroker stroker, FT_Outline *outline, FT_Bool opened)
 
 FT_Stroker_BeginSubPath (FT_Stroker stroker, FT_Vector *to, FT_Bool open)
 
 FT_Stroker_EndSubPath (FT_Stroker stroker)
 
 FT_Stroker_LineTo (FT_Stroker stroker, FT_Vector *to)
 
 FT_Stroker_ConicTo (FT_Stroker stroker, FT_Vector *control, FT_Vector *to)
 
 FT_Stroker_CubicTo (FT_Stroker stroker, FT_Vector *control1, FT_Vector *control2, FT_Vector *to)
 
 FT_Stroker_GetBorderCounts (FT_Stroker stroker, FT_StrokerBorder border, FT_UInt *anum_points, FT_UInt *anum_contours)
 
 FT_Stroker_ExportBorder (FT_Stroker stroker, FT_StrokerBorder border, FT_Outline *outline)
 
 FT_Stroker_GetCounts (FT_Stroker stroker, FT_UInt *anum_points, FT_UInt *anum_contours)
 
 FT_Stroker_Export (FT_Stroker stroker, FT_Outline *outline)
 
 FT_Stroker_Done (FT_Stroker stroker)
 
 FT_Glyph_Stroke (FT_Glyph *pglyph, FT_Stroker stroker, FT_Bool destroy)
 
 FT_Glyph_StrokeBorder (FT_Glyph *pglyph, FT_Stroker stroker, FT_Bool inside, FT_Bool destroy)
 

Typedef Documentation

◆ FT_Stroker

typedef typedefFT_BEGIN_HEADER struct FT_StrokerRec_* FT_Stroker

Definition at line 92 of file ftstroke.h.

◆ FT_Stroker_LineCap

◆ FT_Stroker_LineJoin

◆ FT_StrokerBorder

Enumeration Type Documentation

◆ FT_Stroker_LineCap_

Enumerator
FT_STROKER_LINECAP_BUTT 
FT_STROKER_LINECAP_ROUND 
FT_STROKER_LINECAP_SQUARE 

Definition at line 174 of file ftstroke.h.

◆ FT_Stroker_LineJoin_

Enumerator
FT_STROKER_LINEJOIN_ROUND 
FT_STROKER_LINEJOIN_BEVEL 
FT_STROKER_LINEJOIN_MITER_VARIABLE 
FT_STROKER_LINEJOIN_MITER 
FT_STROKER_LINEJOIN_MITER_FIXED 

Definition at line 141 of file ftstroke.h.

◆ FT_StrokerBorder_

Enumerator
FT_STROKER_BORDER_LEFT 
FT_STROKER_BORDER_RIGHT 

Definition at line 208 of file ftstroke.h.

209  {
212 
enum FT_StrokerBorder_ FT_StrokerBorder

Function Documentation

◆ FT_Glyph_Stroke()

FT_Glyph_Stroke ( FT_Glyph pglyph,
FT_Stroker  stroker,
FT_Bool  destroy 
)

Definition at line 2302 of file ftstroke.c.

2305  {
2306  FT_Error error = FT_ERR( Invalid_Argument );
2307  FT_Glyph glyph = NULL;
2308 
2309  /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
2310  FT_Library library = stroker->library;
2311 
2312  FT_UNUSED( library );
2313 
2314 
2315  if ( !pglyph )
2316  goto Exit;
2317 
2318  glyph = *pglyph;
2319  if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
2320  goto Exit;
2321 
2322  {
2323  FT_Glyph copy;
2324 
2325 
2326  error = FT_Glyph_Copy( glyph, &copy );
2327  if ( error )
2328  goto Exit;
2329 
2330  glyph = copy;
2331  }
2332 
2333  {
2334  FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
2335  FT_Outline* outline = &oglyph->outline;
2336  FT_UInt num_points, num_contours;
2337 
2338 
2339  error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
2340  if ( error )
2341  goto Fail;
2342 
2343  FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
2344 
2345  FT_Outline_Done( glyph->library, outline );
2346 
2347  error = FT_Outline_New( glyph->library,
2348  num_points,
2349  (FT_Int)num_contours,
2350  outline );
2351  if ( error )
2352  goto Fail;
2353 
2354  outline->n_points = 0;
2355  outline->n_contours = 0;
2356 
2357  FT_Stroker_Export( stroker, outline );
2358  }
2359 
2360  if ( destroy )
2361  FT_Done_Glyph( *pglyph );
2362 
2363  *pglyph = glyph;
2364  goto Exit;
2365 
2366  Fail:
2367  FT_Done_Glyph( glyph );
2368  glyph = NULL;
2369 
2370  if ( !destroy )
2371  *pglyph = NULL;
2372 
2373  Exit:
2374  return error;
2375  }
int FT_Error
Definition: fttypes.h:300
FT_Stroker_GetCounts(FT_Stroker stroker, FT_UInt *anum_points, FT_UInt *anum_contours)
Definition: ftstroke.c:2015
struct FT_OutlineGlyphRec_ * FT_OutlineGlyph
Definition: ftglyph.h:179
const FT_Glyph_Class * clazz
Definition: ftglyph.h:111
#define error(str)
Definition: mkdosfs.c:1605
signed int FT_Int
Definition: fttypes.h:220
FT_Library library
Definition: ftglyph.h:110
FT_Glyph_Copy(FT_Glyph source, FT_Glyph *target)
Definition: ftglyph.c:316
FT_Library library
Definition: cffdrivr.c:654
int Fail
Definition: ehthrow.cxx:24
#define FALSE
Definition: types.h:117
FT_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
Definition: ftoutln.c:341
#define FT_ERR(e)
Definition: fttypes.h:586
FT_Outline_Done(FT_Library library, FT_Outline *outline)
Definition: ftoutln.c:463
static void Exit(void)
Definition: sock.c:1331
void destroy(_Tp *__pointer)
Definition: _construct.h:278
FT_Stroker_Export(FT_Stroker stroker, FT_Outline *outline)
Definition: ftstroke.c:2079
Definition: mesh.c:5329
#define FT_OUTLINE_GLYPH_CLASS_GET
Definition: basepic.h:28
unsigned int FT_UInt
Definition: fttypes.h:231
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define NULL
Definition: types.h:112
FT_Outline outline
Definition: ftglyph.h:211
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
FT_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline *outline, FT_Bool opened)
Definition: ftstroke.c:2094

◆ FT_Glyph_StrokeBorder()

FT_Glyph_StrokeBorder ( FT_Glyph pglyph,
FT_Stroker  stroker,
FT_Bool  inside,
FT_Bool  destroy 
)

Definition at line 2381 of file ftstroke.c.

2385  {
2386  FT_Error error = FT_ERR( Invalid_Argument );
2387  FT_Glyph glyph = NULL;
2388 
2389  /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
2390  FT_Library library = stroker->library;
2391 
2392  FT_UNUSED( library );
2393 
2394 
2395  if ( !pglyph )
2396  goto Exit;
2397 
2398  glyph = *pglyph;
2399  if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
2400  goto Exit;
2401 
2402  {
2403  FT_Glyph copy;
2404 
2405 
2406  error = FT_Glyph_Copy( glyph, &copy );
2407  if ( error )
2408  goto Exit;
2409 
2410  glyph = copy;
2411  }
2412 
2413  {
2414  FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
2416  FT_Outline* outline = &oglyph->outline;
2417  FT_UInt num_points, num_contours;
2418 
2419 
2421  if ( inside )
2422  {
2423  if ( border == FT_STROKER_BORDER_LEFT )
2425  else
2427  }
2428 
2429  error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
2430  if ( error )
2431  goto Fail;
2432 
2434  &num_points, &num_contours );
2435 
2436  FT_Outline_Done( glyph->library, outline );
2437 
2438  error = FT_Outline_New( glyph->library,
2439  num_points,
2440  (FT_Int)num_contours,
2441  outline );
2442  if ( error )
2443  goto Fail;
2444 
2445  outline->n_points = 0;
2446  outline->n_contours = 0;
2447 
2448  FT_Stroker_ExportBorder( stroker, border, outline );
2449  }
2450 
2451  if ( destroy )
2452  FT_Done_Glyph( *pglyph );
2453 
2454  *pglyph = glyph;
2455  goto Exit;
2456 
2457  Fail:
2458  FT_Done_Glyph( glyph );
2459  glyph = NULL;
2460 
2461  if ( !destroy )
2462  *pglyph = NULL;
2463 
2464  Exit:
2465  return error;
2466  }
int FT_Error
Definition: fttypes.h:300
FT_Stroker_GetBorderCounts(FT_Stroker stroker, FT_StrokerBorder border, FT_UInt *anum_points, FT_UInt *anum_contours)
Definition: ftstroke.c:1984
struct FT_OutlineGlyphRec_ * FT_OutlineGlyph
Definition: ftglyph.h:179
const FT_Glyph_Class * clazz
Definition: ftglyph.h:111
#define error(str)
Definition: mkdosfs.c:1605
signed int FT_Int
Definition: fttypes.h:220
FT_Library library
Definition: ftglyph.h:110
FT_Glyph_Copy(FT_Glyph source, FT_Glyph *target)
Definition: ftglyph.c:316
FT_Library library
Definition: cffdrivr.c:654
int Fail
Definition: ehthrow.cxx:24
#define FALSE
Definition: types.h:117
FT_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
Definition: ftoutln.c:341
enum FT_StrokerBorder_ FT_StrokerBorder
#define FT_ERR(e)
Definition: fttypes.h:586
FT_Outline_Done(FT_Library library, FT_Outline *outline)
Definition: ftoutln.c:463
static void Exit(void)
Definition: sock.c:1331
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
void destroy(_Tp *__pointer)
Definition: _construct.h:278
Definition: mesh.c:5329
#define FT_OUTLINE_GLYPH_CLASS_GET
Definition: basepic.h:28
FT_Stroker_ExportBorder(FT_Stroker stroker, FT_StrokerBorder border, FT_Outline *outline)
Definition: ftstroke.c:2057
unsigned int FT_UInt
Definition: fttypes.h:231
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define NULL
Definition: types.h:112
FT_Outline outline
Definition: ftglyph.h:211
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
FT_Outline_GetOutsideBorder(FT_Outline *outline)
Definition: ftstroke.c:54
FT_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline *outline, FT_Bool opened)
Definition: ftstroke.c:2094

◆ FT_Outline_GetInsideBorder()

FT_Outline_GetInsideBorder ( FT_Outline outline)

Definition at line 41 of file ftstroke.c.

42  {
44 
45 
48  }
enum FT_Orientation_ FT_Orientation
FT_Outline_Get_Orientation(FT_Outline *outline)
Definition: ftoutln.c:1044
Definition: mesh.c:5329

◆ FT_Outline_GetOutsideBorder()

FT_Outline_GetOutsideBorder ( FT_Outline outline)

Definition at line 54 of file ftstroke.c.

55  {
57 
58 
61  }
enum FT_Orientation_ FT_Orientation
FT_Outline_Get_Orientation(FT_Outline *outline)
Definition: ftoutln.c:1044
Definition: mesh.c:5329

Referenced by FT_Glyph_StrokeBorder().

◆ FT_Stroker_BeginSubPath()

FT_Stroker_BeginSubPath ( FT_Stroker  stroker,
FT_Vector to,
FT_Bool  open 
)

Definition at line 1789 of file ftstroke.c.

1792  {
1793  if ( !stroker || !to )
1794  return FT_THROW( Invalid_Argument );
1795 
1796  /* We cannot process the first point, because there is not enough */
1797  /* information regarding its corner/cap. The latter will be processed */
1798  /* in the `FT_Stroker_EndSubPath' routine. */
1799  /* */
1800  stroker->first_point = TRUE;
1801  stroker->center = *to;
1802  stroker->subpath_open = open;
1803 
1804  /* Determine if we need to check whether the border radius is greater */
1805  /* than the radius of curvature of a curve, to handle this case */
1806  /* specially. This is only required if bevel joins or butt caps may */
1807  /* be created, because round & miter joins and round & square caps */
1808  /* cover the negative sector created with wide strokes. */
1809  stroker->handle_wide_strokes =
1810  FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_ROUND ||
1811  ( stroker->subpath_open &&
1812  stroker->line_cap == FT_STROKER_LINECAP_BUTT ) );
1813 
1814  /* record the subpath start point for each border */
1815  stroker->subpath_start = *to;
1816 
1817  stroker->angle_in = 0;
1818 
1819  return FT_Err_Ok;
1820  }
#define open
Definition: acwin.h:95
#define TRUE
Definition: types.h:120
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_BOOL(x)
Definition: fttypes.h:578

Referenced by FT_Stroker_ParseOutline().

◆ FT_Stroker_ConicTo()

FT_Stroker_ConicTo ( FT_Stroker  stroker,
FT_Vector control,
FT_Vector to 
)

Definition at line 1372 of file ftstroke.c.

1375  {
1377  FT_Vector bez_stack[34];
1378  FT_Vector* arc;
1379  FT_Vector* limit = bez_stack + 30;
1380  FT_Bool first_arc = TRUE;
1381 
1382 
1383  if ( !stroker || !control || !to )
1384  {
1385  error = FT_THROW( Invalid_Argument );
1386  goto Exit;
1387  }
1388 
1389  /* if all control points are coincident, this is a no-op; */
1390  /* avoid creating a spurious corner */
1391  if ( FT_IS_SMALL( stroker->center.x - control->x ) &&
1392  FT_IS_SMALL( stroker->center.y - control->y ) &&
1393  FT_IS_SMALL( control->x - to->x ) &&
1394  FT_IS_SMALL( control->y - to->y ) )
1395  {
1396  stroker->center = *to;
1397  goto Exit;
1398  }
1399 
1400  arc = bez_stack;
1401  arc[0] = *to;
1402  arc[1] = *control;
1403  arc[2] = stroker->center;
1404 
1405  while ( arc >= bez_stack )
1406  {
1407  FT_Angle angle_in, angle_out;
1408 
1409 
1410  /* initialize with current direction */
1411  angle_in = angle_out = stroker->angle_in;
1412 
1413  if ( arc < limit &&
1414  !ft_conic_is_small_enough( arc, &angle_in, &angle_out ) )
1415  {
1416  if ( stroker->first_point )
1417  stroker->angle_in = angle_in;
1418 
1419  ft_conic_split( arc );
1420  arc += 2;
1421  continue;
1422  }
1423 
1424  if ( first_arc )
1425  {
1426  first_arc = FALSE;
1427 
1428  /* process corner if necessary */
1429  if ( stroker->first_point )
1430  error = ft_stroker_subpath_start( stroker, angle_in, 0 );
1431  else
1432  {
1433  stroker->angle_out = angle_in;
1434  error = ft_stroker_process_corner( stroker, 0 );
1435  }
1436  }
1437  else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
1439  {
1440  /* if the deviation from one arc to the next is too great, */
1441  /* add a round corner */
1442  stroker->center = arc[2];
1443  stroker->angle_out = angle_in;
1444  stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
1445 
1446  error = ft_stroker_process_corner( stroker, 0 );
1447 
1448  /* reinstate line join style */
1449  stroker->line_join = stroker->line_join_saved;
1450  }
1451 
1452  if ( error )
1453  goto Exit;
1454 
1455  /* the arc's angle is small enough; we can add it directly to each */
1456  /* border */
1457  {
1458  FT_Vector ctrl, end;
1459  FT_Angle theta, phi, rotate, alpha0 = 0;
1460  FT_Fixed length;
1462  FT_Int side;
1463 
1464 
1465  theta = FT_Angle_Diff( angle_in, angle_out ) / 2;
1466  phi = angle_in + theta;
1467  length = FT_DivFix( stroker->radius, FT_Cos( theta ) );
1468 
1469  /* compute direction of original arc */
1470  if ( stroker->handle_wide_strokes )
1471  alpha0 = FT_Atan2( arc[0].x - arc[2].x, arc[0].y - arc[2].y );
1472 
1473  for ( border = stroker->borders, side = 0;
1474  side <= 1;
1475  side++, border++ )
1476  {
1477  rotate = FT_SIDE_TO_ROTATE( side );
1478 
1479  /* compute control point */
1480  FT_Vector_From_Polar( &ctrl, length, phi + rotate );
1481  ctrl.x += arc[1].x;
1482  ctrl.y += arc[1].y;
1483 
1484  /* compute end point */
1485  FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate );
1486  end.x += arc[0].x;
1487  end.y += arc[0].y;
1488 
1489  if ( stroker->handle_wide_strokes )
1490  {
1491  FT_Vector start;
1492  FT_Angle alpha1;
1493 
1494 
1495  /* determine whether the border radius is greater than the */
1496  /* radius of curvature of the original arc */
1497  start = border->points[border->num_points - 1];
1498 
1499  alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
1500 
1501  /* is the direction of the border arc opposite to */
1502  /* that of the original arc? */
1503  if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
1504  FT_ANGLE_PI / 2 )
1505  {
1506  FT_Angle beta, gamma;
1507  FT_Vector bvec, delta;
1508  FT_Fixed blen, sinA, sinB, alen;
1509 
1510 
1511  /* use the sine rule to find the intersection point */
1512  beta = FT_Atan2( arc[2].x - start.x, arc[2].y - start.y );
1513  gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
1514 
1515  bvec.x = end.x - start.x;
1516  bvec.y = end.y - start.y;
1517 
1518  blen = FT_Vector_Length( &bvec );
1519 
1520  sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
1521  sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
1522 
1523  alen = FT_MulDiv( blen, sinA, sinB );
1524 
1525  FT_Vector_From_Polar( &delta, alen, beta );
1526  delta.x += start.x;
1527  delta.y += start.y;
1528 
1529  /* circumnavigate the negative sector backwards */
1530  border->movable = FALSE;
1531  error = ft_stroke_border_lineto( border, &delta, FALSE );
1532  if ( error )
1533  goto Exit;
1535  if ( error )
1536  goto Exit;
1538  if ( error )
1539  goto Exit;
1540  /* and then move to the endpoint */
1542  if ( error )
1543  goto Exit;
1544 
1545  continue;
1546  }
1547 
1548  /* else fall through */
1549  }
1550 
1551  /* simply add an arc */
1553  if ( error )
1554  goto Exit;
1555  }
1556  }
1557 
1558  arc -= 2;
1559 
1560  stroker->angle_in = angle_out;
1561  }
1562 
1563  stroker->center = *to;
1564 
1565  Exit:
1566  return error;
1567  }
int FT_Error
Definition: fttypes.h:300
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:608
FT_Pos y
Definition: ftimage.h:77
#define FT_IS_SMALL(x)
Definition: ftstroke.c:77
#define error(str)
Definition: mkdosfs.c:1605
FT_Pos x
Definition: ftimage.h:76
#define TRUE
Definition: types.h:120
signed int FT_Int
Definition: fttypes.h:220
static void ft_conic_split(FT_Vector *base)
Definition: ftstroke.c:88
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define FT_SMALL_CONIC_THRESHOLD
Definition: ftstroke.c:72
return FT_Err_Ok
Definition: ftbbox.c:511
static FT_Error ft_stroke_border_lineto(FT_StrokeBorder border, FT_Vector *to, FT_Bool movable)
Definition: ftstroke.c:423
static FT_Pos ft_pos_abs(FT_Pos x)
Definition: ftstroke.c:81
GLint limit
Definition: glext.h:10326
static FT_Error ft_stroker_subpath_start(FT_Stroker stroker, FT_Angle start_angle, FT_Fixed line_length)
Definition: ftstroke.c:1255
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define FALSE
Definition: types.h:117
#define FT_THROW(e)
Definition: ftdebug.h:213
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
FT_Vector_From_Polar(FT_Vector *vec, FT_Fixed length, FT_Angle angle)
Definition: fttrigon.c:493
#define ctrl
Definition: input.c:1757
FT_Atan2(FT_Fixed x, FT_Fixed y)
Definition: fttrigon.c:340
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:416
#define FT_ANGLE_PI
Definition: fttrigon.h:64
_STLP_MOVE_TO_STD_NAMESPACE void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last)
Definition: _algo.c:519
static FT_Error ft_stroker_process_corner(FT_Stroker stroker, FT_Fixed line_length)
Definition: ftstroke.c:1221
static void Exit(void)
Definition: sock.c:1331
FT_Sin(FT_Angle angle)
Definition: fttrigon.c:312
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
GLuint GLuint end
Definition: gl.h:1545
#define FT_SIDE_TO_ROTATE(s)
Definition: ftstroke.c:770
FT_Cos(FT_Angle angle)
Definition: fttrigon.c:298
signed long FT_Fixed
Definition: fttypes.h:288
static FT_Bool ft_conic_is_small_enough(FT_Vector *base, FT_Angle *angle_in, FT_Angle *angle_out)
Definition: ftstroke.c:108
FT_Angle_Diff(FT_Angle angle1, FT_Angle angle2)
Definition: fttrigon.c:510
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
FT_Vector_Length(FT_Vector *vec)
Definition: fttrigon.c:426
static FT_Error ft_stroke_border_conicto(FT_StrokeBorder border, FT_Vector *control, FT_Vector *to)
Definition: ftstroke.c:465

Referenced by FT_Stroker_ParseOutline().

◆ FT_Stroker_CubicTo()

FT_Stroker_CubicTo ( FT_Stroker  stroker,
FT_Vector control1,
FT_Vector control2,
FT_Vector to 
)

Definition at line 1573 of file ftstroke.c.

1577  {
1579  FT_Vector bez_stack[37];
1580  FT_Vector* arc;
1581  FT_Vector* limit = bez_stack + 32;
1582  FT_Bool first_arc = TRUE;
1583 
1584 
1585  if ( !stroker || !control1 || !control2 || !to )
1586  {
1587  error = FT_THROW( Invalid_Argument );
1588  goto Exit;
1589  }
1590 
1591  /* if all control points are coincident, this is a no-op; */
1592  /* avoid creating a spurious corner */
1593  if ( FT_IS_SMALL( stroker->center.x - control1->x ) &&
1594  FT_IS_SMALL( stroker->center.y - control1->y ) &&
1595  FT_IS_SMALL( control1->x - control2->x ) &&
1596  FT_IS_SMALL( control1->y - control2->y ) &&
1597  FT_IS_SMALL( control2->x - to->x ) &&
1598  FT_IS_SMALL( control2->y - to->y ) )
1599  {
1600  stroker->center = *to;
1601  goto Exit;
1602  }
1603 
1604  arc = bez_stack;
1605  arc[0] = *to;
1606  arc[1] = *control2;
1607  arc[2] = *control1;
1608  arc[3] = stroker->center;
1609 
1610  while ( arc >= bez_stack )
1611  {
1612  FT_Angle angle_in, angle_mid, angle_out;
1613 
1614 
1615  /* initialize with current direction */
1616  angle_in = angle_out = angle_mid = stroker->angle_in;
1617 
1618  if ( arc < limit &&
1619  !ft_cubic_is_small_enough( arc, &angle_in,
1620  &angle_mid, &angle_out ) )
1621  {
1622  if ( stroker->first_point )
1623  stroker->angle_in = angle_in;
1624 
1625  ft_cubic_split( arc );
1626  arc += 3;
1627  continue;
1628  }
1629 
1630  if ( first_arc )
1631  {
1632  first_arc = FALSE;
1633 
1634  /* process corner if necessary */
1635  if ( stroker->first_point )
1636  error = ft_stroker_subpath_start( stroker, angle_in, 0 );
1637  else
1638  {
1639  stroker->angle_out = angle_in;
1640  error = ft_stroker_process_corner( stroker, 0 );
1641  }
1642  }
1643  else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
1645  {
1646  /* if the deviation from one arc to the next is too great, */
1647  /* add a round corner */
1648  stroker->center = arc[3];
1649  stroker->angle_out = angle_in;
1650  stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
1651 
1652  error = ft_stroker_process_corner( stroker, 0 );
1653 
1654  /* reinstate line join style */
1655  stroker->line_join = stroker->line_join_saved;
1656  }
1657 
1658  if ( error )
1659  goto Exit;
1660 
1661  /* the arc's angle is small enough; we can add it directly to each */
1662  /* border */
1663  {
1664  FT_Vector ctrl1, ctrl2, end;
1665  FT_Angle theta1, phi1, theta2, phi2, rotate, alpha0 = 0;
1666  FT_Fixed length1, length2;
1668  FT_Int side;
1669 
1670 
1671  theta1 = FT_Angle_Diff( angle_in, angle_mid ) / 2;
1672  theta2 = FT_Angle_Diff( angle_mid, angle_out ) / 2;
1673  phi1 = ft_angle_mean( angle_in, angle_mid );
1674  phi2 = ft_angle_mean( angle_mid, angle_out );
1675  length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
1676  length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
1677 
1678  /* compute direction of original arc */
1679  if ( stroker->handle_wide_strokes )
1680  alpha0 = FT_Atan2( arc[0].x - arc[3].x, arc[0].y - arc[3].y );
1681 
1682  for ( border = stroker->borders, side = 0;
1683  side <= 1;
1684  side++, border++ )
1685  {
1686  rotate = FT_SIDE_TO_ROTATE( side );
1687 
1688  /* compute control points */
1689  FT_Vector_From_Polar( &ctrl1, length1, phi1 + rotate );
1690  ctrl1.x += arc[2].x;
1691  ctrl1.y += arc[2].y;
1692 
1693  FT_Vector_From_Polar( &ctrl2, length2, phi2 + rotate );
1694  ctrl2.x += arc[1].x;
1695  ctrl2.y += arc[1].y;
1696 
1697  /* compute end point */
1698  FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate );
1699  end.x += arc[0].x;
1700  end.y += arc[0].y;
1701 
1702  if ( stroker->handle_wide_strokes )
1703  {
1704  FT_Vector start;
1705  FT_Angle alpha1;
1706 
1707 
1708  /* determine whether the border radius is greater than the */
1709  /* radius of curvature of the original arc */
1710  start = border->points[border->num_points - 1];
1711 
1712  alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
1713 
1714  /* is the direction of the border arc opposite to */
1715  /* that of the original arc? */
1716  if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
1717  FT_ANGLE_PI / 2 )
1718  {
1719  FT_Angle beta, gamma;
1720  FT_Vector bvec, delta;
1721  FT_Fixed blen, sinA, sinB, alen;
1722 
1723 
1724  /* use the sine rule to find the intersection point */
1725  beta = FT_Atan2( arc[3].x - start.x, arc[3].y - start.y );
1726  gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
1727 
1728  bvec.x = end.x - start.x;
1729  bvec.y = end.y - start.y;
1730 
1731  blen = FT_Vector_Length( &bvec );
1732 
1733  sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
1734  sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
1735 
1736  alen = FT_MulDiv( blen, sinA, sinB );
1737 
1738  FT_Vector_From_Polar( &delta, alen, beta );
1739  delta.x += start.x;
1740  delta.y += start.y;
1741 
1742  /* circumnavigate the negative sector backwards */
1743  border->movable = FALSE;
1744  error = ft_stroke_border_lineto( border, &delta, FALSE );
1745  if ( error )
1746  goto Exit;
1748  if ( error )
1749  goto Exit;
1751  &ctrl2,
1752  &ctrl1,
1753  &start );
1754  if ( error )
1755  goto Exit;
1756  /* and then move to the endpoint */
1758  if ( error )
1759  goto Exit;
1760 
1761  continue;
1762  }
1763 
1764  /* else fall through */
1765  }
1766 
1767  /* simply add an arc */
1768  error = ft_stroke_border_cubicto( border, &ctrl1, &ctrl2, &end );
1769  if ( error )
1770  goto Exit;
1771  }
1772  }
1773 
1774  arc -= 3;
1775 
1776  stroker->angle_in = angle_out;
1777  }
1778 
1779  stroker->center = *to;
1780 
1781  Exit:
1782  return error;
1783  }
int FT_Error
Definition: fttypes.h:300
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:608
FT_Pos y
Definition: ftimage.h:77
#define FT_IS_SMALL(x)
Definition: ftstroke.c:77
#define error(str)
Definition: mkdosfs.c:1605
FT_Pos x
Definition: ftimage.h:76
#define TRUE
Definition: types.h:120
signed int FT_Int
Definition: fttypes.h:220
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
return FT_Err_Ok
Definition: ftbbox.c:511
static FT_Error ft_stroke_border_lineto(FT_StrokeBorder border, FT_Vector *to, FT_Bool movable)
Definition: ftstroke.c:423
static FT_Pos ft_pos_abs(FT_Pos x)
Definition: ftstroke.c:81
GLint limit
Definition: glext.h:10326
static FT_Error ft_stroker_subpath_start(FT_Stroker stroker, FT_Angle start_angle, FT_Fixed line_length)
Definition: ftstroke.c:1255
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define FALSE
Definition: types.h:117
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_Vector_From_Polar(FT_Vector *vec, FT_Fixed length, FT_Angle angle)
Definition: fttrigon.c:493
FT_Atan2(FT_Fixed x, FT_Fixed y)
Definition: fttrigon.c:340
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:416
#define FT_ANGLE_PI
Definition: fttrigon.h:64
_STLP_MOVE_TO_STD_NAMESPACE void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last)
Definition: _algo.c:519
static FT_Bool ft_cubic_is_small_enough(FT_Vector *base, FT_Angle *angle_in, FT_Angle *angle_mid, FT_Angle *angle_out)
Definition: ftstroke.c:198
static FT_Error ft_stroker_process_corner(FT_Stroker stroker, FT_Fixed line_length)
Definition: ftstroke.c:1221
static void Exit(void)
Definition: sock.c:1331
FT_Sin(FT_Angle angle)
Definition: fttrigon.c:312
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
GLuint GLuint end
Definition: gl.h:1545
#define FT_SIDE_TO_ROTATE(s)
Definition: ftstroke.c:770
FT_Cos(FT_Angle angle)
Definition: fttrigon.c:298
#define FT_SMALL_CUBIC_THRESHOLD
Definition: ftstroke.c:73
static FT_Angle ft_angle_mean(FT_Angle angle1, FT_Angle angle2)
Definition: ftstroke.c:190
static FT_Error ft_stroke_border_cubicto(FT_StrokeBorder border, FT_Vector *control1, FT_Vector *control2, FT_Vector *to)
Definition: ftstroke.c:497
signed long FT_Fixed
Definition: fttypes.h:288
FT_Angle_Diff(FT_Angle angle1, FT_Angle angle2)
Definition: fttrigon.c:510
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
FT_Vector_Length(FT_Vector *vec)
Definition: fttrigon.c:426
static void ft_cubic_split(FT_Vector *base)
Definition: ftstroke.c:159

Referenced by FT_Stroker_ParseOutline().

◆ FT_Stroker_Done()

FT_Stroker_Done ( FT_Stroker  stroker)

Definition at line 875 of file ftstroke.c.

876  {
877  if ( stroker )
878  {
879  FT_Memory memory = stroker->library->memory;
880 
881 
882  ft_stroke_border_done( &stroker->borders[0] );
883  ft_stroke_border_done( &stroker->borders[1] );
884 
885  stroker->library = NULL;
886  FT_FREE( stroker );
887  }
888  }
static char memory[1024 *256]
Definition: process.c:116
#define FT_FREE(ptr)
Definition: ftmemory.h:329
static void ft_stroke_border_done(FT_StrokeBorder border)
Definition: ftstroke.c:644
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define NULL
Definition: types.h:112

◆ FT_Stroker_EndSubPath()

FT_Stroker_EndSubPath ( FT_Stroker  stroker)

Definition at line 1891 of file ftstroke.c.

1892  {
1894 
1895 
1896  if ( !stroker )
1897  {
1898  error = FT_THROW( Invalid_Argument );
1899  goto Exit;
1900  }
1901 
1902  if ( stroker->subpath_open )
1903  {
1904  FT_StrokeBorder right = stroker->borders;
1905 
1906 
1907  /* All right, this is an opened path, we need to add a cap between */
1908  /* right & left, add the reverse of left, then add a final cap */
1909  /* between left & right. */
1910  error = ft_stroker_cap( stroker, stroker->angle_in, 0 );
1911  if ( error )
1912  goto Exit;
1913 
1914  /* add reversed points from `left' to `right' */
1915  error = ft_stroker_add_reverse_left( stroker, TRUE );
1916  if ( error )
1917  goto Exit;
1918 
1919  /* now add the final cap */
1920  stroker->center = stroker->subpath_start;
1921  error = ft_stroker_cap( stroker,
1922  stroker->subpath_angle + FT_ANGLE_PI, 0 );
1923  if ( error )
1924  goto Exit;
1925 
1926  /* Now end the right subpath accordingly. The left one is */
1927  /* rewind and doesn't need further processing. */
1929  }
1930  else
1931  {
1932  FT_Angle turn;
1933  FT_Int inside_side;
1934 
1935 
1936  /* close the path if needed */
1937  if ( stroker->center.x != stroker->subpath_start.x ||
1938  stroker->center.y != stroker->subpath_start.y )
1939  {
1940  error = FT_Stroker_LineTo( stroker, &stroker->subpath_start );
1941  if ( error )
1942  goto Exit;
1943  }
1944 
1945  /* process the corner */
1946  stroker->angle_out = stroker->subpath_angle;
1947  turn = FT_Angle_Diff( stroker->angle_in,
1948  stroker->angle_out );
1949 
1950  /* no specific corner processing is required if the turn is 0 */
1951  if ( turn != 0 )
1952  {
1953  /* when we turn to the right, the inside side is 0 */
1954  /* otherwise, the inside side is 1 */
1955  inside_side = ( turn < 0 );
1956 
1957  error = ft_stroker_inside( stroker,
1958  inside_side,
1959  stroker->subpath_line_length );
1960  if ( error )
1961  goto Exit;
1962 
1963  /* process the outside side */
1964  error = ft_stroker_outside( stroker,
1965  !inside_side,
1966  stroker->subpath_line_length );
1967  if ( error )
1968  goto Exit;
1969  }
1970 
1971  /* then end our two subpaths */
1972  ft_stroke_border_close( stroker->borders + 0, FALSE );
1973  ft_stroke_border_close( stroker->borders + 1, TRUE );
1974  }
1975 
1976  Exit:
1977  return error;
1978  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
#define TRUE
Definition: types.h:120
signed int FT_Int
Definition: fttypes.h:220
static FT_Error ft_stroker_outside(FT_Stroker stroker, FT_Int side, FT_Fixed line_length)
Definition: ftstroke.c:1060
return FT_Err_Ok
Definition: ftbbox.c:511
static void ft_stroke_border_close(FT_StrokeBorder border, FT_Bool reverse)
Definition: ftstroke.c:357
#define FALSE
Definition: types.h:117
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_Stroker_LineTo(FT_Stroker stroker, FT_Vector *to)
Definition: ftstroke.c:1296
#define FT_ANGLE_PI
Definition: fttrigon.h:64
static FT_Error ft_stroker_inside(FT_Stroker stroker, FT_Int side, FT_Fixed line_length)
Definition: ftstroke.c:995
static void Exit(void)
Definition: sock.c:1331
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
GLdouble GLdouble right
Definition: glext.h:10859
FT_Angle_Diff(FT_Angle angle1, FT_Angle angle2)
Definition: fttrigon.c:510
static FT_Error ft_stroker_cap(FT_Stroker stroker, FT_Angle angle, FT_Int side)
Definition: ftstroke.c:920
static FT_Error ft_stroker_add_reverse_left(FT_Stroker stroker, FT_Bool open)
Definition: ftstroke.c:1824

Referenced by FT_Stroker_ParseOutline().

◆ FT_Stroker_Export()

FT_Stroker_Export ( FT_Stroker  stroker,
FT_Outline outline 
)

Definition at line 2079 of file ftstroke.c.

2081  {
2084  }
Definition: mesh.c:5329
FT_Stroker_ExportBorder(FT_Stroker stroker, FT_StrokerBorder border, FT_Outline *outline)
Definition: ftstroke.c:2057

Referenced by FT_Glyph_Stroke().

◆ FT_Stroker_ExportBorder()

FT_Stroker_ExportBorder ( FT_Stroker  stroker,
FT_StrokerBorder  border,
FT_Outline outline 
)

Definition at line 2057 of file ftstroke.c.

2060  {
2061  if ( !stroker || !outline )
2062  return;
2063 
2064  if ( border == FT_STROKER_BORDER_LEFT ||
2066  {
2067  FT_StrokeBorder sborder = & stroker->borders[border];
2068 
2069 
2070  if ( sborder->valid )
2071  ft_stroke_border_export( sborder, outline );
2072  }
2073  }
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
Definition: mesh.c:5329
static void ft_stroke_border_export(FT_StrokeBorder border, FT_Outline *outline)
Definition: ftstroke.c:711

Referenced by FT_Glyph_StrokeBorder(), and FT_Stroker_Export().

◆ FT_Stroker_GetBorderCounts()

FT_Stroker_GetBorderCounts ( FT_Stroker  stroker,
FT_StrokerBorder  border,
FT_UInt anum_points,
FT_UInt anum_contours 
)

Definition at line 1984 of file ftstroke.c.

1988  {
1989  FT_UInt num_points = 0, num_contours = 0;
1990  FT_Error error;
1991 
1992 
1993  if ( !stroker || border > 1 )
1994  {
1995  error = FT_THROW( Invalid_Argument );
1996  goto Exit;
1997  }
1998 
1999  error = ft_stroke_border_get_counts( stroker->borders + border,
2000  &num_points, &num_contours );
2001  Exit:
2002  if ( anum_points )
2003  *anum_points = num_points;
2004 
2005  if ( anum_contours )
2006  *anum_contours = num_contours;
2007 
2008  return error;
2009  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
#define FT_THROW(e)
Definition: ftdebug.h:213
static void Exit(void)
Definition: sock.c:1331
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
unsigned int FT_UInt
Definition: fttypes.h:231
static FT_Error ft_stroke_border_get_counts(FT_StrokeBorder border, FT_UInt *anum_points, FT_UInt *anum_contours)
Definition: ftstroke.c:660

Referenced by FT_Glyph_StrokeBorder().

◆ FT_Stroker_GetCounts()

FT_Stroker_GetCounts ( FT_Stroker  stroker,
FT_UInt anum_points,
FT_UInt anum_contours 
)

Definition at line 2015 of file ftstroke.c.

2018  {
2019  FT_UInt count1, count2, num_points = 0;
2020  FT_UInt count3, count4, num_contours = 0;
2021  FT_Error error;
2022 
2023 
2024  if ( !stroker )
2025  {
2026  error = FT_THROW( Invalid_Argument );
2027  goto Exit;
2028  }
2029 
2030  error = ft_stroke_border_get_counts( stroker->borders + 0,
2031  &count1, &count2 );
2032  if ( error )
2033  goto Exit;
2034 
2035  error = ft_stroke_border_get_counts( stroker->borders + 1,
2036  &count3, &count4 );
2037  if ( error )
2038  goto Exit;
2039 
2040  num_points = count1 + count3;
2041  num_contours = count2 + count4;
2042 
2043  Exit:
2044  if ( anum_points )
2045  *anum_points = num_points;
2046 
2047  if ( anum_contours )
2048  *anum_contours = num_contours;
2049 
2050  return error;
2051  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
#define FT_THROW(e)
Definition: ftdebug.h:213
static void Exit(void)
Definition: sock.c:1331
unsigned int FT_UInt
Definition: fttypes.h:231
static FT_Error ft_stroke_border_get_counts(FT_StrokeBorder border, FT_UInt *anum_points, FT_UInt *anum_contours)
Definition: ftstroke.c:660

Referenced by FT_Glyph_Stroke().

◆ FT_Stroker_LineTo()

FT_Stroker_LineTo ( FT_Stroker  stroker,
FT_Vector to 
)

Definition at line 1296 of file ftstroke.c.

1298  {
1301  FT_Vector delta;
1302  FT_Angle angle;
1303  FT_Int side;
1304  FT_Fixed line_length;
1305 
1306 
1307  if ( !stroker || !to )
1308  return FT_THROW( Invalid_Argument );
1309 
1310  delta.x = to->x - stroker->center.x;
1311  delta.y = to->y - stroker->center.y;
1312 
1313  /* a zero-length lineto is a no-op; avoid creating a spurious corner */
1314  if ( delta.x == 0 && delta.y == 0 )
1315  goto Exit;
1316 
1317  /* compute length of line */
1318  line_length = FT_Vector_Length( &delta );
1319 
1320  angle = FT_Atan2( delta.x, delta.y );
1321  FT_Vector_From_Polar( &delta, stroker->radius, angle + FT_ANGLE_PI2 );
1322 
1323  /* process corner if necessary */
1324  if ( stroker->first_point )
1325  {
1326  /* This is the first segment of a subpath. We need to */
1327  /* add a point to each border at their respective starting */
1328  /* point locations. */
1329  error = ft_stroker_subpath_start( stroker, angle, line_length );
1330  if ( error )
1331  goto Exit;
1332  }
1333  else
1334  {
1335  /* process the current corner */
1336  stroker->angle_out = angle;
1337  error = ft_stroker_process_corner( stroker, line_length );
1338  if ( error )
1339  goto Exit;
1340  }
1341 
1342  /* now add a line segment to both the `inside' and `outside' paths */
1343  for ( border = stroker->borders, side = 1; side >= 0; side--, border++ )
1344  {
1345  FT_Vector point;
1346 
1347 
1348  point.x = to->x + delta.x;
1349  point.y = to->y + delta.y;
1350 
1351  /* the ends of lineto borders are movable */
1353  if ( error )
1354  goto Exit;
1355 
1356  delta.x = -delta.x;
1357  delta.y = -delta.y;
1358  }
1359 
1360  stroker->angle_in = angle;
1361  stroker->center = *to;
1362  stroker->line_length = line_length;
1363 
1364  Exit:
1365  return error;
1366  }
int FT_Error
Definition: fttypes.h:300
FT_Pos y
Definition: ftimage.h:77
#define FT_ANGLE_PI2
Definition: fttrigon.h:88
#define error(str)
Definition: mkdosfs.c:1605
FT_Pos x
Definition: ftimage.h:76
#define TRUE
Definition: types.h:120
signed int FT_Int
Definition: fttypes.h:220
GLfloat angle
Definition: glext.h:10853
return FT_Err_Ok
Definition: ftbbox.c:511
static FT_Error ft_stroke_border_lineto(FT_StrokeBorder border, FT_Vector *to, FT_Bool movable)
Definition: ftstroke.c:423
POINTL point
Definition: edittest.c:50
LONG y
Definition: windef.h:330
static FT_Error ft_stroker_subpath_start(FT_Stroker stroker, FT_Angle start_angle, FT_Fixed line_length)
Definition: ftstroke.c:1255
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_Vector_From_Polar(FT_Vector *vec, FT_Fixed length, FT_Angle angle)
Definition: fttrigon.c:493
FT_Atan2(FT_Fixed x, FT_Fixed y)
Definition: fttrigon.c:340
static FT_Error ft_stroker_process_corner(FT_Stroker stroker, FT_Fixed line_length)
Definition: ftstroke.c:1221
static void Exit(void)
Definition: sock.c:1331
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
Definition: fttrigon.h:52
LONG x
Definition: windef.h:329
signed long FT_Fixed
Definition: fttypes.h:288
FT_Vector_Length(FT_Vector *vec)
Definition: fttrigon.c:426

Referenced by FT_Stroker_EndSubPath(), and FT_Stroker_ParseOutline().

◆ FT_Stroker_New()

FT_Stroker_New ( FT_Library  library,
FT_Stroker astroker 
)

Definition at line 800 of file ftstroke.c.

802  {
803  FT_Error error; /* assigned in FT_NEW */
805  FT_Stroker stroker = NULL;
806 
807 
808  if ( !library )
809  return FT_THROW( Invalid_Library_Handle );
810 
811  if ( !astroker )
812  return FT_THROW( Invalid_Argument );
813 
814  memory = library->memory;
815 
816  if ( !FT_NEW( stroker ) )
817  {
818  stroker->library = library;
819 
820  ft_stroke_border_init( &stroker->borders[0], memory );
821  ft_stroke_border_init( &stroker->borders[1], memory );
822  }
823 
824  *astroker = stroker;
825 
826  return error;
827  }
int FT_Error
Definition: fttypes.h:300
FT_Memory memory
Definition: ftobjs.h:918
#define error(str)
Definition: mkdosfs.c:1605
FT_Library library
Definition: cffdrivr.c:654
static char memory[1024 *256]
Definition: process.c:116
#define FT_THROW(e)
Definition: ftdebug.h:213
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define NULL
Definition: types.h:112
typedefFT_BEGIN_HEADER struct FT_StrokerRec_ * FT_Stroker
Definition: ftstroke.h:92
#define FT_NEW(ptr)
Definition: ftmemory.h:331
static void ft_stroke_border_init(FT_StrokeBorder border, FT_Memory memory)
Definition: ftstroke.c:620

◆ FT_Stroker_ParseOutline()

FT_Stroker_ParseOutline ( FT_Stroker  stroker,
FT_Outline outline,
FT_Bool  opened 
)

Definition at line 2094 of file ftstroke.c.

2097  {
2098  FT_Vector v_last;
2099  FT_Vector v_control;
2100  FT_Vector v_start;
2101 
2102  FT_Vector* point;
2103  FT_Vector* limit;
2104  char* tags;
2105 
2106  FT_Error error;
2107 
2108  FT_Int n; /* index of contour in outline */
2109  FT_UInt first; /* index of first point in contour */
2110  FT_Int tag; /* current point's state */
2111 
2112 
2113  if ( !outline )
2114  return FT_THROW( Invalid_Outline );
2115 
2116  if ( !stroker )
2117  return FT_THROW( Invalid_Argument );
2118 
2119  FT_Stroker_Rewind( stroker );
2120 
2121  first = 0;
2122 
2123  for ( n = 0; n < outline->n_contours; n++ )
2124  {
2125  FT_UInt last; /* index of last point in contour */
2126 
2127 
2128  last = (FT_UInt)outline->contours[n];
2129  limit = outline->points + last;
2130 
2131  /* skip empty points; we don't stroke these */
2132  if ( last <= first )
2133  {
2134  first = last + 1;
2135  continue;
2136  }
2137 
2138  v_start = outline->points[first];
2139  v_last = outline->points[last];
2140 
2141  v_control = v_start;
2142 
2143  point = outline->points + first;
2144  tags = outline->tags + first;
2145  tag = FT_CURVE_TAG( tags[0] );
2146 
2147  /* A contour cannot start with a cubic control point! */
2148  if ( tag == FT_CURVE_TAG_CUBIC )
2149  goto Invalid_Outline;
2150 
2151  /* check first point to determine origin */
2152  if ( tag == FT_CURVE_TAG_CONIC )
2153  {
2154  /* First point is conic control. Yes, this happens. */
2155  if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
2156  {
2157  /* start at last point if it is on the curve */
2158  v_start = v_last;
2159  limit--;
2160  }
2161  else
2162  {
2163  /* if both first and last points are conic, */
2164  /* start at their middle */
2165  v_start.x = ( v_start.x + v_last.x ) / 2;
2166  v_start.y = ( v_start.y + v_last.y ) / 2;
2167  }
2168  point--;
2169  tags--;
2170  }
2171 
2172  error = FT_Stroker_BeginSubPath( stroker, &v_start, opened );
2173  if ( error )
2174  goto Exit;
2175 
2176  while ( point < limit )
2177  {
2178  point++;
2179  tags++;
2180 
2181  tag = FT_CURVE_TAG( tags[0] );
2182  switch ( tag )
2183  {
2184  case FT_CURVE_TAG_ON: /* emit a single line_to */
2185  {
2186  FT_Vector vec;
2187 
2188 
2189  vec.x = point->x;
2190  vec.y = point->y;
2191 
2192  error = FT_Stroker_LineTo( stroker, &vec );
2193  if ( error )
2194  goto Exit;
2195  continue;
2196  }
2197 
2198  case FT_CURVE_TAG_CONIC: /* consume conic arcs */
2199  v_control.x = point->x;
2200  v_control.y = point->y;
2201 
2202  Do_Conic:
2203  if ( point < limit )
2204  {
2205  FT_Vector vec;
2206  FT_Vector v_middle;
2207 
2208 
2209  point++;
2210  tags++;
2211  tag = FT_CURVE_TAG( tags[0] );
2212 
2213  vec = point[0];
2214 
2215  if ( tag == FT_CURVE_TAG_ON )
2216  {
2217  error = FT_Stroker_ConicTo( stroker, &v_control, &vec );
2218  if ( error )
2219  goto Exit;
2220  continue;
2221  }
2222 
2223  if ( tag != FT_CURVE_TAG_CONIC )
2224  goto Invalid_Outline;
2225 
2226  v_middle.x = ( v_control.x + vec.x ) / 2;
2227  v_middle.y = ( v_control.y + vec.y ) / 2;
2228 
2229  error = FT_Stroker_ConicTo( stroker, &v_control, &v_middle );
2230  if ( error )
2231  goto Exit;
2232 
2233  v_control = vec;
2234  goto Do_Conic;
2235  }
2236 
2237  error = FT_Stroker_ConicTo( stroker, &v_control, &v_start );
2238  goto Close;
2239 
2240  default: /* FT_CURVE_TAG_CUBIC */
2241  {
2242  FT_Vector vec1, vec2;
2243 
2244 
2245  if ( point + 1 > limit ||
2247  goto Invalid_Outline;
2248 
2249  point += 2;
2250  tags += 2;
2251 
2252  vec1 = point[-2];
2253  vec2 = point[-1];
2254 
2255  if ( point <= limit )
2256  {
2257  FT_Vector vec;
2258 
2259 
2260  vec = point[0];
2261 
2262  error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &vec );
2263  if ( error )
2264  goto Exit;
2265  continue;
2266  }
2267 
2268  error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &v_start );
2269  goto Close;
2270  }
2271  }
2272  }
2273 
2274  Close:
2275  if ( error )
2276  goto Exit;
2277 
2278  /* don't try to end the path if no segments have been generated */
2279  if ( !stroker->first_point )
2280  {
2281  error = FT_Stroker_EndSubPath( stroker );
2282  if ( error )
2283  goto Exit;
2284  }
2285 
2286  first = last + 1;
2287  }
2288 
2289  return FT_Err_Ok;
2290 
2291  Exit:
2292  return error;
2293 
2294  Invalid_Outline:
2295  return FT_THROW( Invalid_Outline );
2296  }
int FT_Error
Definition: fttypes.h:300
FT_Pos y
Definition: ftimage.h:77
const char * tags[7 *8]
Definition: apphelp.c:216
FT_Stroker_BeginSubPath(FT_Stroker stroker, FT_Vector *to, FT_Bool open)
Definition: ftstroke.c:1789
#define error(str)
Definition: mkdosfs.c:1605
FT_Pos x
Definition: ftimage.h:76
#define FT_CURVE_TAG_CUBIC
Definition: ftimage.h:455
POINT last
Definition: font.c:46
signed int FT_Int
Definition: fttypes.h:220
const GLint * first
Definition: glext.h:5794
GLdouble n
Definition: glext.h:7729
Definition: ecma_167.h:138
if(dx==0 &&dy==0)
Definition: linetemp.h:174
return FT_Err_Ok
Definition: ftbbox.c:511
POINTL point
Definition: edittest.c:50
LONG y
Definition: windef.h:330
GLint limit
Definition: glext.h:10326
FT_Stroker_Rewind(FT_Stroker stroker)
Definition: ftstroke.c:862
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_Stroker_LineTo(FT_Stroker stroker, FT_Vector *to)
Definition: ftstroke.c:1296
static void Exit(void)
Definition: sock.c:1331
FT_Stroker_ConicTo(FT_Stroker stroker, FT_Vector *control, FT_Vector *to)
Definition: ftstroke.c:1372
LONG x
Definition: windef.h:329
FT_Vector * vec
Definition: ftbbox.c:448
FT_Stroker_CubicTo(FT_Stroker stroker, FT_Vector *control1, FT_Vector *control2, FT_Vector *to)
Definition: ftstroke.c:1573
Definition: mesh.c:5329
Definition: sacdrv.h:267
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_CURVE_TAG_ON
Definition: ftimage.h:453
#define FT_CURVE_TAG_CONIC
Definition: ftimage.h:454
#define FT_CURVE_TAG(flag)
Definition: ftimage.h:451
FT_Stroker_EndSubPath(FT_Stroker stroker)
Definition: ftstroke.c:1891
char * tag
Definition: main.c:59

Referenced by FT_Glyph_Stroke(), and FT_Glyph_StrokeBorder().

◆ FT_Stroker_Rewind()

FT_Stroker_Rewind ( FT_Stroker  stroker)

Definition at line 862 of file ftstroke.c.

863  {
864  if ( stroker )
865  {
866  ft_stroke_border_reset( &stroker->borders[0] );
867  ft_stroke_border_reset( &stroker->borders[1] );
868  }
869  }
static void ft_stroke_border_reset(FT_StrokeBorder border)
Definition: ftstroke.c:635

Referenced by FT_Stroker_ParseOutline(), and FT_Stroker_Set().

◆ FT_Stroker_Set()

FT_Stroker_Set ( FT_Stroker  stroker,
FT_Fixed  radius,
FT_Stroker_LineCap  line_cap,
FT_Stroker_LineJoin  line_join,
FT_Fixed  miter_limit 
)

Definition at line 833 of file ftstroke.c.

838  {
839  if ( !stroker )
840  return;
841 
842  stroker->radius = radius;
843  stroker->line_cap = line_cap;
844  stroker->line_join = line_join;
845  stroker->miter_limit = miter_limit;
846 
847  /* ensure miter limit has sensible value */
848  if ( stroker->miter_limit < 0x10000L )
849  stroker->miter_limit = 0x10000L;
850 
851  /* save line join style: */
852  /* line join style can be temporarily changed when stroking curves */
853  stroker->line_join_saved = line_join;
854 
855  FT_Stroker_Rewind( stroker );
856  }
FT_Stroker_Rewind(FT_Stroker stroker)
Definition: ftstroke.c:862
static const WCHAR L[]
Definition: oid.c:1250