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,9 +1911,9 @@
|
|||
/* the state during the decomposition. */
|
||||
/* */
|
||||
/* <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,
|
||||
void* user );
|
||||
|
||||
|
|
|
@ -19,29 +19,26 @@
|
|||
/* */
|
||||
/* This file can be compiled without the rest of the FreeType engine, */
|
||||
/* by defining the _STANDALONE_ macro when compiling it. You also need */
|
||||
/* to put the files "ftgrays.h" and "ftimage.h" in the current */
|
||||
/* compilation directory. Typically, you could do something like: */
|
||||
/* to put the files `ftgrays.h' and `ftimage.h' into the current */
|
||||
/* 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 */
|
||||
/* "include/freetype/ftgrays.h" to the same directory */
|
||||
/* - copy `include/freetype/ftimage.h' and */
|
||||
/* `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 */
|
||||
/* */
|
||||
/* - 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 */
|
||||
/* */
|
||||
/* - 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.. */
|
||||
/* 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 "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 */
|
||||
|
||||
/* 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
|
||||
#else /* _STANDALONE_ */
|
||||
|
||||
#include <freetype/ftgrays.h>
|
||||
#include <freetype/internal/ftobjs.h> /* for UNUSED() */
|
||||
#include <freetype/freetype.h> /* to link to FT_Outline_Decompose() */
|
||||
#endif
|
||||
|
||||
#endif /* _STANDALONE_ */
|
||||
|
||||
/* define this to dump debugging information */
|
||||
#define xxxDEBUG_GRAYS
|
||||
|
@ -1369,7 +1369,8 @@
|
|||
/* draw a gray span until the end of the clipping region */
|
||||
if ( cover && x < ras.max_ex - ras.min_ex )
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1402,17 +1403,40 @@
|
|||
|
||||
|
||||
#ifdef _STANDALONE_
|
||||
/************************************************************************
|
||||
*
|
||||
* 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,
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The following function should only compile in stand_alone mode, */
|
||||
/* i.e., when building this component without the rest of FreeType. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Decompose */
|
||||
/* */
|
||||
/* <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 )
|
||||
{
|
||||
|
@ -1435,12 +1459,14 @@
|
|||
int shift = interface->shift;
|
||||
FT_Pos delta = interface->delta;
|
||||
|
||||
|
||||
first = 0;
|
||||
|
||||
for ( n = 0; n < outline->n_contours; n++ )
|
||||
{
|
||||
int last; /* index of last point in contour */
|
||||
|
||||
|
||||
last = outline->contours[n];
|
||||
limit = outline->points + last;
|
||||
|
||||
|
@ -1485,7 +1511,8 @@
|
|||
}
|
||||
|
||||
error = interface->move_to( &v_start, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
while ( point < limit )
|
||||
{
|
||||
|
@ -1499,15 +1526,16 @@
|
|||
{
|
||||
FT_Vector vec;
|
||||
|
||||
|
||||
vec.x = SCALED( point->x );
|
||||
vec.y = SCALED( point->y );
|
||||
|
||||
error = interface->line_to( &vec, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
||||
{
|
||||
v_control.x = SCALED( point->x );
|
||||
|
@ -1519,6 +1547,7 @@
|
|||
FT_Vector vec;
|
||||
FT_Vector v_middle;
|
||||
|
||||
|
||||
point++;
|
||||
tags++;
|
||||
tag = FT_CURVE_TAG( tags[0] );
|
||||
|
@ -1529,7 +1558,8 @@
|
|||
if ( tag == FT_Curve_Tag_On )
|
||||
{
|
||||
error = interface->conic_to( &v_control, &vec, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1540,7 +1570,8 @@
|
|||
v_middle.y = ( v_control.y + vec.y ) / 2;
|
||||
|
||||
error = interface->conic_to( &v_control, &v_middle, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
v_control = vec;
|
||||
goto Do_Conic;
|
||||
|
@ -1554,6 +1585,7 @@
|
|||
{
|
||||
FT_Vector vec1, vec2;
|
||||
|
||||
|
||||
if ( point + 1 > limit ||
|
||||
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
||||
goto Invalid_Outline;
|
||||
|
@ -1568,11 +1600,13 @@
|
|||
{
|
||||
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;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1586,25 +1620,24 @@
|
|||
error = interface->line_to( &v_start, user );
|
||||
|
||||
Close:
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
first = last + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Invalid_Outline:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* _STANDALONE_ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct TBand_
|
||||
{
|
||||
FT_Pos min, max;
|
||||
|
@ -1795,8 +1828,8 @@
|
|||
}
|
||||
|
||||
|
||||
/**** RASTER OBJECT CREATION : in standalone mode, we simply use *****/
|
||||
/**** a static object .. *****/
|
||||
/**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
|
||||
/**** a static object. *****/
|
||||
|
||||
#ifdef _STANDALONE_
|
||||
|
||||
|
@ -1808,8 +1841,10 @@
|
|||
|
||||
UNUSED( memory );
|
||||
|
||||
|
||||
*araster = (FT_Raster)&the_raster;
|
||||
memset( &the_raster, 0, sizeof ( the_raster ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1818,7 +1853,7 @@
|
|||
void grays_raster_done( FT_Raster raster )
|
||||
{
|
||||
/* nothing */
|
||||
(void)raster;
|
||||
UNUSED( raster );
|
||||
}
|
||||
|
||||
#else /* _STANDALONE_ */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType outline management (body). */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used */
|
||||
|
@ -30,6 +30,7 @@
|
|||
static
|
||||
const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -52,9 +53,10 @@
|
|||
/* the state during the decomposition. */
|
||||
/* */
|
||||
/* <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* outline,
|
||||
FT_Outline_Funcs* interface,
|
||||
void* user )
|
||||
{
|
||||
|
@ -69,19 +71,22 @@
|
|||
FT_Vector* limit;
|
||||
char* tags;
|
||||
|
||||
int n; /* index of contour in outline */
|
||||
int first; /* index of first point in contour */
|
||||
int error;
|
||||
FT_Error error;
|
||||
|
||||
FT_Int n; /* index of contour in outline */
|
||||
FT_UInt first; /* index of first point in contour */
|
||||
char tag; /* current point's state */
|
||||
|
||||
int shift = interface->shift;
|
||||
FT_Int shift = interface->shift;
|
||||
FT_Pos delta = interface->delta;
|
||||
|
||||
|
||||
first = 0;
|
||||
|
||||
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];
|
||||
limit = outline->points + last;
|
||||
|
@ -127,7 +132,8 @@
|
|||
}
|
||||
|
||||
error = interface->move_to( &v_start, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
while ( point < limit )
|
||||
{
|
||||
|
@ -141,15 +147,16 @@
|
|||
{
|
||||
FT_Vector vec;
|
||||
|
||||
|
||||
vec.x = SCALED( point->x );
|
||||
vec.y = SCALED( point->y );
|
||||
|
||||
error = interface->line_to( &vec, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
||||
{
|
||||
v_control.x = SCALED( point->x );
|
||||
|
@ -161,6 +168,7 @@
|
|||
FT_Vector vec;
|
||||
FT_Vector v_middle;
|
||||
|
||||
|
||||
point++;
|
||||
tags++;
|
||||
tag = FT_CURVE_TAG( tags[0] );
|
||||
|
@ -171,7 +179,8 @@
|
|||
if ( tag == FT_Curve_Tag_On )
|
||||
{
|
||||
error = interface->conic_to( &v_control, &vec, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -182,7 +191,8 @@
|
|||
v_middle.y = ( v_control.y + vec.y ) / 2;
|
||||
|
||||
error = interface->conic_to( &v_control, &v_middle, user );
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
v_control = vec;
|
||||
goto Do_Conic;
|
||||
|
@ -196,6 +206,7 @@
|
|||
{
|
||||
FT_Vector vec1, vec2;
|
||||
|
||||
|
||||
if ( point + 1 > limit ||
|
||||
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
||||
goto Invalid_Outline;
|
||||
|
@ -210,11 +221,13 @@
|
|||
{
|
||||
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;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -228,18 +241,22 @@
|
|||
error = interface->line_to( &v_start, user );
|
||||
|
||||
Close:
|
||||
if (error) goto Exit;
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
first = last + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Invalid_Outline:
|
||||
return -1;
|
||||
return FT_Err_Invalid_Outline;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -251,12 +268,12 @@
|
|||
/* <Input> */
|
||||
/* library :: A handle to the library object from where the */
|
||||
/* 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(). */
|
||||
/* */
|
||||
/* 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> */
|
||||
/* outline :: A handle to the new outline. NULL in case of */
|
||||
|
@ -270,9 +287,7 @@
|
|||
/* */
|
||||
/* <Note> */
|
||||
/* The reason why this function takes a `library' parameter is simply */
|
||||
/* to use the library's memory allocator. You can copy the source */
|
||||
/* code of this function, replacing allocations with `malloc()' if */
|
||||
/* you want to control where the objects go. */
|
||||
/* to use the library's memory allocator. */
|
||||
/* */
|
||||
BASE_FUNC( FT_Error ) FT_Outline_New( FT_Library library,
|
||||
FT_UInt numPoints,
|
||||
|
@ -333,15 +348,14 @@
|
|||
/* descriptor will be released. */
|
||||
/* */
|
||||
/* The reason why this function takes an `outline' parameter is */
|
||||
/* simply to use FT_Alloc()/FT_Free(). You can copy the source code */
|
||||
/* of this function, replacing allocations with `malloc()' in your */
|
||||
/* application if you want something simpler. */
|
||||
/* simply to use FT_Free(). */
|
||||
/* */
|
||||
BASE_FUNC( FT_Error ) FT_Outline_Done( FT_Library library,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
FT_Memory memory = library->memory;
|
||||
|
||||
|
||||
if ( outline )
|
||||
{
|
||||
if ( outline->flags & ft_outline_owner )
|
||||
|
@ -390,6 +404,7 @@
|
|||
{
|
||||
FT_Pos xMin, yMin, xMax, yMax;
|
||||
|
||||
|
||||
if ( outline && cbox )
|
||||
{
|
||||
if ( outline->n_points == 0 )
|
||||
|
@ -404,6 +419,7 @@
|
|||
FT_Vector* vec = outline->points;
|
||||
FT_Vector* limit = vec + outline->n_points;
|
||||
|
||||
|
||||
xMin = xMax = vec->x;
|
||||
yMin = yMax = vec->y;
|
||||
vec++;
|
||||
|
@ -412,6 +428,7 @@
|
|||
{
|
||||
FT_Pos x, y;
|
||||
|
||||
|
||||
x = vec->x;
|
||||
if ( x < xMin ) xMin = x;
|
||||
if ( x > xMax ) xMax = x;
|
||||
|
@ -440,7 +457,9 @@
|
|||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* xOffset :: The horizontal offset. */
|
||||
/* */
|
||||
/* yOffset :: The vertical offset. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
|
@ -453,6 +472,7 @@
|
|||
FT_UShort n;
|
||||
FT_Vector* vec = outline->points;
|
||||
|
||||
|
||||
for ( n = 0; n < outline->n_points; n++ )
|
||||
{
|
||||
vec->x += xOffset;
|
||||
|
@ -461,28 +481,31 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Reverse */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Reverse the drawing direction of an outline. This is used to */
|
||||
/* ensure consistent fill conventions for mirrored glyphs.. */
|
||||
/* Reverses the drawing direction of an outline. This is used to */
|
||||
/* ensure consistent fill conventions for mirrored glyphs. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This functions toggles the bit flag ft_outline_reverse_fill in */
|
||||
/* the outline's "flags" field.. */
|
||||
/* This functions toggles the bit flag `ft_outline_reverse_fill' in */
|
||||
/* the outline's `flags' field. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_Outline_Reverse( FT_Outline* outline )
|
||||
{
|
||||
FT_UShort n;
|
||||
FT_Int first, last;
|
||||
|
||||
|
||||
first = 0;
|
||||
|
||||
for ( n = 0; n < outline->n_contours; n++ )
|
||||
{
|
||||
last = outline->contours[n];
|
||||
|
@ -493,6 +516,7 @@
|
|||
FT_Vector* q = outline->points + last;
|
||||
FT_Vector swap;
|
||||
|
||||
|
||||
while ( p < q )
|
||||
{
|
||||
swap = *p;
|
||||
|
@ -521,9 +545,11 @@
|
|||
|
||||
first = last + 1;
|
||||
}
|
||||
|
||||
outline->flags ^= ft_outline_reverse_fill;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -533,12 +559,13 @@
|
|||
/* Deallocates a glyph zone. */
|
||||
/* */
|
||||
/* <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 )
|
||||
{
|
||||
FT_Memory memory = zone->memory;
|
||||
|
||||
|
||||
FREE( zone->contours );
|
||||
FREE( zone->tags );
|
||||
FREE( zone->cur );
|
||||
|
@ -548,6 +575,7 @@
|
|||
zone->max_contours = zone->n_contours = 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -576,6 +604,7 @@
|
|||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( maxPoints > 0 )
|
||||
maxPoints += 2;
|
||||
|
||||
|
@ -589,9 +618,11 @@
|
|||
{
|
||||
FT_Done_GlyphZone( zone );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -609,12 +640,6 @@
|
|||
/* <InOut> */
|
||||
/* zone :: The address of the target zone. */
|
||||
/* */
|
||||
/* maxPoints :: The address of the zone's current capacity for */
|
||||
/* points. */
|
||||
/* */
|
||||
/* 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 )
|
||||
|
@ -622,13 +647,18 @@
|
|||
FT_Error error = FT_Err_Ok;
|
||||
FT_Memory memory = zone->memory;
|
||||
|
||||
|
||||
newPoints += 2;
|
||||
|
||||
if ( zone->max_points < newPoints )
|
||||
{
|
||||
/* reallocate the points arrays */
|
||||
if ( REALLOC_ARRAY( zone->org, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
|
||||
REALLOC_ARRAY( zone->cur, zone->max_points*2, newPoints*2, FT_F26Dot6 ) ||
|
||||
REALLOC_ARRAY( zone->tags, zone->max_points*2, newPoints, FT_Byte ) )
|
||||
if ( REALLOC_ARRAY( zone->org, zone->max_points * 2,
|
||||
newPoints * 2, FT_F26Dot6 ) ||
|
||||
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;
|
||||
|
||||
zone->max_points = newPoints;
|
||||
|
@ -637,15 +667,18 @@
|
|||
if ( zone->max_contours < newContours )
|
||||
{
|
||||
/* 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;
|
||||
|
||||
zone->max_contours = newContours;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -653,12 +686,13 @@
|
|||
/* */
|
||||
/* <Description> */
|
||||
/* 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> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* map :: A pointer to the target bitmap descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
|
@ -683,36 +717,43 @@
|
|||
FT_Raster_Funcs funcs;
|
||||
FT_Raster_Params params;
|
||||
|
||||
|
||||
error = FT_Err_Invalid_Glyph_Format;
|
||||
raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
|
||||
if (!raster) goto Exit;
|
||||
if ( !raster )
|
||||
goto Exit;
|
||||
|
||||
params.target = bitmap;
|
||||
params.source = outline;
|
||||
params.flags = 0;
|
||||
|
||||
if ( bitmap->pixel_mode == ft_pixel_mode_grays )
|
||||
params.flags |= ft_raster_flag_aa;
|
||||
|
||||
error = funcs.raster_render( raster, ¶ms );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Render */
|
||||
/* */
|
||||
/* <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 */
|
||||
/* advanced features like direct composition/translucency, etc.. */
|
||||
/* advanced features like direct composition/translucency, etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* params :: A pointer to a FT_Raster_Params used to describe */
|
||||
/* the rendering operation */
|
||||
/* the rendering operation. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
|
@ -725,9 +766,9 @@
|
|||
/* You should know what you're doing and the role of FT_Raster_Params */
|
||||
/* to use this function. */
|
||||
/* */
|
||||
/* the field "params.source" will be set to "outline" before the */
|
||||
/* scan converter is called, which means that the value you give it */
|
||||
/* is actually ignored.. */
|
||||
/* The field `params.source' will be set to `outline' before the scan */
|
||||
/* converter is called, which means that the value you give to it is */
|
||||
/* actually ignored. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Render( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
|
@ -737,12 +778,15 @@
|
|||
FT_Raster raster;
|
||||
FT_Raster_Funcs funcs;
|
||||
|
||||
|
||||
error = FT_Err_Invalid_Glyph_Format;
|
||||
raster = FT_Get_Raster( library, ft_glyph_format_outline, &funcs );
|
||||
if (!raster) goto Exit;
|
||||
if ( !raster )
|
||||
goto Exit;
|
||||
|
||||
params->source = (void*)outline;
|
||||
error = funcs.raster_render( raster, params );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
@ -759,6 +803,7 @@
|
|||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* matrix :: A pointer to the transformation matrix. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
|
@ -774,11 +819,13 @@
|
|||
FT_UShort n;
|
||||
FT_Vector* vec;
|
||||
|
||||
|
||||
vec = outline->points;
|
||||
for ( n = 0; n < outline->n_points; n++ )
|
||||
{
|
||||
FT_Pos x, y;
|
||||
|
||||
|
||||
x = FT_MulFix( vec->x, matrix->xx ) +
|
||||
FT_MulFix( vec->y, matrix->xy );
|
||||
|
||||
|
@ -792,25 +839,25 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** 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 ****/
|
||||
/**** 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
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -823,6 +870,8 @@
|
|||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
|
@ -833,6 +882,7 @@
|
|||
{
|
||||
FT_Int is_owner;
|
||||
|
||||
|
||||
if ( !source || !target ||
|
||||
source->n_points != target->n_points ||
|
||||
source->n_contours != target->n_contours )
|
||||
|
@ -847,12 +897,13 @@
|
|||
MEM_Copy( target->contours, source->contours,
|
||||
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;
|
||||
target->flags = source->flags;
|
||||
|
||||
target->flags &= ~ft_outline_owner;
|
||||
target->flags |= is_owner;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
@ -866,7 +917,7 @@
|
|||
/* Transforms a single vector through a 2x2 matrix. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* vector :: The target vector to transform */
|
||||
/* vector :: The target vector to transform. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to the source 2x2 matrix. */
|
||||
|
@ -879,6 +930,7 @@
|
|||
{
|
||||
FT_Pos xz, yz;
|
||||
|
||||
|
||||
xz = FT_MulFix( vector->x, matrix->xx ) +
|
||||
FT_MulFix( vector->y, matrix->xy );
|
||||
|
||||
|
@ -965,6 +1017,7 @@
|
|||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS */
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue