FT_Outline_Decompose() now returns FT_Error.
Minor bug fixes. More formatting, adding/fixing documentation.
This commit is contained in:
parent
a7b53c47fc
commit
d66ea312f6
|
@ -1911,11 +1911,11 @@
|
||||||
/* the state during the decomposition. */
|
/* the state during the decomposition. */
|
||||||
/* */
|
/* */
|
||||||
/* <Return> */
|
/* <Return> */
|
||||||
/* Error code. 0 means sucess. */
|
/* FreeType error code. 0 means sucess. */
|
||||||
/* */
|
/* */
|
||||||
FT_EXPORT_DEF(int) FT_Outline_Decompose( FT_Outline* outline,
|
FT_EXPORT_DEF(FT_Error) FT_Outline_Decompose( FT_Outline* outline,
|
||||||
FT_Outline_Funcs* funcs,
|
FT_Outline_Funcs* funcs,
|
||||||
void* user );
|
void* user );
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
|
@ -18,30 +18,27 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* This file can be compiled without the rest of the FreeType engine, */
|
/* This file can be compiled without the rest of the FreeType engine, */
|
||||||
/* by defining the _STANDALONE_ macro when compiling it. You also need */
|
/* by defining the _STANDALONE_ macro when compiling it. You also need */
|
||||||
/* to put the files "ftgrays.h" and "ftimage.h" in the current */
|
/* to put the files `ftgrays.h' and `ftimage.h' into the current */
|
||||||
/* compilation directory. Typically, you could do something like: */
|
/* compilation directory. Typically, you could do something like */
|
||||||
/* */
|
/* */
|
||||||
/* - copy "src/base/ftgrays.c" to your current directory */
|
/* - copy `src/base/ftgrays.c' to your current directory */
|
||||||
/* */
|
/* */
|
||||||
/* - copy "include/freetype/ftimage.h" and */
|
/* - copy `include/freetype/ftimage.h' and */
|
||||||
/* "include/freetype/ftgrays.h" to the same directory */
|
/* `include/freetype/ftgrays.h' to the same directory */
|
||||||
/* */
|
/* */
|
||||||
/* - compile the "ftgrays" with the _STANDALONE_ macro defined, as in: */
|
/* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */
|
||||||
/* */
|
/* */
|
||||||
/* cc -c -D_STANDALONE_ ftgrays.c */
|
/* cc -c -D_STANDALONE_ ftgrays.c */
|
||||||
/* */
|
/* */
|
||||||
/* - the renderer can be initialised with a call to: */
|
/* The renderer can be initialised with a call to */
|
||||||
|
/* `ft_grays_raster.grays_raster_new'; an anti-aliased bitmap can be */
|
||||||
|
/* generated with a call to `ft_grays_raster.grays_raster_render'. */
|
||||||
/* */
|
/* */
|
||||||
/* ft_grays_raster.init */
|
/* See the comments and documentation in the file `ftimage.h' for */
|
||||||
/* */
|
/* more details on how the raster works. */
|
||||||
/* - an anti-aliased bitmap can be generated with a call to: */
|
|
||||||
/* */
|
|
||||||
/* ft_grays_raster.render */
|
|
||||||
/* */
|
|
||||||
/* See the comments and documentation in the file "ftimage.h" for */
|
|
||||||
/* more details on how the raster works.. */
|
|
||||||
/* */
|
/* */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
|
@ -92,17 +89,20 @@
|
||||||
|
|
||||||
#include "ftimage.h"
|
#include "ftimage.h"
|
||||||
#include "ftgrays.h"
|
#include "ftgrays.h"
|
||||||
/* this macro is used to indicate that a function parameter is unused */
|
|
||||||
/* its purpose is simply to reduce compiler warnings. Note also that */
|
|
||||||
/* simply defining it as "(void)x" doesn't avoid warnings with certain */
|
|
||||||
/* ANSI compilers, like LCC */
|
|
||||||
#define UNUSED(x) (x)=(x)
|
|
||||||
|
|
||||||
#else
|
/* This macro is used to indicate that a function parameter is unused. */
|
||||||
|
/* Its purpose is simply to reduce compiler warnings. Note also that */
|
||||||
|
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
|
||||||
|
/* ANSI compilers (e.g. LCC). */
|
||||||
|
#define UNUSED( x ) (x) = (x)
|
||||||
|
|
||||||
|
#else /* _STANDALONE_ */
|
||||||
|
|
||||||
#include <freetype/ftgrays.h>
|
#include <freetype/ftgrays.h>
|
||||||
#include <freetype/internal/ftobjs.h> /* for UNUSED() */
|
#include <freetype/internal/ftobjs.h> /* for UNUSED() */
|
||||||
#include <freetype/freetype.h> /* to link to FT_Outline_Decompose() */
|
#include <freetype/freetype.h> /* to link to FT_Outline_Decompose() */
|
||||||
#endif
|
|
||||||
|
#endif /* _STANDALONE_ */
|
||||||
|
|
||||||
/* define this to dump debugging information */
|
/* define this to dump debugging information */
|
||||||
#define xxxDEBUG_GRAYS
|
#define xxxDEBUG_GRAYS
|
||||||
|
@ -325,8 +325,8 @@
|
||||||
/* Set the current cell to a new position. */
|
/* Set the current cell to a new position. */
|
||||||
/* */
|
/* */
|
||||||
static
|
static
|
||||||
int set_cell( RAS_ARG_ TScan ex,
|
int set_cell( RAS_ARG_ TScan ex,
|
||||||
TScan ey )
|
TScan ey )
|
||||||
{
|
{
|
||||||
int invalid, record, clean;
|
int invalid, record, clean;
|
||||||
|
|
||||||
|
@ -1234,7 +1234,7 @@
|
||||||
coverage = -coverage;
|
coverage = -coverage;
|
||||||
|
|
||||||
while ( coverage >= 512 )
|
while ( coverage >= 512 )
|
||||||
coverage = 512-coverage;
|
coverage = 512 - coverage;
|
||||||
|
|
||||||
if ( coverage > 256 )
|
if ( coverage > 256 )
|
||||||
coverage = 0;
|
coverage = 0;
|
||||||
|
@ -1369,7 +1369,8 @@
|
||||||
/* draw a gray span until the end of the clipping region */
|
/* draw a gray span until the end of the clipping region */
|
||||||
if ( cover && x < ras.max_ex - ras.min_ex )
|
if ( cover && x < ras.max_ex - ras.min_ex )
|
||||||
grays_hline( RAS_VAR_ x, y,
|
grays_hline( RAS_VAR_ x, y,
|
||||||
cover * ( ONE_PIXEL * 2 ), ras.max_ex - x - ras.min_ex );
|
cover * ( ONE_PIXEL * 2 ),
|
||||||
|
ras.max_ex - x - ras.min_ex );
|
||||||
cover = 0;
|
cover = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1402,38 +1403,62 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef _STANDALONE_
|
#ifdef _STANDALONE_
|
||||||
/************************************************************************
|
|
||||||
*
|
/*************************************************************************/
|
||||||
* The Following function should only compile in stand_alone mode,
|
/* */
|
||||||
* i.e. when building this component without the rest of FreeType.
|
/* The following function should only compile in stand_alone mode, */
|
||||||
*
|
/* i.e., when building this component without the rest of FreeType. */
|
||||||
*
|
/* */
|
||||||
*
|
/*************************************************************************/
|
||||||
*
|
|
||||||
*
|
/*************************************************************************/
|
||||||
*/
|
/* */
|
||||||
static int FT_Outline_Decompose( FT_Outline* outline,
|
/* <Function> */
|
||||||
FT_Outline_Funcs* interface,
|
/* FT_Outline_Decompose */
|
||||||
void* user )
|
/* */
|
||||||
|
/* <Description> */
|
||||||
|
/* Walks over an outline's structure to decompose it into individual */
|
||||||
|
/* segments and Bezier arcs. This function is also able to emit */
|
||||||
|
/* `move to' and `close to' operations to indicate the start and end */
|
||||||
|
/* of new contours in the outline. */
|
||||||
|
/* */
|
||||||
|
/* <Input> */
|
||||||
|
/* outline :: A pointer to the source target. */
|
||||||
|
/* */
|
||||||
|
/* interface :: A table of `emitters', i.e,. function pointers called */
|
||||||
|
/* during decomposition to indicate path operations. */
|
||||||
|
/* */
|
||||||
|
/* user :: A typeless pointer which is passed to each emitter */
|
||||||
|
/* during the decomposition. It can be used to store */
|
||||||
|
/* the state during the decomposition. */
|
||||||
|
/* */
|
||||||
|
/* <Return> */
|
||||||
|
/* Error code. 0 means sucess. */
|
||||||
|
/* */
|
||||||
|
static
|
||||||
|
int FT_Outline_Decompose( FT_Outline* outline,
|
||||||
|
FT_Outline_Funcs* interface,
|
||||||
|
void* user )
|
||||||
{
|
{
|
||||||
#undef SCALED
|
#undef SCALED
|
||||||
#define SCALED( x ) ( ((x) << shift) - delta )
|
#define SCALED( x ) ( ( (x) << shift ) - delta )
|
||||||
|
|
||||||
FT_Vector v_last;
|
FT_Vector v_last;
|
||||||
FT_Vector v_control;
|
FT_Vector v_control;
|
||||||
FT_Vector v_start;
|
FT_Vector v_start;
|
||||||
|
|
||||||
FT_Vector* point;
|
FT_Vector* point;
|
||||||
FT_Vector* limit;
|
FT_Vector* limit;
|
||||||
char* tags;
|
char* tags;
|
||||||
|
|
||||||
int n; /* index of contour in outline */
|
int n; /* index of contour in outline */
|
||||||
int first; /* index of first point in contour */
|
int first; /* index of first point in contour */
|
||||||
int error;
|
int error;
|
||||||
char tag; /* current point's state */
|
char tag; /* current point's state */
|
||||||
|
|
||||||
|
int shift = interface->shift;
|
||||||
|
FT_Pos delta = interface->delta;
|
||||||
|
|
||||||
int shift = interface->shift;
|
|
||||||
FT_Pos delta = interface->delta;
|
|
||||||
|
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
|
@ -1441,14 +1466,15 @@
|
||||||
{
|
{
|
||||||
int last; /* index of last point in contour */
|
int last; /* index of last point in contour */
|
||||||
|
|
||||||
|
|
||||||
last = outline->contours[n];
|
last = outline->contours[n];
|
||||||
limit = outline->points + last;
|
limit = outline->points + last;
|
||||||
|
|
||||||
v_start = outline->points[first];
|
v_start = outline->points[first];
|
||||||
v_last = outline->points[last];
|
v_last = outline->points[last];
|
||||||
|
|
||||||
v_start.x = SCALED(v_start.x); v_start.y = SCALED(v_start.y);
|
v_start.x = SCALED( v_start.x ); v_start.y = SCALED( v_start.y );
|
||||||
v_last.x = SCALED(v_last.x); v_last.y = SCALED(v_last.y);
|
v_last.x = SCALED( v_last.x ); v_last.y = SCALED( v_last.y );
|
||||||
|
|
||||||
v_control = v_start;
|
v_control = v_start;
|
||||||
|
|
||||||
|
@ -1485,100 +1511,108 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
error = interface->move_to( &v_start, user );
|
error = interface->move_to( &v_start, user );
|
||||||
if (error) goto Exit;
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
while (point < limit)
|
while ( point < limit )
|
||||||
{
|
{
|
||||||
point++;
|
point++;
|
||||||
tags++;
|
tags++;
|
||||||
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
tag = FT_CURVE_TAG( tags[0] );
|
||||||
switch (tag)
|
switch ( tag )
|
||||||
{
|
{
|
||||||
case FT_Curve_Tag_On: /* emit a single line_to */
|
case FT_Curve_Tag_On: /* emit a single line_to */
|
||||||
|
{
|
||||||
|
FT_Vector vec;
|
||||||
|
|
||||||
|
|
||||||
|
vec.x = SCALED( point->x );
|
||||||
|
vec.y = SCALED( point->y );
|
||||||
|
|
||||||
|
error = interface->line_to( &vec, user );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
||||||
|
{
|
||||||
|
v_control.x = SCALED( point->x );
|
||||||
|
v_control.y = SCALED( point->y );
|
||||||
|
|
||||||
|
Do_Conic:
|
||||||
|
if ( point < limit )
|
||||||
{
|
{
|
||||||
FT_Vector vec;
|
FT_Vector vec;
|
||||||
|
FT_Vector v_middle;
|
||||||
vec.x = SCALED(point->x);
|
|
||||||
vec.y = SCALED(point->y);
|
|
||||||
|
|
||||||
error = interface->line_to( &vec, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
point++;
|
||||||
{
|
tags++;
|
||||||
v_control.x = SCALED(point->x);
|
tag = FT_CURVE_TAG( tags[0] );
|
||||||
v_control.y = SCALED(point->y);
|
|
||||||
|
|
||||||
Do_Conic:
|
vec.x = SCALED( point->x );
|
||||||
if (point < limit)
|
vec.y = SCALED( point->y );
|
||||||
|
|
||||||
|
if ( tag == FT_Curve_Tag_On )
|
||||||
{
|
{
|
||||||
FT_Vector vec;
|
error = interface->conic_to( &v_control, &vec, user );
|
||||||
FT_Vector v_middle;
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
point++;
|
|
||||||
tags++;
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
|
||||||
|
|
||||||
vec.x = SCALED(point->x);
|
|
||||||
vec.y = SCALED(point->y);
|
|
||||||
|
|
||||||
if (tag == FT_Curve_Tag_On)
|
|
||||||
{
|
|
||||||
error = interface->conic_to( &v_control, &vec, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag != FT_Curve_Tag_Conic)
|
|
||||||
goto Invalid_Outline;
|
|
||||||
|
|
||||||
v_middle.x = (v_control.x + vec.x)/2;
|
|
||||||
v_middle.y = (v_control.y + vec.y)/2;
|
|
||||||
|
|
||||||
error = interface->conic_to( &v_control, &v_middle, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
|
|
||||||
v_control = vec;
|
|
||||||
goto Do_Conic;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = interface->conic_to( &v_control, &v_start, user );
|
|
||||||
goto Close;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: /* FT_Curve_Tag_Cubic */
|
|
||||||
{
|
|
||||||
FT_Vector vec1, vec2;
|
|
||||||
|
|
||||||
if ( point+1 > limit ||
|
|
||||||
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
|
||||||
goto Invalid_Outline;
|
|
||||||
|
|
||||||
point += 2;
|
|
||||||
tags += 2;
|
|
||||||
|
|
||||||
vec1.x = SCALED(point[-2].x); vec1.y = SCALED(point[-2].y);
|
|
||||||
vec2.x = SCALED(point[-1].x); vec2.y = SCALED(point[-1].y);
|
|
||||||
|
|
||||||
if (point <= limit)
|
|
||||||
{
|
|
||||||
FT_Vector vec;
|
|
||||||
|
|
||||||
vec.x = SCALED(point->x);
|
|
||||||
vec.y = SCALED(point->y);
|
|
||||||
|
|
||||||
error = interface->cubic_to( &vec1, &vec2, &vec, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = interface->cubic_to( &vec1, &vec2, &v_start, user );
|
if ( tag != FT_Curve_Tag_Conic )
|
||||||
goto Close;
|
goto Invalid_Outline;
|
||||||
|
|
||||||
|
v_middle.x = ( v_control.x + vec.x ) / 2;
|
||||||
|
v_middle.y = ( v_control.y + vec.y ) / 2;
|
||||||
|
|
||||||
|
error = interface->conic_to( &v_control, &v_middle, user );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
|
v_control = vec;
|
||||||
|
goto Do_Conic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error = interface->conic_to( &v_control, &v_start, user );
|
||||||
|
goto Close;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: /* FT_Curve_Tag_Cubic */
|
||||||
|
{
|
||||||
|
FT_Vector vec1, vec2;
|
||||||
|
|
||||||
|
|
||||||
|
if ( point + 1 > limit ||
|
||||||
|
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
||||||
|
goto Invalid_Outline;
|
||||||
|
|
||||||
|
point += 2;
|
||||||
|
tags += 2;
|
||||||
|
|
||||||
|
vec1.x = SCALED( point[-2].x ); vec1.y = SCALED( point[-2].y );
|
||||||
|
vec2.x = SCALED( point[-1].x ); vec2.y = SCALED( point[-1].y );
|
||||||
|
|
||||||
|
if ( point <= limit )
|
||||||
|
{
|
||||||
|
FT_Vector vec;
|
||||||
|
|
||||||
|
|
||||||
|
vec.x = SCALED( point->x );
|
||||||
|
vec.y = SCALED( point->y );
|
||||||
|
|
||||||
|
error = interface->cubic_to( &vec1, &vec2, &vec, user );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = interface->cubic_to( &vec1, &vec2, &v_start, user );
|
||||||
|
goto Close;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,25 +1620,24 @@
|
||||||
error = interface->line_to( &v_start, user );
|
error = interface->line_to( &v_start, user );
|
||||||
|
|
||||||
Close:
|
Close:
|
||||||
if (error) goto Exit;
|
if ( error )
|
||||||
first = last+1;
|
goto Exit;
|
||||||
|
|
||||||
|
first = last + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
Invalid_Outline:
|
Invalid_Outline:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _STANDALONE_ */
|
#endif /* _STANDALONE_ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct TBand_
|
typedef struct TBand_
|
||||||
{
|
{
|
||||||
FT_Pos min, max;
|
FT_Pos min, max;
|
||||||
|
@ -1795,8 +1828,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**** RASTER OBJECT CREATION : in standalone mode, we simply use *****/
|
/**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
|
||||||
/**** a static object .. *****/
|
/**** a static object. *****/
|
||||||
|
|
||||||
#ifdef _STANDALONE_
|
#ifdef _STANDALONE_
|
||||||
|
|
||||||
|
@ -1806,10 +1839,12 @@
|
||||||
{
|
{
|
||||||
static TRaster the_raster;
|
static TRaster the_raster;
|
||||||
|
|
||||||
UNUSED(memory);
|
UNUSED( memory );
|
||||||
|
|
||||||
|
|
||||||
*araster = (FT_Raster)&the_raster;
|
*araster = (FT_Raster)&the_raster;
|
||||||
memset( &the_raster, 0, sizeof(the_raster) );
|
memset( &the_raster, 0, sizeof ( the_raster ) );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1818,7 +1853,7 @@
|
||||||
void grays_raster_done( FT_Raster raster )
|
void grays_raster_done( FT_Raster raster )
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
(void)raster;
|
UNUSED( raster );
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* _STANDALONE_ */
|
#else /* _STANDALONE_ */
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* FreeType outline management (body). */
|
/* FreeType outline management (body). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 1996-1999 by */
|
/* Copyright 1996-2000 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of the FreeType project, and may only be used */
|
/* This file is part of the FreeType project, and may only be used */
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
static
|
static
|
||||||
const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
|
const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -52,36 +53,40 @@
|
||||||
/* the state during the decomposition. */
|
/* the state during the decomposition. */
|
||||||
/* */
|
/* */
|
||||||
/* <Return> */
|
/* <Return> */
|
||||||
/* Error code. 0 means sucess. */
|
/* FreeType error code. 0 means sucess. */
|
||||||
/* */
|
/* */
|
||||||
FT_EXPORT_FUNC(int) FT_Outline_Decompose( FT_Outline* outline,
|
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Decompose(
|
||||||
FT_Outline_Funcs* interface,
|
FT_Outline* outline,
|
||||||
void* user )
|
FT_Outline_Funcs* interface,
|
||||||
|
void* user )
|
||||||
{
|
{
|
||||||
#undef SCALED
|
#undef SCALED
|
||||||
#define SCALED( x ) ( ((x) << shift) - delta )
|
#define SCALED( x ) ( ( (x) << shift ) - delta )
|
||||||
|
|
||||||
FT_Vector v_last;
|
FT_Vector v_last;
|
||||||
FT_Vector v_control;
|
FT_Vector v_control;
|
||||||
FT_Vector v_start;
|
FT_Vector v_start;
|
||||||
|
|
||||||
FT_Vector* point;
|
FT_Vector* point;
|
||||||
FT_Vector* limit;
|
FT_Vector* limit;
|
||||||
char* tags;
|
char* tags;
|
||||||
|
|
||||||
int n; /* index of contour in outline */
|
FT_Error error;
|
||||||
int first; /* index of first point in contour */
|
|
||||||
int error;
|
FT_Int n; /* index of contour in outline */
|
||||||
char tag; /* current point's state */
|
FT_UInt first; /* index of first point in contour */
|
||||||
|
char tag; /* current point's state */
|
||||||
|
|
||||||
|
FT_Int shift = interface->shift;
|
||||||
|
FT_Pos delta = interface->delta;
|
||||||
|
|
||||||
int shift = interface->shift;
|
|
||||||
FT_Pos delta = interface->delta;
|
|
||||||
|
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
for ( n = 0; n < outline->n_contours; n++ )
|
for ( n = 0; n < outline->n_contours; n++ )
|
||||||
{
|
{
|
||||||
int last; /* index of last point in contour */
|
FT_Int last; /* index of last point in contour */
|
||||||
|
|
||||||
|
|
||||||
last = outline->contours[n];
|
last = outline->contours[n];
|
||||||
limit = outline->points + last;
|
limit = outline->points + last;
|
||||||
|
@ -89,8 +94,8 @@
|
||||||
v_start = outline->points[first];
|
v_start = outline->points[first];
|
||||||
v_last = outline->points[last];
|
v_last = outline->points[last];
|
||||||
|
|
||||||
v_start.x = SCALED(v_start.x); v_start.y = SCALED(v_start.y);
|
v_start.x = SCALED( v_start.x ); v_start.y = SCALED( v_start.y );
|
||||||
v_last.x = SCALED(v_last.x); v_last.y = SCALED(v_last.y);
|
v_last.x = SCALED( v_last.x ); v_last.y = SCALED( v_last.y );
|
||||||
|
|
||||||
v_control = v_start;
|
v_control = v_start;
|
||||||
|
|
||||||
|
@ -127,100 +132,108 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
error = interface->move_to( &v_start, user );
|
error = interface->move_to( &v_start, user );
|
||||||
if (error) goto Exit;
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
while (point < limit)
|
while ( point < limit )
|
||||||
{
|
{
|
||||||
point++;
|
point++;
|
||||||
tags++;
|
tags++;
|
||||||
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
tag = FT_CURVE_TAG( tags[0] );
|
||||||
switch (tag)
|
switch ( tag )
|
||||||
{
|
{
|
||||||
case FT_Curve_Tag_On: /* emit a single line_to */
|
case FT_Curve_Tag_On: /* emit a single line_to */
|
||||||
|
{
|
||||||
|
FT_Vector vec;
|
||||||
|
|
||||||
|
|
||||||
|
vec.x = SCALED( point->x );
|
||||||
|
vec.y = SCALED( point->y );
|
||||||
|
|
||||||
|
error = interface->line_to( &vec, user );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
||||||
|
{
|
||||||
|
v_control.x = SCALED( point->x );
|
||||||
|
v_control.y = SCALED( point->y );
|
||||||
|
|
||||||
|
Do_Conic:
|
||||||
|
if ( point < limit )
|
||||||
{
|
{
|
||||||
FT_Vector vec;
|
FT_Vector vec;
|
||||||
|
FT_Vector v_middle;
|
||||||
vec.x = SCALED(point->x);
|
|
||||||
vec.y = SCALED(point->y);
|
|
||||||
|
|
||||||
error = interface->line_to( &vec, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
point++;
|
||||||
{
|
tags++;
|
||||||
v_control.x = SCALED(point->x);
|
tag = FT_CURVE_TAG( tags[0] );
|
||||||
v_control.y = SCALED(point->y);
|
|
||||||
|
|
||||||
Do_Conic:
|
vec.x = SCALED( point->x );
|
||||||
if (point < limit)
|
vec.y = SCALED( point->y );
|
||||||
|
|
||||||
|
if ( tag == FT_Curve_Tag_On )
|
||||||
{
|
{
|
||||||
FT_Vector vec;
|
error = interface->conic_to( &v_control, &vec, user );
|
||||||
FT_Vector v_middle;
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
point++;
|
|
||||||
tags++;
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
|
||||||
|
|
||||||
vec.x = SCALED(point->x);
|
|
||||||
vec.y = SCALED(point->y);
|
|
||||||
|
|
||||||
if (tag == FT_Curve_Tag_On)
|
|
||||||
{
|
|
||||||
error = interface->conic_to( &v_control, &vec, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag != FT_Curve_Tag_Conic)
|
|
||||||
goto Invalid_Outline;
|
|
||||||
|
|
||||||
v_middle.x = (v_control.x + vec.x)/2;
|
|
||||||
v_middle.y = (v_control.y + vec.y)/2;
|
|
||||||
|
|
||||||
error = interface->conic_to( &v_control, &v_middle, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
|
|
||||||
v_control = vec;
|
|
||||||
goto Do_Conic;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = interface->conic_to( &v_control, &v_start, user );
|
|
||||||
goto Close;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: /* FT_Curve_Tag_Cubic */
|
|
||||||
{
|
|
||||||
FT_Vector vec1, vec2;
|
|
||||||
|
|
||||||
if ( point+1 > limit ||
|
|
||||||
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
|
||||||
goto Invalid_Outline;
|
|
||||||
|
|
||||||
point += 2;
|
|
||||||
tags += 2;
|
|
||||||
|
|
||||||
vec1.x = SCALED(point[-2].x); vec1.y = SCALED(point[-2].y);
|
|
||||||
vec2.x = SCALED(point[-1].x); vec2.y = SCALED(point[-1].y);
|
|
||||||
|
|
||||||
if (point <= limit)
|
|
||||||
{
|
|
||||||
FT_Vector vec;
|
|
||||||
|
|
||||||
vec.x = SCALED(point->x);
|
|
||||||
vec.y = SCALED(point->y);
|
|
||||||
|
|
||||||
error = interface->cubic_to( &vec1, &vec2, &vec, user );
|
|
||||||
if (error) goto Exit;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = interface->cubic_to( &vec1, &vec2, &v_start, user );
|
if ( tag != FT_Curve_Tag_Conic )
|
||||||
goto Close;
|
goto Invalid_Outline;
|
||||||
|
|
||||||
|
v_middle.x = ( v_control.x + vec.x ) / 2;
|
||||||
|
v_middle.y = ( v_control.y + vec.y ) / 2;
|
||||||
|
|
||||||
|
error = interface->conic_to( &v_control, &v_middle, user );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
|
v_control = vec;
|
||||||
|
goto Do_Conic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error = interface->conic_to( &v_control, &v_start, user );
|
||||||
|
goto Close;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: /* FT_Curve_Tag_Cubic */
|
||||||
|
{
|
||||||
|
FT_Vector vec1, vec2;
|
||||||
|
|
||||||
|
|
||||||
|
if ( point + 1 > limit ||
|
||||||
|
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
||||||
|
goto Invalid_Outline;
|
||||||
|
|
||||||
|
point += 2;
|
||||||
|
tags += 2;
|
||||||
|
|
||||||
|
vec1.x = SCALED( point[-2].x ); vec1.y = SCALED( point[-2].y );
|
||||||
|
vec2.x = SCALED( point[-1].x ); vec2.y = SCALED( point[-1].y );
|
||||||
|
|
||||||
|
if ( point <= limit )
|
||||||
|
{
|
||||||
|
FT_Vector vec;
|
||||||
|
|
||||||
|
|
||||||
|
vec.x = SCALED( point->x );
|
||||||
|
vec.y = SCALED( point->y );
|
||||||
|
|
||||||
|
error = interface->cubic_to( &vec1, &vec2, &vec, user );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = interface->cubic_to( &vec1, &vec2, &v_start, user );
|
||||||
|
goto Close;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,18 +241,22 @@
|
||||||
error = interface->line_to( &v_start, user );
|
error = interface->line_to( &v_start, user );
|
||||||
|
|
||||||
Close:
|
Close:
|
||||||
if (error) goto Exit;
|
if ( error )
|
||||||
first = last+1;
|
goto Exit;
|
||||||
|
|
||||||
|
first = last + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
Invalid_Outline:
|
Invalid_Outline:
|
||||||
return -1;
|
return FT_Err_Invalid_Outline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -251,12 +268,12 @@
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* library :: A handle to the library object from where the */
|
/* library :: A handle to the library object from where the */
|
||||||
/* outline is allocated. Note however that the new */
|
/* outline is allocated. Note however that the new */
|
||||||
/* outline will NOT necessarily be FREED when */
|
/* outline will NOT necessarily be FREED, when */
|
||||||
/* destroying the library, by FT_Done_FreeType(). */
|
/* destroying the library, by FT_Done_FreeType(). */
|
||||||
/* */
|
/* */
|
||||||
/* numPoints :: The maximum number of points within the outline. */
|
/* numPoints :: The maximal number of points within the outline. */
|
||||||
/* */
|
/* */
|
||||||
/* numContours :: The maximum number of contours within the outline. */
|
/* numContours :: The maximal number of contours within the outline. */
|
||||||
/* */
|
/* */
|
||||||
/* <Output> */
|
/* <Output> */
|
||||||
/* outline :: A handle to the new outline. NULL in case of */
|
/* outline :: A handle to the new outline. NULL in case of */
|
||||||
|
@ -270,14 +287,12 @@
|
||||||
/* */
|
/* */
|
||||||
/* <Note> */
|
/* <Note> */
|
||||||
/* The reason why this function takes a `library' parameter is simply */
|
/* The reason why this function takes a `library' parameter is simply */
|
||||||
/* to use the library's memory allocator. You can copy the source */
|
/* to use the library's memory allocator. */
|
||||||
/* code of this function, replacing allocations with `malloc()' if */
|
|
||||||
/* you want to control where the objects go. */
|
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(FT_Error) FT_Outline_New( FT_Library library,
|
BASE_FUNC( FT_Error ) FT_Outline_New( FT_Library library,
|
||||||
FT_UInt numPoints,
|
FT_UInt numPoints,
|
||||||
FT_Int numContours,
|
FT_Int numContours,
|
||||||
FT_Outline* outline )
|
FT_Outline* outline )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_Memory memory;
|
FT_Memory memory;
|
||||||
|
@ -290,13 +305,13 @@
|
||||||
memory = library->memory;
|
memory = library->memory;
|
||||||
|
|
||||||
if ( ALLOC_ARRAY( outline->points, numPoints * 2L, FT_Pos ) ||
|
if ( ALLOC_ARRAY( outline->points, numPoints * 2L, FT_Pos ) ||
|
||||||
ALLOC_ARRAY( outline->tags, numPoints, FT_Byte ) ||
|
ALLOC_ARRAY( outline->tags, numPoints, FT_Byte ) ||
|
||||||
ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
|
ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
outline->n_points = (FT_UShort)numPoints;
|
outline->n_points = (FT_UShort)numPoints;
|
||||||
outline->n_contours = (FT_Short)numContours;
|
outline->n_contours = (FT_Short)numContours;
|
||||||
outline->flags |= ft_outline_owner;
|
outline->flags |= ft_outline_owner;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
|
|
||||||
|
@ -333,15 +348,14 @@
|
||||||
/* descriptor will be released. */
|
/* descriptor will be released. */
|
||||||
/* */
|
/* */
|
||||||
/* The reason why this function takes an `outline' parameter is */
|
/* The reason why this function takes an `outline' parameter is */
|
||||||
/* simply to use FT_Alloc()/FT_Free(). You can copy the source code */
|
/* simply to use FT_Free(). */
|
||||||
/* of this function, replacing allocations with `malloc()' in your */
|
|
||||||
/* application if you want something simpler. */
|
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(FT_Error) FT_Outline_Done( FT_Library library,
|
BASE_FUNC( FT_Error ) FT_Outline_Done( FT_Library library,
|
||||||
FT_Outline* outline )
|
FT_Outline* outline )
|
||||||
{
|
{
|
||||||
FT_Memory memory = library->memory;
|
FT_Memory memory = library->memory;
|
||||||
|
|
||||||
|
|
||||||
if ( outline )
|
if ( outline )
|
||||||
{
|
{
|
||||||
if ( outline->flags & ft_outline_owner )
|
if ( outline->flags & ft_outline_owner )
|
||||||
|
@ -385,11 +399,12 @@
|
||||||
/* <MT-Note> */
|
/* <MT-Note> */
|
||||||
/* Yes. */
|
/* Yes. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(void) FT_Outline_Get_CBox( FT_Outline* outline,
|
BASE_FUNC( void ) FT_Outline_Get_CBox( FT_Outline* outline,
|
||||||
FT_BBox* cbox )
|
FT_BBox* cbox )
|
||||||
{
|
{
|
||||||
FT_Pos xMin, yMin, xMax, yMax;
|
FT_Pos xMin, yMin, xMax, yMax;
|
||||||
|
|
||||||
|
|
||||||
if ( outline && cbox )
|
if ( outline && cbox )
|
||||||
{
|
{
|
||||||
if ( outline->n_points == 0 )
|
if ( outline->n_points == 0 )
|
||||||
|
@ -404,6 +419,7 @@
|
||||||
FT_Vector* vec = outline->points;
|
FT_Vector* vec = outline->points;
|
||||||
FT_Vector* limit = vec + outline->n_points;
|
FT_Vector* limit = vec + outline->n_points;
|
||||||
|
|
||||||
|
|
||||||
xMin = xMax = vec->x;
|
xMin = xMax = vec->x;
|
||||||
yMin = yMax = vec->y;
|
yMin = yMax = vec->y;
|
||||||
vec++;
|
vec++;
|
||||||
|
@ -412,6 +428,7 @@
|
||||||
{
|
{
|
||||||
FT_Pos x, y;
|
FT_Pos x, y;
|
||||||
|
|
||||||
|
|
||||||
x = vec->x;
|
x = vec->x;
|
||||||
if ( x < xMin ) xMin = x;
|
if ( x < xMin ) xMin = x;
|
||||||
if ( x > xMax ) xMax = x;
|
if ( x > xMax ) xMax = x;
|
||||||
|
@ -440,19 +457,22 @@
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* outline :: A pointer to the target outline descriptor. */
|
/* outline :: A pointer to the target outline descriptor. */
|
||||||
|
/* */
|
||||||
/* xOffset :: The horizontal offset. */
|
/* xOffset :: The horizontal offset. */
|
||||||
|
/* */
|
||||||
/* yOffset :: The vertical offset. */
|
/* yOffset :: The vertical offset. */
|
||||||
/* */
|
/* */
|
||||||
/* <MT-Note> */
|
/* <MT-Note> */
|
||||||
/* Yes. */
|
/* Yes. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(void) FT_Outline_Translate( FT_Outline* outline,
|
BASE_FUNC( void ) FT_Outline_Translate( FT_Outline* outline,
|
||||||
FT_Pos xOffset,
|
FT_Pos xOffset,
|
||||||
FT_Pos yOffset )
|
FT_Pos yOffset )
|
||||||
{
|
{
|
||||||
FT_UShort n;
|
FT_UShort n;
|
||||||
FT_Vector* vec = outline->points;
|
FT_Vector* vec = outline->points;
|
||||||
|
|
||||||
|
|
||||||
for ( n = 0; n < outline->n_points; n++ )
|
for ( n = 0; n < outline->n_points; n++ )
|
||||||
{
|
{
|
||||||
vec->x += xOffset;
|
vec->x += xOffset;
|
||||||
|
@ -461,28 +481,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
/* FT_Outline_Reverse */
|
/* FT_Outline_Reverse */
|
||||||
/* */
|
/* */
|
||||||
/* <Description> */
|
/* <Description> */
|
||||||
/* Reverse the drawing direction of an outline. This is used to */
|
/* Reverses the drawing direction of an outline. This is used to */
|
||||||
/* ensure consistent fill conventions for mirrored glyphs.. */
|
/* ensure consistent fill conventions for mirrored glyphs. */
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* outline :: A pointer to the target outline descriptor. */
|
/* outline :: A pointer to the target outline descriptor. */
|
||||||
/* */
|
/* */
|
||||||
/* <Note> */
|
/* <Note> */
|
||||||
/* This functions toggles the bit flag ft_outline_reverse_fill in */
|
/* This functions toggles the bit flag `ft_outline_reverse_fill' in */
|
||||||
/* the outline's "flags" field.. */
|
/* the outline's `flags' field. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(void) FT_Outline_Reverse( FT_Outline* outline )
|
BASE_FUNC( void ) FT_Outline_Reverse( FT_Outline* outline )
|
||||||
{
|
{
|
||||||
FT_UShort n;
|
FT_UShort n;
|
||||||
FT_Int first, last;
|
FT_Int first, last;
|
||||||
|
|
||||||
|
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
for ( n = 0; n < outline->n_contours; n++ )
|
for ( n = 0; n < outline->n_contours; n++ )
|
||||||
{
|
{
|
||||||
last = outline->contours[n];
|
last = outline->contours[n];
|
||||||
|
@ -493,7 +516,8 @@
|
||||||
FT_Vector* q = outline->points + last;
|
FT_Vector* q = outline->points + last;
|
||||||
FT_Vector swap;
|
FT_Vector swap;
|
||||||
|
|
||||||
while (p < q)
|
|
||||||
|
while ( p < q )
|
||||||
{
|
{
|
||||||
swap = *p;
|
swap = *p;
|
||||||
*p = *q;
|
*p = *q;
|
||||||
|
@ -509,7 +533,7 @@
|
||||||
char* q = outline->tags + last;
|
char* q = outline->tags + last;
|
||||||
char swap;
|
char swap;
|
||||||
|
|
||||||
while (p < q)
|
while ( p < q )
|
||||||
{
|
{
|
||||||
swap = *p;
|
swap = *p;
|
||||||
*p = *q;
|
*p = *q;
|
||||||
|
@ -519,11 +543,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
first = last+1;
|
first = last + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
outline->flags ^= ft_outline_reverse_fill;
|
outline->flags ^= ft_outline_reverse_fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -533,12 +559,13 @@
|
||||||
/* Deallocates a glyph zone. */
|
/* Deallocates a glyph zone. */
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* zone :: pointer to the target glyph zone. */
|
/* zone :: A pointer to the target glyph zone. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(void) FT_Done_GlyphZone( FT_GlyphZone* zone )
|
BASE_FUNC( void ) FT_Done_GlyphZone( FT_GlyphZone* zone )
|
||||||
{
|
{
|
||||||
FT_Memory memory = zone->memory;
|
FT_Memory memory = zone->memory;
|
||||||
|
|
||||||
|
|
||||||
FREE( zone->contours );
|
FREE( zone->contours );
|
||||||
FREE( zone->tags );
|
FREE( zone->tags );
|
||||||
FREE( zone->cur );
|
FREE( zone->cur );
|
||||||
|
@ -548,6 +575,7 @@
|
||||||
zone->max_contours = zone->n_contours = 0;
|
zone->max_contours = zone->n_contours = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -569,29 +597,32 @@
|
||||||
/* <Return> */
|
/* <Return> */
|
||||||
/* FreeType error code. 0 means success. */
|
/* FreeType error code. 0 means success. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(FT_Error) FT_New_GlyphZone( FT_Memory memory,
|
BASE_FUNC( FT_Error ) FT_New_GlyphZone( FT_Memory memory,
|
||||||
FT_UShort maxPoints,
|
FT_UShort maxPoints,
|
||||||
FT_Short maxContours,
|
FT_Short maxContours,
|
||||||
FT_GlyphZone* zone )
|
FT_GlyphZone* zone )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
|
||||||
if (maxPoints > 0)
|
|
||||||
|
if ( maxPoints > 0 )
|
||||||
maxPoints += 2;
|
maxPoints += 2;
|
||||||
|
|
||||||
MEM_Set( zone, 0, sizeof(*zone) );
|
MEM_Set( zone, 0, sizeof ( *zone ) );
|
||||||
zone->memory = memory;
|
zone->memory = memory;
|
||||||
|
|
||||||
if ( ALLOC_ARRAY( zone->org, maxPoints*2, FT_F26Dot6 ) ||
|
if ( ALLOC_ARRAY( zone->org, maxPoints * 2, FT_F26Dot6 ) ||
|
||||||
ALLOC_ARRAY( zone->cur, maxPoints*2, FT_F26Dot6 ) ||
|
ALLOC_ARRAY( zone->cur, maxPoints * 2, FT_F26Dot6 ) ||
|
||||||
ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
|
ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
|
||||||
ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
|
ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
|
||||||
{
|
{
|
||||||
FT_Done_GlyphZone(zone);
|
FT_Done_GlyphZone( zone );
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -609,26 +640,25 @@
|
||||||
/* <InOut> */
|
/* <InOut> */
|
||||||
/* zone :: The address of the target zone. */
|
/* zone :: The address of the target zone. */
|
||||||
/* */
|
/* */
|
||||||
/* maxPoints :: The address of the zone's current capacity for */
|
BASE_FUNC( FT_Error ) FT_Update_GlyphZone( FT_GlyphZone* zone,
|
||||||
/* points. */
|
FT_UShort newPoints,
|
||||||
/* */
|
FT_Short newContours )
|
||||||
/* maxContours :: The address of the zone's current capacity for */
|
|
||||||
/* contours. */
|
|
||||||
/* */
|
|
||||||
BASE_FUNC(FT_Error) FT_Update_GlyphZone( FT_GlyphZone* zone,
|
|
||||||
FT_UShort newPoints,
|
|
||||||
FT_Short newContours )
|
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
FT_Memory memory = zone->memory;
|
FT_Memory memory = zone->memory;
|
||||||
|
|
||||||
|
|
||||||
newPoints += 2;
|
newPoints += 2;
|
||||||
|
|
||||||
if ( zone->max_points < newPoints )
|
if ( zone->max_points < newPoints )
|
||||||
{
|
{
|
||||||
/* reallocate the points arrays */
|
/* reallocate the points arrays */
|
||||||
if ( REALLOC_ARRAY( zone->org, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
|
if ( REALLOC_ARRAY( zone->org, zone->max_points * 2,
|
||||||
REALLOC_ARRAY( zone->cur, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
|
newPoints * 2, FT_F26Dot6 ) ||
|
||||||
REALLOC_ARRAY( zone->tags, zone->max_points*2, newPoints, FT_Byte ) )
|
REALLOC_ARRAY( zone->cur, zone->max_points * 2,
|
||||||
|
newPoints * 2, FT_F26Dot6 ) ||
|
||||||
|
REALLOC_ARRAY( zone->tags, zone->max_points * 2,
|
||||||
|
newPoints, FT_Byte ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
zone->max_points = newPoints;
|
zone->max_points = newPoints;
|
||||||
|
@ -637,15 +667,18 @@
|
||||||
if ( zone->max_contours < newContours )
|
if ( zone->max_contours < newContours )
|
||||||
{
|
{
|
||||||
/* reallocate the contours array */
|
/* reallocate the contours array */
|
||||||
if ( REALLOC_ARRAY( zone->contours, zone->max_contours, newContours, FT_UShort ) )
|
if ( REALLOC_ARRAY( zone->contours, zone->max_contours,
|
||||||
|
newContours, FT_UShort ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
zone->max_contours = newContours;
|
zone->max_contours = newContours;
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -653,12 +686,13 @@
|
||||||
/* */
|
/* */
|
||||||
/* <Description> */
|
/* <Description> */
|
||||||
/* Renders an outline within a bitmap. The outline's image is simply */
|
/* Renders an outline within a bitmap. The outline's image is simply */
|
||||||
/* or-ed to the target bitmap. */
|
/* OR-ed to the target bitmap. */
|
||||||
/* */
|
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* library :: A handle to a FreeType library object. */
|
/* library :: A handle to a FreeType library object. */
|
||||||
|
/* */
|
||||||
/* outline :: A pointer to the source outline descriptor. */
|
/* outline :: A pointer to the source outline descriptor. */
|
||||||
|
/* */
|
||||||
/* map :: A pointer to the target bitmap descriptor. */
|
/* map :: A pointer to the target bitmap descriptor. */
|
||||||
/* */
|
/* */
|
||||||
/* <Return> */
|
/* <Return> */
|
||||||
|
@ -674,45 +708,52 @@
|
||||||
/* */
|
/* */
|
||||||
/* It will use the raster correponding to the default glyph format. */
|
/* It will use the raster correponding to the default glyph format. */
|
||||||
/* */
|
/* */
|
||||||
FT_EXPORT_FUNC(FT_Error) FT_Outline_Get_Bitmap( FT_Library library,
|
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library,
|
||||||
FT_Outline* outline,
|
FT_Outline* outline,
|
||||||
FT_Bitmap* bitmap )
|
FT_Bitmap* bitmap )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_Raster raster;
|
FT_Raster raster;
|
||||||
FT_Raster_Funcs funcs;
|
FT_Raster_Funcs funcs;
|
||||||
FT_Raster_Params params;
|
FT_Raster_Params params;
|
||||||
|
|
||||||
|
|
||||||
error = FT_Err_Invalid_Glyph_Format;
|
error = FT_Err_Invalid_Glyph_Format;
|
||||||
raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
|
raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
|
||||||
if (!raster) goto Exit;
|
if ( !raster )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
params.target = bitmap;
|
params.target = bitmap;
|
||||||
params.source = outline;
|
params.source = outline;
|
||||||
params.flags = 0;
|
params.flags = 0;
|
||||||
if (bitmap->pixel_mode == ft_pixel_mode_grays)
|
|
||||||
|
if ( bitmap->pixel_mode == ft_pixel_mode_grays )
|
||||||
params.flags |= ft_raster_flag_aa;
|
params.flags |= ft_raster_flag_aa;
|
||||||
|
|
||||||
error = funcs.raster_render( raster, ¶ms );
|
error = funcs.raster_render( raster, ¶ms );
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
/* FT_Outline_Render */
|
/* FT_Outline_Render */
|
||||||
/* */
|
/* */
|
||||||
/* <Description> */
|
/* <Description> */
|
||||||
/* Renders an outline within a bitmap using the current scan-convert */
|
/* Renders an outline within a bitmap using the current scan-convert. */
|
||||||
/* This functions uses a FT_Raster_Params as argument, allowing */
|
/* This functions uses a FT_Raster_Params as argument, allowing */
|
||||||
/* advanced features like direct composition/translucency, etc.. */
|
/* advanced features like direct composition/translucency, etc. */
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* library :: A handle to a FreeType library object. */
|
/* library :: A handle to a FreeType library object. */
|
||||||
|
/* */
|
||||||
/* outline :: A pointer to the source outline descriptor. */
|
/* outline :: A pointer to the source outline descriptor. */
|
||||||
|
/* */
|
||||||
/* params :: A pointer to a FT_Raster_Params used to describe */
|
/* params :: A pointer to a FT_Raster_Params used to describe */
|
||||||
/* the rendering operation */
|
/* the rendering operation. */
|
||||||
/* */
|
/* */
|
||||||
/* <Return> */
|
/* <Return> */
|
||||||
/* FreeType error code. 0 means success. */
|
/* FreeType error code. 0 means success. */
|
||||||
|
@ -725,24 +766,27 @@
|
||||||
/* You should know what you're doing and the role of FT_Raster_Params */
|
/* You should know what you're doing and the role of FT_Raster_Params */
|
||||||
/* to use this function. */
|
/* to use this function. */
|
||||||
/* */
|
/* */
|
||||||
/* the field "params.source" will be set to "outline" before the */
|
/* The field `params.source' will be set to `outline' before the scan */
|
||||||
/* scan converter is called, which means that the value you give it */
|
/* converter is called, which means that the value you give to it is */
|
||||||
/* is actually ignored.. */
|
/* actually ignored. */
|
||||||
/* */
|
/* */
|
||||||
FT_EXPORT_FUNC(FT_Error) FT_Outline_Render( FT_Library library,
|
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Render( FT_Library library,
|
||||||
FT_Outline* outline,
|
FT_Outline* outline,
|
||||||
FT_Raster_Params* params )
|
FT_Raster_Params* params )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_Raster raster;
|
FT_Raster raster;
|
||||||
FT_Raster_Funcs funcs;
|
FT_Raster_Funcs funcs;
|
||||||
|
|
||||||
|
|
||||||
error = FT_Err_Invalid_Glyph_Format;
|
error = FT_Err_Invalid_Glyph_Format;
|
||||||
raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
|
raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
|
||||||
if (!raster) goto Exit;
|
if ( !raster )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
params->source = (void*)outline;
|
params->source = (void*)outline;
|
||||||
error = funcs.raster_render( raster, params );
|
error = funcs.raster_render( raster, params );
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -759,6 +803,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* outline :: A pointer to the target outline descriptor. */
|
/* outline :: A pointer to the target outline descriptor. */
|
||||||
|
/* */
|
||||||
/* matrix :: A pointer to the transformation matrix. */
|
/* matrix :: A pointer to the transformation matrix. */
|
||||||
/* */
|
/* */
|
||||||
/* <MT-Note> */
|
/* <MT-Note> */
|
||||||
|
@ -768,17 +813,19 @@
|
||||||
/* You can use FT_Outline_Translate() if you need to translate the */
|
/* You can use FT_Outline_Translate() if you need to translate the */
|
||||||
/* outline's points. */
|
/* outline's points. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(void) FT_Outline_Transform( FT_Outline* outline,
|
BASE_FUNC( void ) FT_Outline_Transform( FT_Outline* outline,
|
||||||
FT_Matrix* matrix )
|
FT_Matrix* matrix )
|
||||||
{
|
{
|
||||||
FT_UShort n;
|
FT_UShort n;
|
||||||
FT_Vector* vec;
|
FT_Vector* vec;
|
||||||
|
|
||||||
|
|
||||||
vec = outline->points;
|
vec = outline->points;
|
||||||
for ( n = 0; n < outline->n_points; n++ )
|
for ( n = 0; n < outline->n_points; n++ )
|
||||||
{
|
{
|
||||||
FT_Pos x, y;
|
FT_Pos x, y;
|
||||||
|
|
||||||
|
|
||||||
x = FT_MulFix( vec->x, matrix->xx ) +
|
x = FT_MulFix( vec->x, matrix->xx ) +
|
||||||
FT_MulFix( vec->y, matrix->xy );
|
FT_MulFix( vec->y, matrix->xy );
|
||||||
|
|
||||||
|
@ -792,25 +839,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/**** ****/
|
/**** ****/
|
||||||
/**** The following functions are not used by the font drivers ****/
|
/**** The following functions are not used by the font drivers ****/
|
||||||
/**** but they are provided as a convenience for client apps. ****/
|
/**** but they are provided as a convenience for client ****/
|
||||||
|
/**** applications. ****/
|
||||||
/**** ****/
|
/**** ****/
|
||||||
/**** Note that they will not be compiled if the configuration ****/
|
/**** Note that they will not be compiled if the configuration ****/
|
||||||
/**** macro FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS is defined ****/
|
/**** macro FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS is defined. ****/
|
||||||
/**** ****/
|
/**** ****/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
|
#ifndef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -823,16 +870,19 @@
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* source :: A handle to the source outline. */
|
/* source :: A handle to the source outline. */
|
||||||
|
/* */
|
||||||
|
/* <Output> */
|
||||||
/* target :: A handle to the target outline. */
|
/* target :: A handle to the target outline. */
|
||||||
/* */
|
/* */
|
||||||
/* <Return> */
|
/* <Return> */
|
||||||
/* FreeType error code. 0 means success. */
|
/* FreeType error code. 0 means success. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(FT_Error) FT_Outline_Copy( FT_Outline* source,
|
BASE_FUNC( FT_Error ) FT_Outline_Copy( FT_Outline* source,
|
||||||
FT_Outline* target )
|
FT_Outline* target )
|
||||||
{
|
{
|
||||||
FT_Int is_owner;
|
FT_Int is_owner;
|
||||||
|
|
||||||
|
|
||||||
if ( !source || !target ||
|
if ( !source || !target ||
|
||||||
source->n_points != target->n_points ||
|
source->n_points != target->n_points ||
|
||||||
source->n_contours != target->n_contours )
|
source->n_contours != target->n_contours )
|
||||||
|
@ -847,12 +897,13 @@
|
||||||
MEM_Copy( target->contours, source->contours,
|
MEM_Copy( target->contours, source->contours,
|
||||||
source->n_contours * sizeof ( FT_Short ) );
|
source->n_contours * sizeof ( FT_Short ) );
|
||||||
|
|
||||||
/* copy all flags, except the "ft_outline_owner" one */
|
/* copy all flags, except the `ft_outline_owner' one */
|
||||||
is_owner = target->flags & ft_outline_owner;
|
is_owner = target->flags & ft_outline_owner;
|
||||||
target->flags = source->flags;
|
target->flags = source->flags;
|
||||||
|
|
||||||
target->flags &= ~ft_outline_owner;
|
target->flags &= ~ft_outline_owner;
|
||||||
target->flags |= is_owner;
|
target->flags |= is_owner;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,7 +917,7 @@
|
||||||
/* Transforms a single vector through a 2x2 matrix. */
|
/* Transforms a single vector through a 2x2 matrix. */
|
||||||
/* */
|
/* */
|
||||||
/* <InOut> */
|
/* <InOut> */
|
||||||
/* vector :: The target vector to transform */
|
/* vector :: The target vector to transform. */
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* matrix :: A pointer to the source 2x2 matrix. */
|
/* matrix :: A pointer to the source 2x2 matrix. */
|
||||||
|
@ -874,11 +925,12 @@
|
||||||
/* <MT-Note> */
|
/* <MT-Note> */
|
||||||
/* Yes. */
|
/* Yes. */
|
||||||
/* */
|
/* */
|
||||||
FT_EXPORT_FUNC(void) FT_Vector_Transform( FT_Vector* vector,
|
FT_EXPORT_FUNC( void ) FT_Vector_Transform( FT_Vector* vector,
|
||||||
FT_Matrix* matrix )
|
FT_Matrix* matrix )
|
||||||
{
|
{
|
||||||
FT_Pos xz, yz;
|
FT_Pos xz, yz;
|
||||||
|
|
||||||
|
|
||||||
xz = FT_MulFix( vector->x, matrix->xx ) +
|
xz = FT_MulFix( vector->x, matrix->xx ) +
|
||||||
FT_MulFix( vector->y, matrix->xy );
|
FT_MulFix( vector->y, matrix->xy );
|
||||||
|
|
||||||
|
@ -907,8 +959,8 @@
|
||||||
/* <MT-Note> */
|
/* <MT-Note> */
|
||||||
/* Yes. */
|
/* Yes. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(void) FT_Matrix_Multiply( FT_Matrix* a,
|
BASE_FUNC( void ) FT_Matrix_Multiply( FT_Matrix* a,
|
||||||
FT_Matrix* b )
|
FT_Matrix* b )
|
||||||
{
|
{
|
||||||
FT_Fixed xx, xy, yx, yy;
|
FT_Fixed xx, xy, yx, yy;
|
||||||
|
|
||||||
|
@ -941,7 +993,7 @@
|
||||||
/* <MT-Note> */
|
/* <MT-Note> */
|
||||||
/* Yes. */
|
/* Yes. */
|
||||||
/* */
|
/* */
|
||||||
BASE_FUNC(FT_Error) FT_Matrix_Invert( FT_Matrix* matrix )
|
BASE_FUNC( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix )
|
||||||
{
|
{
|
||||||
FT_Pos delta, xx, yy;
|
FT_Pos delta, xx, yy;
|
||||||
|
|
||||||
|
@ -965,6 +1017,7 @@
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS */
|
||||||
|
|
||||||
|
|
||||||
/* END */
|
/* END */
|
||||||
|
|
1938
src/base/ftraster.c
1938
src/base/ftraster.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue