* src/raster/ftmisc.h: New file. Only needed if ftraster.c is

compiled as stand-alone.

* src/raster/ftraster.c: Add comment how to compile as stand-alone.
s/FT_CONFIG_OPTION_STATIC_RASTER/FT_STATIC_RASTER/.
s/TT_STATIC_RASTER/FT_STATIC_RASTER/.
[_STANDALONE_]: Include ftimage.h and ftmisc.h.
(FT_TRACE1, FT_TRACE6, ft_memset, FT_MEM_ZERO): Define
conditionally.
(Render_Glyph, Render_Gray_Glyph): Return Raster_Err_None (or
Raster_Err_Unsupported).
(ft_black_new) [_STANDALONE_]: Fix type of `the_raster'.
(ft_black_init, ft_black_reset, ft_black_set_mode, ft_black_render):
Use `ras', not `raster'.
(ft_black_done): Use FT_UNUSED_RASTER.
(Horizontal_Sweep_Init, Horizontal_Sweep_Step,
Horizontal_Gray_Sweep_Span): Use FT_UNUSED_RASTER.


* docs/CHANGES: Updated.
This commit is contained in:
Werner Lemberg 2005-05-19 07:20:24 +00:00
parent eaab4a3c3b
commit f9fccbee8b
4 changed files with 179 additions and 31 deletions

View File

