mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Freetype: Remove the unused multiple renderers/rasterisers support
This commit is contained in:
parent
ca07e4ef33
commit
d1addd3ee0
@ -301,16 +301,7 @@
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* try to find a renderer that supports the glyph image format */
|
/* NOTE: Support for other renderers removed */
|
||||||
FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 );
|
|
||||||
|
|
||||||
|
|
||||||
if ( render )
|
|
||||||
clazz = &render->glyph_class;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !clazz )
|
|
||||||
{
|
|
||||||
error = FT_THROW( Invalid_Glyph_Format );
|
error = FT_THROW( Invalid_Glyph_Format );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
@ -91,185 +91,6 @@
|
|||||||
#define FT_COMPONENT trace_smooth
|
#define FT_COMPONENT trace_smooth
|
||||||
|
|
||||||
|
|
||||||
#ifdef STANDALONE_
|
|
||||||
|
|
||||||
|
|
||||||
/* The size in bytes of the render pool used by the scan-line converter */
|
|
||||||
/* to do all of its work. */
|
|
||||||
#define FT_RENDER_POOL_SIZE 16384L
|
|
||||||
|
|
||||||
|
|
||||||
/* Auxiliary macros for token concatenation. */
|
|
||||||
#define FT_ERR_XCAT( x, y ) x ## y
|
|
||||||
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
|
|
||||||
|
|
||||||
#define FT_BEGIN_STMNT do {
|
|
||||||
#define FT_END_STMNT } while ( 0 )
|
|
||||||
|
|
||||||
#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
|
|
||||||
#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
|
|
||||||
#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Approximate sqrt(x*x+y*y) using the `alpha max plus beta min'
|
|
||||||
* algorithm. We use alpha = 1, beta = 3/8, giving us results with a
|
|
||||||
* largest error less than 7% compared to the exact value.
|
|
||||||
*/
|
|
||||||
#define FT_HYPOT( x, y ) \
|
|
||||||
( x = FT_ABS( x ), \
|
|
||||||
y = FT_ABS( y ), \
|
|
||||||
x > y ? x + ( 3 * y >> 3 ) \
|
|
||||||
: y + ( 3 * x >> 3 ) )
|
|
||||||
|
|
||||||
|
|
||||||
/* define this to dump debugging information */
|
|
||||||
/* #define FT_DEBUG_LEVEL_TRACE */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#define FT_CHAR_BIT CHAR_BIT
|
|
||||||
#define FT_UINT_MAX UINT_MAX
|
|
||||||
#define FT_INT_MAX INT_MAX
|
|
||||||
#define FT_ULONG_MAX ULONG_MAX
|
|
||||||
|
|
||||||
#define ADD_LONG( a, b ) \
|
|
||||||
(long)( (unsigned long)(a) + (unsigned long)(b) )
|
|
||||||
#define SUB_LONG( a, b ) \
|
|
||||||
(long)( (unsigned long)(a) - (unsigned long)(b) )
|
|
||||||
#define MUL_LONG( a, b ) \
|
|
||||||
(long)( (unsigned long)(a) * (unsigned long)(b) )
|
|
||||||
#define NEG_LONG( a ) \
|
|
||||||
(long)( -(unsigned long)(a) )
|
|
||||||
|
|
||||||
|
|
||||||
#define ft_memset memset
|
|
||||||
|
|
||||||
#define ft_setjmp setjmp
|
|
||||||
#define ft_longjmp longjmp
|
|
||||||
#define ft_jmp_buf jmp_buf
|
|
||||||
|
|
||||||
typedef ptrdiff_t FT_PtrDist;
|
|
||||||
|
|
||||||
|
|
||||||
#define ErrRaster_Invalid_Mode -2
|
|
||||||
#define ErrRaster_Invalid_Outline -1
|
|
||||||
#define ErrRaster_Invalid_Argument -3
|
|
||||||
#define ErrRaster_Memory_Overflow -4
|
|
||||||
|
|
||||||
#define FT_BEGIN_HEADER
|
|
||||||
#define FT_END_HEADER
|
|
||||||
|
|
||||||
#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 (e.g. LCC). */
|
|
||||||
#define FT_UNUSED( x ) (x) = (x)
|
|
||||||
|
|
||||||
|
|
||||||
/* we only use level 5 & 7 tracing messages; cf. ftdebug.h */
|
|
||||||
|
|
||||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
||||||
|
|
||||||
void
|
|
||||||
FT_Message( const char* fmt,
|
|
||||||
... )
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
|
|
||||||
va_start( ap, fmt );
|
|
||||||
vfprintf( stderr, fmt, ap );
|
|
||||||
va_end( ap );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* empty function useful for setting a breakpoint to catch errors */
|
|
||||||
int
|
|
||||||
FT_Throw( int error,
|
|
||||||
int line,
|
|
||||||
const char* file )
|
|
||||||
{
|
|
||||||
FT_UNUSED( error );
|
|
||||||
FT_UNUSED( line );
|
|
||||||
FT_UNUSED( file );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* we don't handle tracing levels in stand-alone mode; */
|
|
||||||
#ifndef FT_TRACE5
|
|
||||||
#define FT_TRACE5( varformat ) FT_Message varformat
|
|
||||||
#endif
|
|
||||||
#ifndef FT_TRACE7
|
|
||||||
#define FT_TRACE7( varformat ) FT_Message varformat
|
|
||||||
#endif
|
|
||||||
#ifndef FT_ERROR
|
|
||||||
#define FT_ERROR( varformat ) FT_Message varformat
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FT_THROW( e ) \
|
|
||||||
( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \
|
|
||||||
__LINE__, \
|
|
||||||
__FILE__ ) | \
|
|
||||||
FT_ERR_CAT( ErrRaster, e ) )
|
|
||||||
|
|
||||||
#else /* !FT_DEBUG_LEVEL_TRACE */
|
|
||||||
|
|
||||||
#define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */
|
|
||||||
#define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */
|
|
||||||
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
|
|
||||||
#define FT_THROW( e ) FT_ERR_CAT( ErrRaster_, e )
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !FT_DEBUG_LEVEL_TRACE */
|
|
||||||
|
|
||||||
|
|
||||||
#define FT_DEFINE_OUTLINE_FUNCS( class_, \
|
|
||||||
move_to_, line_to_, \
|
|
||||||
conic_to_, cubic_to_, \
|
|
||||||
shift_, delta_ ) \
|
|
||||||
static const FT_Outline_Funcs class_ = \
|
|
||||||
{ \
|
|
||||||
move_to_, \
|
|
||||||
line_to_, \
|
|
||||||
conic_to_, \
|
|
||||||
cubic_to_, \
|
|
||||||
shift_, \
|
|
||||||
delta_ \
|
|
||||||
};
|
|
||||||
|
|
||||||
#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, \
|
|
||||||
raster_new_, raster_reset_, \
|
|
||||||
raster_set_mode_, raster_render_, \
|
|
||||||
raster_done_ ) \
|
|
||||||
const FT_Raster_Funcs class_ = \
|
|
||||||
{ \
|
|
||||||
glyph_format_, \
|
|
||||||
raster_new_, \
|
|
||||||
raster_reset_, \
|
|
||||||
raster_set_mode_, \
|
|
||||||
raster_render_, \
|
|
||||||
raster_done_ \
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#else /* !STANDALONE_ */
|
|
||||||
|
|
||||||
|
|
||||||
#include "ft2build.h"
|
#include "ft2build.h"
|
||||||
#include "ftgrays.h"
|
#include "ftgrays.h"
|
||||||
#include FT_INTERNAL_OBJECTS_H
|
#include FT_INTERNAL_OBJECTS_H
|
||||||
@ -284,21 +105,6 @@ typedef ptrdiff_t FT_PtrDist;
|
|||||||
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
|
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
|
||||||
|
|
||||||
|
|
||||||
#endif /* !STANDALONE_ */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef FT_MEM_SET
|
|
||||||
#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FT_MEM_ZERO
|
|
||||||
#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FT_ZERO
|
|
||||||
#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* as usual, for the speed hungry :-) */
|
/* as usual, for the speed hungry :-) */
|
||||||
|
|
||||||
#undef RAS_ARG
|
#undef RAS_ARG
|
||||||
@ -480,13 +286,6 @@ typedef ptrdiff_t FT_PtrDist;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct gray_TRaster_
|
|
||||||
{
|
|
||||||
void* memory;
|
|
||||||
|
|
||||||
} gray_TRaster, *gray_PRaster;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||||
|
|
||||||
/* to be called while in the debugger -- */
|
/* to be called while in the debugger -- */
|
||||||
@ -1326,366 +1125,6 @@ typedef ptrdiff_t FT_PtrDist;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef STANDALONE_
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* The following functions should only compile in stand-alone mode, */
|
|
||||||
/* i.e., when building this component without the rest of FreeType. */
|
|
||||||
/* */
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Function> */
|
|
||||||
/* FT_Outline_Decompose */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Walk over an outline's structure to decompose it into individual */
|
|
||||||
/* segments and Bézier 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. */
|
|
||||||
/* */
|
|
||||||
/* func_interface :: A table of `emitters', i.e., function pointers */
|
|
||||||
/* called during decomposition to indicate path */
|
|
||||||
/* operations. */
|
|
||||||
/* */
|
|
||||||
/* <InOut> */
|
|
||||||
/* 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 success. */
|
|
||||||
/* */
|
|
||||||
static int
|
|
||||||
FT_Outline_Decompose( const FT_Outline* outline,
|
|
||||||
const FT_Outline_Funcs* func_interface,
|
|
||||||
void* user )
|
|
||||||
{
|
|
||||||
#undef SCALED
|
|
||||||
#define SCALED( x ) ( ( (x) << shift ) - delta )
|
|
||||||
|
|
||||||
FT_Vector v_last;
|
|
||||||
FT_Vector v_control;
|
|
||||||
FT_Vector v_start;
|
|
||||||
|
|
||||||
FT_Vector* point;
|
|
||||||
FT_Vector* limit;
|
|
||||||
char* tags;
|
|
||||||
|
|
||||||
int error;
|
|
||||||
|
|
||||||
int n; /* index of contour in outline */
|
|
||||||
int first; /* index of first point in contour */
|
|
||||||
char tag; /* current point's state */
|
|
||||||
|
|
||||||
int shift;
|
|
||||||
TPos delta;
|
|
||||||
|
|
||||||
|
|
||||||
if ( !outline )
|
|
||||||
return FT_THROW( Invalid_Outline );
|
|
||||||
|
|
||||||
if ( !func_interface )
|
|
||||||
return FT_THROW( Invalid_Argument );
|
|
||||||
|
|
||||||
shift = func_interface->shift;
|
|
||||||
delta = func_interface->delta;
|
|
||||||
first = 0;
|
|
||||||
|
|
||||||
for ( n = 0; n < outline->n_contours; n++ )
|
|
||||||
{
|
|
||||||
int last; /* index of last point in contour */
|
|
||||||
|
|
||||||
|
|
||||||
FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
|
|
||||||
|
|
||||||
last = outline->contours[n];
|
|
||||||
if ( last < 0 )
|
|
||||||
goto Invalid_Outline;
|
|
||||||
limit = outline->points + last;
|
|
||||||
|
|
||||||
v_start = outline->points[first];
|
|
||||||
v_start.x = SCALED( v_start.x );
|
|
||||||
v_start.y = SCALED( v_start.y );
|
|
||||||
|
|
||||||
v_last = outline->points[last];
|
|
||||||
v_last.x = SCALED( v_last.x );
|
|
||||||
v_last.y = SCALED( v_last.y );
|
|
||||||
|
|
||||||
v_control = v_start;
|
|
||||||
|
|
||||||
point = outline->points + first;
|
|
||||||
tags = outline->tags + first;
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
|
||||||
|
|
||||||
/* A contour cannot start with a cubic control point! */
|
|
||||||
if ( tag == FT_CURVE_TAG_CUBIC )
|
|
||||||
goto Invalid_Outline;
|
|
||||||
|
|
||||||
/* check first point to determine origin */
|
|
||||||
if ( tag == FT_CURVE_TAG_CONIC )
|
|
||||||
{
|
|
||||||
/* first point is conic control. Yes, this happens. */
|
|
||||||
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
|
|
||||||
{
|
|
||||||
/* start at last point if it is on the curve */
|
|
||||||
v_start = v_last;
|
|
||||||
limit--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* if both first and last points are conic, */
|
|
||||||
/* start at their middle and record its position */
|
|
||||||
/* for closure */
|
|
||||||
v_start.x = ( v_start.x + v_last.x ) / 2;
|
|
||||||
v_start.y = ( v_start.y + v_last.y ) / 2;
|
|
||||||
|
|
||||||
v_last = v_start;
|
|
||||||
}
|
|
||||||
point--;
|
|
||||||
tags--;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_TRACE5(( " move to (%.2f, %.2f)\n",
|
|
||||||
v_start.x / 64.0, v_start.y / 64.0 ));
|
|
||||||
error = func_interface->move_to( &v_start, user );
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
while ( point < limit )
|
|
||||||
{
|
|
||||||
point++;
|
|
||||||
tags++;
|
|
||||||
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
|
||||||
switch ( tag )
|
|
||||||
{
|
|
||||||
case FT_CURVE_TAG_ON: /* emit a single line_to */
|
|
||||||
{
|
|
||||||
FT_Vector vec;
|
|
||||||
|
|
||||||
|
|
||||||
vec.x = SCALED( point->x );
|
|
||||||
vec.y = SCALED( point->y );
|
|
||||||
|
|
||||||
FT_TRACE5(( " line to (%.2f, %.2f)\n",
|
|
||||||
vec.x / 64.0, vec.y / 64.0 ));
|
|
||||||
error = func_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 v_middle;
|
|
||||||
|
|
||||||
|
|
||||||
point++;
|
|
||||||
tags++;
|
|
||||||
tag = FT_CURVE_TAG( tags[0] );
|
|
||||||
|
|
||||||
vec.x = SCALED( point->x );
|
|
||||||
vec.y = SCALED( point->y );
|
|
||||||
|
|
||||||
if ( tag == FT_CURVE_TAG_ON )
|
|
||||||
{
|
|
||||||
FT_TRACE5(( " conic to (%.2f, %.2f)"
|
|
||||||
" with control (%.2f, %.2f)\n",
|
|
||||||
vec.x / 64.0, vec.y / 64.0,
|
|
||||||
v_control.x / 64.0, v_control.y / 64.0 ));
|
|
||||||
error = func_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;
|
|
||||||
|
|
||||||
FT_TRACE5(( " conic to (%.2f, %.2f)"
|
|
||||||
" with control (%.2f, %.2f)\n",
|
|
||||||
v_middle.x / 64.0, v_middle.y / 64.0,
|
|
||||||
v_control.x / 64.0, v_control.y / 64.0 ));
|
|
||||||
error = func_interface->conic_to( &v_control, &v_middle, user );
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
v_control = vec;
|
|
||||||
goto Do_Conic;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_TRACE5(( " conic to (%.2f, %.2f)"
|
|
||||||
" with control (%.2f, %.2f)\n",
|
|
||||||
v_start.x / 64.0, v_start.y / 64.0,
|
|
||||||
v_control.x / 64.0, v_control.y / 64.0 ));
|
|
||||||
error = func_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 );
|
|
||||||
|
|
||||||
FT_TRACE5(( " cubic to (%.2f, %.2f)"
|
|
||||||
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
|
|
||||||
vec.x / 64.0, vec.y / 64.0,
|
|
||||||
vec1.x / 64.0, vec1.y / 64.0,
|
|
||||||
vec2.x / 64.0, vec2.y / 64.0 ));
|
|
||||||
error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_TRACE5(( " cubic to (%.2f, %.2f)"
|
|
||||||
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
|
|
||||||
v_start.x / 64.0, v_start.y / 64.0,
|
|
||||||
vec1.x / 64.0, vec1.y / 64.0,
|
|
||||||
vec2.x / 64.0, vec2.y / 64.0 ));
|
|
||||||
error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
|
|
||||||
goto Close;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close the contour with a line segment */
|
|
||||||
FT_TRACE5(( " line to (%.2f, %.2f)\n",
|
|
||||||
v_start.x / 64.0, v_start.y / 64.0 ));
|
|
||||||
error = func_interface->line_to( &v_start, user );
|
|
||||||
|
|
||||||
Close:
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
first = last + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Exit:
|
|
||||||
FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error ));
|
|
||||||
return error;
|
|
||||||
|
|
||||||
Invalid_Outline:
|
|
||||||
return FT_THROW( Invalid_Outline );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Function> */
|
|
||||||
/* FT_Outline_Get_CBox */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Return an outline's `control box'. The control box encloses all */
|
|
||||||
/* the outline's points, including Bézier control points. Though it */
|
|
||||||
/* coincides with the exact bounding box for most glyphs, it can be */
|
|
||||||
/* slightly larger in some situations (like when rotating an outline */
|
|
||||||
/* that contains Bézier outside arcs). */
|
|
||||||
/* */
|
|
||||||
/* Computing the control box is very fast, while getting the bounding */
|
|
||||||
/* box can take much more time as it needs to walk over all segments */
|
|
||||||
/* and arcs in the outline. To get the latter, you can use the */
|
|
||||||
/* `ftbbox' component, which is dedicated to this single task. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* outline :: A pointer to the source outline descriptor. */
|
|
||||||
/* */
|
|
||||||
/* <Output> */
|
|
||||||
/* acbox :: The outline's control box. */
|
|
||||||
/* */
|
|
||||||
/* <Note> */
|
|
||||||
/* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
|
|
||||||
/* */
|
|
||||||
|
|
||||||
static void
|
|
||||||
FT_Outline_Get_CBox( const FT_Outline* outline,
|
|
||||||
FT_BBox *acbox )
|
|
||||||
{
|
|
||||||
TPos xMin, yMin, xMax, yMax;
|
|
||||||
|
|
||||||
|
|
||||||
if ( outline && acbox )
|
|
||||||
{
|
|
||||||
if ( outline->n_points == 0 )
|
|
||||||
{
|
|
||||||
xMin = 0;
|
|
||||||
yMin = 0;
|
|
||||||
xMax = 0;
|
|
||||||
yMax = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FT_Vector* vec = outline->points;
|
|
||||||
FT_Vector* limit = vec + outline->n_points;
|
|
||||||
|
|
||||||
|
|
||||||
xMin = xMax = vec->x;
|
|
||||||
yMin = yMax = vec->y;
|
|
||||||
vec++;
|
|
||||||
|
|
||||||
for ( ; vec < limit; vec++ )
|
|
||||||
{
|
|
||||||
TPos x, y;
|
|
||||||
|
|
||||||
|
|
||||||
x = vec->x;
|
|
||||||
if ( x < xMin ) xMin = x;
|
|
||||||
if ( x > xMax ) xMax = x;
|
|
||||||
|
|
||||||
y = vec->y;
|
|
||||||
if ( y < yMin ) yMin = y;
|
|
||||||
if ( y > yMax ) yMax = y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
acbox->xMin = xMin;
|
|
||||||
acbox->xMax = xMax;
|
|
||||||
acbox->yMin = yMin;
|
|
||||||
acbox->yMax = yMax;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* STANDALONE_ */
|
|
||||||
|
|
||||||
|
|
||||||
FT_DEFINE_OUTLINE_FUNCS(
|
FT_DEFINE_OUTLINE_FUNCS(
|
||||||
func_interface,
|
func_interface,
|
||||||
|
|
||||||
@ -1815,8 +1254,7 @@ typedef ptrdiff_t FT_PtrDist;
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
gray_raster_render( FT_Raster raster,
|
gray_raster_render( const FT_Raster_Params* params )
|
||||||
const FT_Raster_Params* params )
|
|
||||||
{
|
{
|
||||||
const FT_Outline* outline = (const FT_Outline*)params->source;
|
const FT_Outline* outline = (const FT_Outline*)params->source;
|
||||||
const FT_Bitmap* target_map = params->target;
|
const FT_Bitmap* target_map = params->target;
|
||||||
@ -1826,10 +1264,6 @@ typedef ptrdiff_t FT_PtrDist;
|
|||||||
gray_TWorker worker[1];
|
gray_TWorker worker[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if ( !raster )
|
|
||||||
return FT_THROW( Invalid_Argument );
|
|
||||||
|
|
||||||
/* this version does not support monochrome rendering */
|
/* this version does not support monochrome rendering */
|
||||||
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
|
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
|
||||||
return FT_THROW( Invalid_Mode );
|
return FT_THROW( Invalid_Mode );
|
||||||
@ -1928,102 +1362,10 @@ typedef ptrdiff_t FT_PtrDist;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/
|
|
||||||
/**** a static object. *****/
|
|
||||||
|
|
||||||
#ifdef STANDALONE_
|
|
||||||
|
|
||||||
static int
|
|
||||||
gray_raster_new( void* memory,
|
|
||||||
FT_Raster* araster )
|
|
||||||
{
|
|
||||||
static gray_TRaster the_raster;
|
|
||||||
|
|
||||||
FT_UNUSED( memory );
|
|
||||||
|
|
||||||
|
|
||||||
*araster = (FT_Raster)&the_raster;
|
|
||||||
FT_ZERO( &the_raster );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gray_raster_done( FT_Raster raster )
|
|
||||||
{
|
|
||||||
/* nothing */
|
|
||||||
FT_UNUSED( raster );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* !STANDALONE_ */
|
|
||||||
|
|
||||||
static int
|
|
||||||
gray_raster_new( FT_Memory memory,
|
|
||||||
FT_Raster* araster )
|
|
||||||
{
|
|
||||||
FT_Error error;
|
|
||||||
gray_PRaster raster = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
*araster = 0;
|
|
||||||
if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) )
|
|
||||||
{
|
|
||||||
raster->memory = memory;
|
|
||||||
*araster = (FT_Raster)raster;
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gray_raster_done( FT_Raster raster )
|
|
||||||
{
|
|
||||||
FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory;
|
|
||||||
|
|
||||||
|
|
||||||
FT_FREE( raster );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !STANDALONE_ */
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gray_raster_reset( FT_Raster raster,
|
|
||||||
unsigned char* pool_base,
|
|
||||||
unsigned long pool_size )
|
|
||||||
{
|
|
||||||
FT_UNUSED( raster );
|
|
||||||
FT_UNUSED( pool_base );
|
|
||||||
FT_UNUSED( pool_size );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
gray_raster_set_mode( FT_Raster raster,
|
|
||||||
unsigned long mode,
|
|
||||||
void* args )
|
|
||||||
{
|
|
||||||
FT_UNUSED( raster );
|
|
||||||
FT_UNUSED( mode );
|
|
||||||
FT_UNUSED( args );
|
|
||||||
|
|
||||||
|
|
||||||
return 0; /* nothing to do */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FT_DEFINE_RASTER_FUNCS(
|
FT_DEFINE_RASTER_FUNCS(
|
||||||
ft_grays_raster,
|
ft_grays_raster,
|
||||||
|
|
||||||
FT_GLYPH_FORMAT_OUTLINE,
|
(FT_Raster_Render_Func) gray_raster_render /* raster_render */
|
||||||
|
|
||||||
(FT_Raster_New_Func) gray_raster_new, /* raster_new */
|
|
||||||
(FT_Raster_Reset_Func) gray_raster_reset, /* raster_reset */
|
|
||||||
(FT_Raster_Set_Mode_Func)gray_raster_set_mode, /* raster_set_mode */
|
|
||||||
(FT_Raster_Render_Func) gray_raster_render, /* raster_render */
|
|
||||||
(FT_Raster_Done_Func) gray_raster_done /* raster_done */
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -747,18 +747,6 @@ FT_BEGIN_HEADER
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <Type> */
|
|
||||||
/* FT_Raster */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* An opaque handle (pointer) to a raster object. Each object can be */
|
|
||||||
/* used independently to convert an outline into a bitmap or pixmap. */
|
|
||||||
/* */
|
|
||||||
typedef struct FT_RasterRec_* FT_Raster;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Struct> */
|
/* <Struct> */
|
||||||
@ -828,34 +816,6 @@ FT_BEGIN_HEADER
|
|||||||
#define FT_Raster_Span_Func FT_SpanFunc
|
#define FT_Raster_Span_Func FT_SpanFunc
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <FuncType> */
|
|
||||||
/* FT_Raster_BitTest_Func */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Deprecated, unimplemented. */
|
|
||||||
/* */
|
|
||||||
typedef int
|
|
||||||
(*FT_Raster_BitTest_Func)( int y,
|
|
||||||
int x,
|
|
||||||
void* user );
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <FuncType> */
|
|
||||||
/* FT_Raster_BitSet_Func */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Deprecated, unimplemented. */
|
|
||||||
/* */
|
|
||||||
typedef void
|
|
||||||
(*FT_Raster_BitSet_Func)( int y,
|
|
||||||
int x,
|
|
||||||
void* user );
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Enum> */
|
/* <Enum> */
|
||||||
@ -921,12 +881,6 @@ FT_BEGIN_HEADER
|
|||||||
/* */
|
/* */
|
||||||
/* gray_spans :: The gray span drawing callback. */
|
/* gray_spans :: The gray span drawing callback. */
|
||||||
/* */
|
/* */
|
||||||
/* black_spans :: Unused. */
|
|
||||||
/* */
|
|
||||||
/* bit_test :: Unused. */
|
|
||||||
/* */
|
|
||||||
/* bit_set :: Unused. */
|
|
||||||
/* */
|
|
||||||
/* user :: User-supplied data that is passed to each drawing */
|
/* user :: User-supplied data that is passed to each drawing */
|
||||||
/* callback. */
|
/* callback. */
|
||||||
/* */
|
/* */
|
||||||
@ -952,123 +906,12 @@ FT_BEGIN_HEADER
|
|||||||
const void* source;
|
const void* source;
|
||||||
int flags;
|
int flags;
|
||||||
FT_SpanFunc gray_spans;
|
FT_SpanFunc gray_spans;
|
||||||
FT_SpanFunc black_spans; /* unused */
|
|
||||||
FT_Raster_BitTest_Func bit_test; /* unused */
|
|
||||||
FT_Raster_BitSet_Func bit_set; /* unused */
|
|
||||||
void* user;
|
void* user;
|
||||||
FT_BBox clip_box;
|
FT_BBox clip_box;
|
||||||
|
|
||||||
} FT_Raster_Params;
|
} FT_Raster_Params;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <FuncType> */
|
|
||||||
/* FT_Raster_NewFunc */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* A function used to create a new raster object. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* memory :: A handle to the memory allocator. */
|
|
||||||
/* */
|
|
||||||
/* <Output> */
|
|
||||||
/* raster :: A handle to the new raster object. */
|
|
||||||
/* */
|
|
||||||
/* <Return> */
|
|
||||||
/* Error code. 0~means success. */
|
|
||||||
/* */
|
|
||||||
/* <Note> */
|
|
||||||
/* The `memory' parameter is a typeless pointer in order to avoid */
|
|
||||||
/* un-wanted dependencies on the rest of the FreeType code. In */
|
|
||||||
/* practice, it is an @FT_Memory object, i.e., a handle to the */
|
|
||||||
/* standard FreeType memory allocator. However, this field can be */
|
|
||||||
/* completely ignored by a given raster implementation. */
|
|
||||||
/* */
|
|
||||||
typedef int
|
|
||||||
(*FT_Raster_NewFunc)( void* memory,
|
|
||||||
FT_Raster* raster );
|
|
||||||
|
|
||||||
#define FT_Raster_New_Func FT_Raster_NewFunc
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <FuncType> */
|
|
||||||
/* FT_Raster_DoneFunc */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* A function used to destroy a given raster object. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* raster :: A handle to the raster object. */
|
|
||||||
/* */
|
|
||||||
typedef void
|
|
||||||
(*FT_Raster_DoneFunc)( FT_Raster raster );
|
|
||||||
|
|
||||||
#define FT_Raster_Done_Func FT_Raster_DoneFunc
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <FuncType> */
|
|
||||||
/* FT_Raster_ResetFunc */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* FreeType used to provide an area of memory called the `render */
|
|
||||||
/* pool' available to all registered rasterizers. This was not */
|
|
||||||
/* thread safe, however, and now FreeType never allocates this pool. */
|
|
||||||
/* */
|
|
||||||
/* This function is called after a new raster object is created. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* raster :: A handle to the new raster object. */
|
|
||||||
/* */
|
|
||||||
/* pool_base :: Previously, the address in memory of the render pool. */
|
|
||||||
/* Set this to NULL. */
|
|
||||||
/* */
|
|
||||||
/* pool_size :: Previously, the size in bytes of the render pool. */
|
|
||||||
/* Set this to 0. */
|
|
||||||
/* */
|
|
||||||
/* <Note> */
|
|
||||||
/* Rasterizers should rely on dynamic or stack allocation if they */
|
|
||||||
/* want to (a handle to the memory allocator is passed to the */
|
|
||||||
/* rasterizer constructor). */
|
|
||||||
/* */
|
|
||||||
typedef void
|
|
||||||
(*FT_Raster_ResetFunc)( FT_Raster raster,
|
|
||||||
unsigned char* pool_base,
|
|
||||||
unsigned long pool_size );
|
|
||||||
|
|
||||||
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* <FuncType> */
|
|
||||||
/* FT_Raster_SetModeFunc */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* This function is a generic facility to change modes or attributes */
|
|
||||||
/* in a given raster. This can be used for debugging purposes, or */
|
|
||||||
/* simply to allow implementation-specific `features' in a given */
|
|
||||||
/* raster module. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* raster :: A handle to the new raster object. */
|
|
||||||
/* */
|
|
||||||
/* mode :: A 4-byte tag used to name the mode or property. */
|
|
||||||
/* */
|
|
||||||
/* args :: A pointer to the new mode/property to use. */
|
|
||||||
/* */
|
|
||||||
typedef int
|
|
||||||
(*FT_Raster_SetModeFunc)( FT_Raster raster,
|
|
||||||
unsigned long mode,
|
|
||||||
void* args );
|
|
||||||
|
|
||||||
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <FuncType> */
|
/* <FuncType> */
|
||||||
@ -1079,8 +922,6 @@ FT_BEGIN_HEADER
|
|||||||
/* target bitmap. */
|
/* target bitmap. */
|
||||||
/* */
|
/* */
|
||||||
/* <Input> */
|
/* <Input> */
|
||||||
/* raster :: A handle to the raster object. */
|
|
||||||
/* */
|
|
||||||
/* params :: A pointer to an @FT_Raster_Params structure used to */
|
/* params :: A pointer to an @FT_Raster_Params structure used to */
|
||||||
/* store the rendering parameters. */
|
/* store the rendering parameters. */
|
||||||
/* */
|
/* */
|
||||||
@ -1104,8 +945,7 @@ FT_BEGIN_HEADER
|
|||||||
/* composition). */
|
/* composition). */
|
||||||
/* */
|
/* */
|
||||||
typedef int
|
typedef int
|
||||||
(*FT_Raster_RenderFunc)( FT_Raster raster,
|
(*FT_Raster_RenderFunc)( const FT_Raster_Params* params );
|
||||||
const FT_Raster_Params* params );
|
|
||||||
|
|
||||||
#define FT_Raster_Render_Func FT_Raster_RenderFunc
|
#define FT_Raster_Render_Func FT_Raster_RenderFunc
|
||||||
|
|
||||||
@ -1119,25 +959,11 @@ FT_BEGIN_HEADER
|
|||||||
/* A structure used to describe a given raster class to the library. */
|
/* A structure used to describe a given raster class to the library. */
|
||||||
/* */
|
/* */
|
||||||
/* <Fields> */
|
/* <Fields> */
|
||||||
/* glyph_format :: The supported glyph format for this raster. */
|
|
||||||
/* */
|
|
||||||
/* raster_new :: The raster constructor. */
|
|
||||||
/* */
|
|
||||||
/* raster_reset :: Used to reset the render pool within the raster. */
|
|
||||||
/* */
|
|
||||||
/* raster_render :: A function to render a glyph into a given bitmap. */
|
/* raster_render :: A function to render a glyph into a given bitmap. */
|
||||||
/* */
|
/* */
|
||||||
/* raster_done :: The raster destructor. */
|
|
||||||
/* */
|
|
||||||
typedef struct FT_Raster_Funcs_
|
typedef struct FT_Raster_Funcs_
|
||||||
{
|
{
|
||||||
FT_Glyph_Format glyph_format;
|
|
||||||
|
|
||||||
FT_Raster_NewFunc raster_new;
|
|
||||||
FT_Raster_ResetFunc raster_reset;
|
|
||||||
FT_Raster_SetModeFunc raster_set_mode;
|
|
||||||
FT_Raster_RenderFunc raster_render;
|
FT_Raster_RenderFunc raster_render;
|
||||||
FT_Raster_DoneFunc raster_done;
|
|
||||||
|
|
||||||
} FT_Raster_Funcs;
|
} FT_Raster_Funcs;
|
||||||
|
|
||||||
|
@ -617,10 +617,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FT_Renderer
|
|
||||||
ft_lookup_glyph_renderer( FT_GlyphSlot slot );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GRID_FIT_METRICS
|
#ifdef GRID_FIT_METRICS
|
||||||
static void
|
static void
|
||||||
ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot,
|
ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot,
|
||||||
@ -888,7 +884,10 @@
|
|||||||
if ( internal->transform_flags )
|
if ( internal->transform_flags )
|
||||||
{
|
{
|
||||||
/* get renderer */
|
/* get renderer */
|
||||||
FT_Renderer renderer = ft_lookup_glyph_renderer( slot );
|
/* NOTE: Support for multiple renderers was removed */
|
||||||
|
FT_Renderer renderer = library->cur_renderer;
|
||||||
|
if ( renderer->glyph_format != slot->format )
|
||||||
|
renderer = NULL;
|
||||||
|
|
||||||
|
|
||||||
if ( renderer )
|
if ( renderer )
|
||||||
@ -2845,154 +2844,22 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/* lookup a renderer by glyph format in the library's list */
|
|
||||||
FT_BASE_DEF( FT_Renderer )
|
|
||||||
FT_Lookup_Renderer( FT_Library library,
|
|
||||||
FT_Glyph_Format format,
|
|
||||||
FT_ListNode* node )
|
|
||||||
{
|
|
||||||
FT_ListNode cur;
|
|
||||||
FT_Renderer result = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
if ( !library )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
cur = library->renderers.head;
|
|
||||||
|
|
||||||
if ( node )
|
|
||||||
{
|
|
||||||
if ( *node )
|
|
||||||
cur = (*node)->next;
|
|
||||||
*node = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( cur )
|
|
||||||
{
|
|
||||||
FT_Renderer renderer = FT_RENDERER( cur->data );
|
|
||||||
|
|
||||||
|
|
||||||
if ( renderer->glyph_format == format )
|
|
||||||
{
|
|
||||||
if ( node )
|
|
||||||
*node = cur;
|
|
||||||
|
|
||||||
result = renderer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
Exit:
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static FT_Renderer
|
|
||||||
ft_lookup_glyph_renderer( FT_GlyphSlot slot )
|
|
||||||
{
|
|
||||||
FT_Face face = slot->face;
|
|
||||||
FT_Library library = FT_FACE_LIBRARY( face );
|
|
||||||
FT_Renderer result = library->cur_renderer;
|
|
||||||
|
|
||||||
|
|
||||||
if ( !result || result->glyph_format != slot->format )
|
|
||||||
result = FT_Lookup_Renderer( library, slot->format, 0 );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ft_set_current_renderer( FT_Library library )
|
|
||||||
{
|
|
||||||
FT_Renderer renderer;
|
|
||||||
|
|
||||||
|
|
||||||
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
|
|
||||||
library->cur_renderer = renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static FT_Error
|
|
||||||
ft_add_renderer( FT_Module module )
|
ft_add_renderer( FT_Module module )
|
||||||
{
|
{
|
||||||
FT_Library library = module->library;
|
FT_Library library = module->library;
|
||||||
FT_Memory memory = library->memory;
|
|
||||||
FT_Error error;
|
FT_Renderer render = FT_RENDERER( module );
|
||||||
FT_ListNode node = NULL;
|
FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz;
|
||||||
|
|
||||||
|
|
||||||
if ( FT_NEW( node ) )
|
render->clazz = clazz;
|
||||||
goto Exit;
|
render->glyph_format = clazz->glyph_format;
|
||||||
|
|
||||||
{
|
render->raster_render = clazz->raster_class->raster_render;
|
||||||
FT_Renderer render = FT_RENDERER( module );
|
render->render = clazz->render_glyph;
|
||||||
FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz;
|
|
||||||
|
|
||||||
|
library->cur_renderer = render;
|
||||||
render->clazz = clazz;
|
|
||||||
render->glyph_format = clazz->glyph_format;
|
|
||||||
|
|
||||||
/* allocate raster object if needed */
|
|
||||||
if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
|
|
||||||
clazz->raster_class->raster_new )
|
|
||||||
{
|
|
||||||
error = clazz->raster_class->raster_new( memory, &render->raster );
|
|
||||||
if ( error )
|
|
||||||
goto Fail;
|
|
||||||
|
|
||||||
render->raster_render = clazz->raster_class->raster_render;
|
|
||||||
render->render = clazz->render_glyph;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add to list */
|
|
||||||
node->data = module;
|
|
||||||
FT_List_Add( &library->renderers, node );
|
|
||||||
|
|
||||||
ft_set_current_renderer( library );
|
|
||||||
}
|
|
||||||
|
|
||||||
Fail:
|
|
||||||
if ( error )
|
|
||||||
FT_FREE( node );
|
|
||||||
|
|
||||||
Exit:
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
ft_remove_renderer( FT_Module module )
|
|
||||||
{
|
|
||||||
FT_Library library;
|
|
||||||
FT_Memory memory;
|
|
||||||
FT_ListNode node;
|
|
||||||
|
|
||||||
|
|
||||||
library = module->library;
|
|
||||||
if ( !library )
|
|
||||||
return;
|
|
||||||
|
|
||||||
memory = library->memory;
|
|
||||||
|
|
||||||
node = FT_List_Find( &library->renderers, module );
|
|
||||||
if ( node )
|
|
||||||
{
|
|
||||||
FT_Renderer render = FT_RENDERER( module );
|
|
||||||
|
|
||||||
|
|
||||||
/* release raster object, if any */
|
|
||||||
if ( render->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
|
|
||||||
render->raster )
|
|
||||||
render->clazz->raster_class->raster_done( render->raster );
|
|
||||||
|
|
||||||
/* remove from list */
|
|
||||||
FT_List_Remove( &library->renderers, node );
|
|
||||||
FT_FREE( node );
|
|
||||||
|
|
||||||
ft_set_current_renderer( library );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3011,37 +2878,13 @@
|
|||||||
case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
|
case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FT_GLYPH_FORMAT_OUTLINE: /* small shortcut for the very common case */
|
||||||
|
renderer = library->cur_renderer; /* NOTE: Multiple renderer support removed */
|
||||||
|
error = renderer->render( renderer, slot, render_mode, NULL );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
error = FT_ERR( Unimplemented_Feature );
|
||||||
FT_ListNode node = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
/* small shortcut for the very common case */
|
|
||||||
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
|
||||||
{
|
|
||||||
renderer = library->cur_renderer;
|
|
||||||
node = library->renderers.head;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
renderer = FT_Lookup_Renderer( library, slot->format, &node );
|
|
||||||
|
|
||||||
error = FT_ERR( Unimplemented_Feature );
|
|
||||||
while ( renderer )
|
|
||||||
{
|
|
||||||
error = renderer->render( renderer, slot, render_mode, NULL );
|
|
||||||
if ( !error ||
|
|
||||||
FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
|
|
||||||
/* is unsupported by the current renderer for this glyph image */
|
|
||||||
/* format. */
|
|
||||||
|
|
||||||
/* now, look for another renderer that supports the same */
|
|
||||||
/* format. */
|
|
||||||
renderer = FT_Lookup_Renderer( library, slot->format, &node );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -3106,8 +2949,8 @@
|
|||||||
library->auto_hinter = NULL;
|
library->auto_hinter = NULL;
|
||||||
|
|
||||||
/* if the module is a renderer */
|
/* if the module is a renderer */
|
||||||
if ( FT_MODULE_IS_RENDERER( module ) )
|
if ( library && FT_MODULE_IS_RENDERER( module ) )
|
||||||
ft_remove_renderer( module );
|
library->cur_renderer = NULL;
|
||||||
|
|
||||||
/* if the module is a font driver, add some steps */
|
/* if the module is a font driver, add some steps */
|
||||||
if ( FT_MODULE_IS_DRIVER( module ) )
|
if ( FT_MODULE_IS_DRIVER( module ) )
|
||||||
@ -3187,9 +3030,7 @@
|
|||||||
if ( FT_MODULE_IS_RENDERER( module ) )
|
if ( FT_MODULE_IS_RENDERER( module ) )
|
||||||
{
|
{
|
||||||
/* add to the renderers list */
|
/* add to the renderers list */
|
||||||
error = ft_add_renderer( module );
|
ft_add_renderer( module );
|
||||||
if ( error )
|
|
||||||
goto Fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* is the module a auto-hinter? */
|
/* is the module a auto-hinter? */
|
||||||
@ -3219,17 +3060,6 @@
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
if ( FT_MODULE_IS_RENDERER( module ) )
|
|
||||||
{
|
|
||||||
FT_Renderer renderer = FT_RENDERER( module );
|
|
||||||
|
|
||||||
|
|
||||||
if ( renderer->clazz &&
|
|
||||||
renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
|
|
||||||
renderer->raster )
|
|
||||||
renderer->clazz->raster_class->raster_done( renderer->raster );
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_FREE( module );
|
FT_FREE( module );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,6 @@ FT_BEGIN_HEADER
|
|||||||
FT_Glyph_Format glyph_format;
|
FT_Glyph_Format glyph_format;
|
||||||
FT_Glyph_Class glyph_class;
|
FT_Glyph_Class glyph_class;
|
||||||
|
|
||||||
FT_Raster raster;
|
|
||||||
FT_Raster_Render_Func raster_render;
|
FT_Raster_Render_Func raster_render;
|
||||||
FT_Renderer_RenderFunc render;
|
FT_Renderer_RenderFunc render;
|
||||||
|
|
||||||
@ -748,12 +747,6 @@ FT_BEGIN_HEADER
|
|||||||
/* memory :: The library's memory object. Manages memory */
|
/* memory :: The library's memory object. Manages memory */
|
||||||
/* allocation. */
|
/* allocation. */
|
||||||
/* */
|
/* */
|
||||||
/* version_major :: The major version number of the library. */
|
|
||||||
/* */
|
|
||||||
/* version_minor :: The minor version number of the library. */
|
|
||||||
/* */
|
|
||||||
/* version_patch :: The current patch level of the library. */
|
|
||||||
/* */
|
|
||||||
/* num_modules :: The number of modules currently registered */
|
/* num_modules :: The number of modules currently registered */
|
||||||
/* within this library. This is set to 0 for new */
|
/* within this library. This is set to 0 for new */
|
||||||
/* libraries. New modules are added through the */
|
/* libraries. New modules are added through the */
|
||||||
@ -763,31 +756,12 @@ FT_BEGIN_HEADER
|
|||||||
/* registered modules. Note that each font driver */
|
/* registered modules. Note that each font driver */
|
||||||
/* contains a list of its opened faces. */
|
/* contains a list of its opened faces. */
|
||||||
/* */
|
/* */
|
||||||
/* renderers :: The list of renderers currently registered */
|
/* cur_renderer :: The current outline renderer. It is a */
|
||||||
/* within the library. */
|
|
||||||
/* */
|
|
||||||
/* cur_renderer :: The current outline renderer. This is a */
|
|
||||||
/* shortcut used to avoid parsing the list on */
|
|
||||||
/* each call to FT_Outline_Render(). It is a */
|
|
||||||
/* handle to the current renderer for the */
|
/* handle to the current renderer for the */
|
||||||
/* FT_GLYPH_FORMAT_OUTLINE format. */
|
/* FT_GLYPH_FORMAT_OUTLINE format. */
|
||||||
/* */
|
/* */
|
||||||
/* auto_hinter :: The auto-hinter module interface. */
|
/* auto_hinter :: The auto-hinter module interface. */
|
||||||
/* */
|
/* */
|
||||||
/* debug_hooks :: An array of four function pointers that allow */
|
|
||||||
/* debuggers to hook into a font format's */
|
|
||||||
/* interpreter. Currently, only the TrueType */
|
|
||||||
/* bytecode debugger uses this. */
|
|
||||||
/* */
|
|
||||||
/* lcd_weights :: If subpixel rendering is activated, the LCD */
|
|
||||||
/* filter weights, if any. */
|
|
||||||
/* */
|
|
||||||
/* lcd_filter_func :: If subpixel rendering is activated, the LCD */
|
|
||||||
/* filtering callback function. */
|
|
||||||
/* */
|
|
||||||
/* pic_container :: Contains global structs and tables, instead */
|
|
||||||
/* of defining them globally. */
|
|
||||||
/* */
|
|
||||||
/* refcount :: A counter initialized to~1 at the time an */
|
/* refcount :: A counter initialized to~1 at the time an */
|
||||||
/* @FT_Library structure is created. */
|
/* @FT_Library structure is created. */
|
||||||
/* @FT_Reference_Library increments this counter, */
|
/* @FT_Reference_Library increments this counter, */
|
||||||
@ -802,7 +776,6 @@ FT_BEGIN_HEADER
|
|||||||
FT_UInt num_modules;
|
FT_UInt num_modules;
|
||||||
FT_Module modules[FT_MAX_MODULES]; /* module objects */
|
FT_Module modules[FT_MAX_MODULES]; /* module objects */
|
||||||
|
|
||||||
FT_ListRec renderers; /* list of renderers */
|
|
||||||
FT_Renderer cur_renderer; /* current outline renderer */
|
FT_Renderer cur_renderer; /* current outline renderer */
|
||||||
FT_Module auto_hinter;
|
FT_Module auto_hinter;
|
||||||
FT_Int refcount;
|
FT_Int refcount;
|
||||||
@ -810,10 +783,6 @@ FT_BEGIN_HEADER
|
|||||||
} FT_LibraryRec;
|
} FT_LibraryRec;
|
||||||
|
|
||||||
|
|
||||||
FT_BASE( FT_Renderer )
|
|
||||||
FT_Lookup_Renderer( FT_Library library,
|
|
||||||
FT_Glyph_Format format,
|
|
||||||
FT_ListNode* node );
|
|
||||||
|
|
||||||
FT_BASE( FT_Error )
|
FT_BASE( FT_Error )
|
||||||
FT_Render_Glyph_Internal( FT_Library library,
|
FT_Render_Glyph_Internal( FT_Library library,
|
||||||
@ -887,20 +856,10 @@ FT_BEGIN_HEADER
|
|||||||
/* */
|
/* */
|
||||||
#define FT_DEFINE_RASTER_FUNCS( \
|
#define FT_DEFINE_RASTER_FUNCS( \
|
||||||
class_, \
|
class_, \
|
||||||
glyph_format_, \
|
raster_render_ ) \
|
||||||
raster_new_, \
|
|
||||||
raster_reset_, \
|
|
||||||
raster_set_mode_, \
|
|
||||||
raster_render_, \
|
|
||||||
raster_done_ ) \
|
|
||||||
const FT_Raster_Funcs class_ = \
|
const FT_Raster_Funcs class_ = \
|
||||||
{ \
|
{ \
|
||||||
glyph_format_, \
|
raster_render_ \
|
||||||
raster_new_, \
|
|
||||||
raster_reset_, \
|
|
||||||
raster_set_mode_, \
|
|
||||||
raster_render_, \
|
|
||||||
raster_done_ \
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -555,9 +555,7 @@
|
|||||||
FT_Outline* outline,
|
FT_Outline* outline,
|
||||||
FT_Raster_Params* params )
|
FT_Raster_Params* params )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
|
||||||
FT_Renderer renderer;
|
FT_Renderer renderer;
|
||||||
FT_ListNode node;
|
|
||||||
|
|
||||||
|
|
||||||
if ( !library )
|
if ( !library )
|
||||||
@ -570,28 +568,10 @@
|
|||||||
return FT_THROW( Invalid_Argument );
|
return FT_THROW( Invalid_Argument );
|
||||||
|
|
||||||
renderer = library->cur_renderer;
|
renderer = library->cur_renderer;
|
||||||
node = library->renderers.head;
|
|
||||||
|
|
||||||
params->source = (void*)outline;
|
params->source = (void*)outline;
|
||||||
|
|
||||||
error = FT_ERR( Cannot_Render_Glyph );
|
return renderer->raster_render( params );
|
||||||
while ( renderer )
|
|
||||||
{
|
|
||||||
error = renderer->raster_render( renderer->raster, params );
|
|
||||||
if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
|
|
||||||
/* is unsupported by the current renderer for this glyph image */
|
|
||||||
/* format */
|
|
||||||
|
|
||||||
/* now, look for another renderer that supports the same */
|
|
||||||
/* format */
|
|
||||||
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
|
|
||||||
&node );
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
static FT_Error
|
static FT_Error
|
||||||
ft_smooth_init( FT_Renderer render )
|
ft_smooth_init( FT_Renderer render )
|
||||||
{
|
{
|
||||||
render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,10 +40,7 @@
|
|||||||
FT_ULong mode_tag,
|
FT_ULong mode_tag,
|
||||||
FT_Pointer data )
|
FT_Pointer data )
|
||||||
{
|
{
|
||||||
/* we simply pass it to the raster */
|
return 0;
|
||||||
return render->clazz->raster_class->raster_set_mode( render->raster,
|
|
||||||
mode_tag,
|
|
||||||
data );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* transform a given glyph image */
|
/* transform a given glyph image */
|
||||||
@ -155,7 +150,7 @@
|
|||||||
params.flags = FT_RASTER_FLAG_AA;
|
params.flags = FT_RASTER_FLAG_AA;
|
||||||
|
|
||||||
/* grayscale */
|
/* grayscale */
|
||||||
error = render->raster_render( render->raster, ¶ms );
|
error = render->raster_render( ¶ms );
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
if ( !error )
|
if ( !error )
|
||||||
|
@ -176,7 +176,7 @@ static void RefreshWindowBounds(void) {
|
|||||||
- (void)keyDown:(NSEvent *)event { }
|
- (void)keyDown:(NSEvent *)event { }
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CCWindowDelegate : NSWindowDelegate { }
|
@interface CCWindowDelegate : NSObject { }
|
||||||
@end
|
@end
|
||||||
@implementation CCWindowDelegate
|
@implementation CCWindowDelegate
|
||||||
- (void)windowDidResize:(NSNotification *)notification {
|
- (void)windowDidResize:(NSNotification *)notification {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user