@ -1,8 +1,30 @@
2004-05-18 Werner Lemberg <wl@gnu.org>
2005-05-18 Kirill Smelkov <kirr@mns.spb.ru>
* src/raster/ftmisc.h: New file. Only needed if ftraster.c is
compiled as stand-alone.
* src/raster/ftraster.c: Add comment how to compile as stand-alone.
s/FT_CONFIG_OPTION_STATIC_RASTER/FT_STATIC_RASTER/.
s/TT_STATIC_RASTER/FT_STATIC_RASTER/.
[_STANDALONE_]: Include ftimage.h and ftmisc.h.
(FT_TRACE1, FT_TRACE6, ft_memset, FT_MEM_ZERO): Define
conditionally.
(Render_Glyph, Render_Gray_Glyph): Return Raster_Err_None (or
Raster_Err_Unsupported).
(ft_black_new) [_STANDALONE_]: Fix type of `the_raster'.
(ft_black_init, ft_black_reset, ft_black_set_mode, ft_black_render):
Use `ras', not `raster'.
(ft_black_done): Use FT_UNUSED_RASTER.
(Horizontal_Sweep_Init, Horizontal_Sweep_Step,
Horizontal_Gray_Sweep_Span): Use FT_UNUSED_RASTER.
2005-05-18 Werner Lemberg <wl@gnu.org>
* docs/announce: Start updating.
2004-05-16 Vitaliy Pasternak <v_a_pasternak@mail.ru>
* docs/CHANGES: Updated.
2005-05-16 Vitaliy Pasternak <v_a_pasternak@mail.ru>
* builds/win32/visualc/freetype.vcproj: Updated.
Exclude debug info for `Release' versions to reduce library size.

View File

@ -100,6 +100,9 @@ LATEST CHANGES BETWEEN 2.1.10 and 2.1.9
compressed form (as a trie) which saves about 20KByte of code as
well.
- Kyrill Smelkov provided patches to make src/raster/ftraster.c
compile stand-alone again.
======================================================================

83
src/raster/ftmisc.h Normal file
View File

@ -0,0 +1,83 @@
/***************************************************************************/
/* */
/* ftmisc.h */
/* */
/* Miscellaneous macros for stand-alone rasterizer (specification */
/* only). */
/* */
/* Copyright 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
/* modified and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/***************************************************/
/* */
/* This file is *not* portable! You have to adapt */
/* its definitions to your platform. */
/* */
/***************************************************/
#ifndef __FTMISC_H__
#define __FTMISC_H__
#include <string.h> /* memset */
#define FT_BEGIN_HEADER
#define FT_END_HEADER
#define FT_LOCAL_DEF( x ) static x
/* from include/freetype2/fttypes.h */
typedef unsigned char FT_Byte;
typedef signed int FT_Int;
typedef unsigned int FT_UInt;
typedef signed long FT_Long;
typedef unsigned long FT_ULong;
typedef signed long FT_F26Dot6;
typedef int FT_Error;
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
( ( (FT_ULong)_x1 << 24 ) | \
( (FT_ULong)_x2 << 16 ) | \
( (FT_ULong)_x3 << 8 ) | \
(FT_ULong)_x4 )
/* from src/ftcalc.c */
#include <inttypes.h>
typedef int64_t FT_Int64;
static FT_Long
FT_MulDiv( FT_Long a,
FT_Long b,
FT_Long c )
{
FT_Int s;
FT_Long d;
s = 1;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if ( c < 0 ) { c = -c; s = -s; }
d = (FT_Long)( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFL );
return ( s > 0 ) ? d : -d;
}
#endif /* __FTMISC_H__ */
/* END */

View File

@ -17,15 +17,49 @@
/*************************************************************************/
/* */
/* This is a rewrite of the FreeType 1.x scan-line converter */
/* 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 `ftimage.h' and `ftmisc.h' into the $(incdir) */
/* directory. Typically, you should do something like */
/* */
/* - copy `src/raster/ftraster.c' (this file) to your current directory */
/* */
/* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' */
/* to your current directory */
/* */
/* - compile `ftraster' with the _STANDALONE_ macro defined, as in */
/* */
/* cc -c -D_STANDALONE_ ftraster.c */
/* */
/* The renderer can be initialized with a call to */
/* `ft_standard_raster.raster_new'; a bitmap can be generated */
/* with a call to `ft_standard_raster.raster_render'. */
/* */
/* See the comments and documentation in the file `ftimage.h' for more */
/* details on how the raster works. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* This is a rewrite of the FreeType 1.x scan-line converter */
/* */
/*************************************************************************/
#ifdef _STANDALONE_
#include "ftmisc.h"
#include "ftimage.h"
#else /* !_STANDALONE_ */
#include <ft2build.h>
#include "ftraster.h"
#include FT_INTERNAL_CALC_H /* for FT_MulDiv only */
#endif /* !_STANDALONE_ */
/*************************************************************************/
/* */
@ -153,7 +187,9 @@
#endif
#ifndef FT_TRACE
#define FT_TRACE( x ) do ; while ( 0 ) /* nothing */
#define FT_TRACE( x ) do ; while ( 0 ) /* nothing */
#define FT_TRACE1( x ) do ; while ( 0 ) /* nothing */
#define FT_TRACE6( x ) do ; while ( 0 ) /* nothing */
#endif
#define Raster_Err_None 0
@ -163,6 +199,7 @@
#define Raster_Err_Invalid -4
#define Raster_Err_Unsupported -5
#define ft_memset memset
#else /* _STANDALONE_ */
@ -187,6 +224,9 @@
#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
/* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */
/* typically a small value and the result of a*b is known to fit into */
@ -323,7 +363,7 @@
( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) )
#ifdef TT_STATIC_RASTER
#ifdef FT_STATIC_RASTER
#define RAS_ARGS /* void */
@ -335,7 +375,7 @@
#define FT_UNUSED_RASTER do ; while ( 0 )
#else /* TT_STATIC_RASTER */
#else /* FT_STATIC_RASTER */
#define RAS_ARGS TRaster_Instance* raster,
@ -347,7 +387,7 @@
#define FT_UNUSED_RASTER FT_UNUSED( raster )
#endif /* TT_STATIC_RASTER */
#endif /* FT_STATIC_RASTER */
typedef struct TRaster_Instance_ TRaster_Instance;
@ -495,7 +535,7 @@
};
#ifdef FT_CONFIG_OPTION_STATIC_RASTER
#ifdef FT_STATIC_RASTER
static TRaster_Instance cur_ras;
#define ras cur_ras
@ -504,7 +544,7 @@
#define ras (*raster)
#endif /* FT_CONFIG_OPTION_STATIC_RASTER */
#endif /* FT_STATIC_RASTER */
/*************************************************************************/
@ -2250,7 +2290,7 @@
Short* max )
{
/* nothing, really */
FT_UNUSED( raster );
FT_UNUSED_RASTER;
FT_UNUSED( min );
FT_UNUSED( max );
}
@ -2399,7 +2439,7 @@
Horizontal_Sweep_Step( RAS_ARG )
{
/* Nothing, really */
FT_UNUSED( raster );
FT_UNUSED_RASTER;
}
@ -2546,7 +2586,7 @@
PProfile right )
{
/* nothing, really */
FT_UNUSED( raster );
FT_UNUSED_RASTER;
FT_UNUSED( y );
FT_UNUSED( x1 );
FT_UNUSED( x2 );
@ -3020,7 +3060,7 @@
return error;
}
return Raster_Err_Ok;
return Raster_Err_None;
}
@ -3096,7 +3136,7 @@
return error;
}
return Raster_Err_Ok;
return Raster_Err_None;
}
#else /* !FT_RASTER_OPTION_ANTI_ALIASING */
@ -3106,7 +3146,7 @@
{
FT_UNUSED_RASTER;
return Raster_Err_Cannot_Render_Glyph;
return Raster_Err_Unsupported;
}
#endif /* !FT_RASTER_OPTION_ANTI_ALIASING */
@ -3129,7 +3169,7 @@
( ( c << 2 ) & 0x0030 ) |
(c & 0x0003 );
raster->count_table[n] = (UInt)c;
ras.count_table[n] = (UInt)c;
}
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
@ -3138,7 +3178,7 @@
for ( n = 0; n < 5; n++ )
raster->grays[n] = n * 255 / 4;
raster->gray_width = RASTER_GRAY_LINES / 2;
ras.gray_width = RASTER_GRAY_LINES / 2;
#endif
}
@ -3155,10 +3195,10 @@
ft_black_new( void* memory,
FT_Raster *araster )
{
static FT_RasterRec_ the_raster;
static TRaster_Instance the_raster;
*araster = &the_raster;
*araster = (FT_Raster)&the_raster;
FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
ft_black_init( &the_raster );
@ -3170,7 +3210,7 @@
ft_black_done( FT_Raster raster )
{
/* nothing */
raster->init = 0;
FT_UNUSED( raster );
}
@ -3214,11 +3254,11 @@
const char* pool_base,
long pool_size )
{
if ( raster && pool_base && pool_size >= 4096 )
if ( (&ras) && pool_base && pool_size >= 4096 )
{
/* save the pool */
raster->buff = (PLong)pool_base;
raster->sizeBuff = raster->buff + pool_size / sizeof ( Long );
ras.buff = (PLong)pool_base;
ras.sizeBuff = ras.buff + pool_size / sizeof ( Long );
}
}
@ -3233,11 +3273,11 @@
if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
{
/* set 5-levels gray palette */
raster->grays[0] = palette[0];
raster->grays[1] = palette[1];
raster->grays[2] = palette[2];
raster->grays[3] = palette[3];
raster->grays[4] = palette[4];
ras.grays[0] = palette[0];
ras.grays[1] = palette[1];
ras.grays[2] = palette[2];
ras.grays[3] = palette[3];
ras.grays[4] = palette[4];
}
#else
@ -3258,7 +3298,7 @@
const FT_Bitmap* target_map = params->target;
if ( !raster || !raster->buff || !raster->sizeBuff )
if ( !(&ras) || !ras.buff || !ras.sizeBuff )
return Raster_Err_Not_Ini;
/* return immediately if the outline is empty */
@ -3282,8 +3322,8 @@
ras.target = *target_map;
return ( ( params->flags & FT_RASTER_FLAG_AA )
? Render_Gray_Glyph( raster )
: Render_Glyph( raster ) );
? Render_Gray_Glyph( RAS_VAR )
: Render_Glyph( RAS_VAR ) );
}