diff options
Diffstat (limited to 'freetype/src/tools')
-rw-r--r-- | freetype/src/tools/apinames.c | 28 | ||||
-rw-r--r-- | freetype/src/tools/cordic.py | 62 | ||||
-rw-r--r-- | freetype/src/tools/ftrandom/ftrandom.c | 34 | ||||
-rw-r--r-- | freetype/src/tools/test_afm.c | 2 | ||||
-rw-r--r-- | freetype/src/tools/test_bbox.c | 34 | ||||
-rw-r--r-- | freetype/src/tools/test_trig.c | 82 |
6 files changed, 138 insertions, 104 deletions
diff --git a/freetype/src/tools/apinames.c b/freetype/src/tools/apinames.c index 3dc6559e4..c85df721a 100644 --- a/freetype/src/tools/apinames.c +++ b/freetype/src/tools/apinames.c @@ -10,7 +10,7 @@ * accepted if you are using GCC for compilation (and probably by * other compilers too). * - * Author: David Turner, 2005, 2006, 2008-2012 + * Author: David Turner, 2005, 2006, 2008-2013 * * This code is explicitly placed into the public domain. * @@ -22,7 +22,7 @@ #include <ctype.h> #define PROGRAM_NAME "apinames" -#define PROGRAM_VERSION "0.1" +#define PROGRAM_VERSION "0.2" #define LINEBUFF_SIZE 1024 @@ -31,7 +31,8 @@ typedef enum OutputFormat_ OUTPUT_LIST = 0, /* output the list of names, one per line */ OUTPUT_WINDOWS_DEF, /* output a Windows .DEF file for Visual C++ or Mingw */ OUTPUT_BORLAND_DEF, /* output a Windows .DEF file for Borland C++ */ - OUTPUT_WATCOM_LBC /* output a Watcom Linker Command File */ + OUTPUT_WATCOM_LBC, /* output a Watcom Linker Command File */ + OUTPUT_NETWARE_IMP /* output a NetWare ImportFile */ } OutputFormat; @@ -154,8 +155,6 @@ names_dump( FILE* out, case OUTPUT_WATCOM_LBC: { - /* we must omit the .dll suffix from the library name */ - char temp[512]; const char* dot; @@ -166,10 +165,12 @@ names_dump( FILE* out, exit( 4 ); } + /* we must omit the .dll suffix from the library name */ dot = strchr( dll_name, '.' ); if ( dot != NULL ) { - int len = dot - dll_name; + char temp[512]; + int len = dot - dll_name; if ( len > (int)( sizeof ( temp ) - 1 ) ) @@ -187,6 +188,16 @@ names_dump( FILE* out, } break; + case OUTPUT_NETWARE_IMP: + { + if ( dll_name != NULL ) + fprintf( out, " (%s)\n", dll_name ); + for ( nn = 0; nn < num_names - 1; nn++ ) + fprintf( out, " %s,\n", the_names[nn].name ); + fprintf( out, " %s\n", the_names[num_names - 1].name ); + } + break; + default: /* LIST */ for ( nn = 0; nn < num_names; nn++ ) fprintf( out, "%s\n", the_names[nn].name ); @@ -311,6 +322,7 @@ usage( void ) " -w : output .DEF file for Visual C++ and Mingw\n" " -wB : output .DEF file for Borland C++\n" " -wW : output Watcom Linker Response File\n" + " -wN : output NetWare Import File\n" "\n"; fprintf( stderr, @@ -394,6 +406,10 @@ int main( int argc, const char* const* argv ) format = OUTPUT_WATCOM_LBC; break; + case 'N': + format = OUTPUT_NETWARE_IMP; + break; + case 0: break; diff --git a/freetype/src/tools/cordic.py b/freetype/src/tools/cordic.py index 3f80c5f09..6742c90df 100644 --- a/freetype/src/tools/cordic.py +++ b/freetype/src/tools/cordic.py @@ -2,65 +2,20 @@ import sys, math #units = 64*65536.0 # don't change !! -units = 256 +units = 180 * 2**16 scale = units/math.pi shrink = 1.0 comma = "" -def calc_val( x ): - global units, shrink - angle = math.atan(x) - shrink = shrink * math.cos(angle) - return angle/math.pi * units - -def print_val( n, x ): - global comma - - lo = int(x) - hi = lo + 1 - alo = math.atan(lo) - ahi = math.atan(hi) - ax = math.atan(2.0**n) - - errlo = abs( alo - ax ) - errhi = abs( ahi - ax ) - - if ( errlo < errhi ): - hi = lo - - sys.stdout.write( comma + repr( int(hi) ) ) - comma = ", " - - print "" print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units" -# compute range of "i" -r = [-1] -r = r + range(32) - -for n in r: - - if n >= 0: - x = 1.0/(2.0**n) # tangent value - else: - x = 2.0**(-n) +for n in range(1,32): - angle = math.atan(x) # arctangent - angle2 = angle*scale # arctangent in FT_Angle units + x = 0.5**n # tangent value - # determine which integer value for angle gives the best tangent - lo = int(angle2) - hi = lo + 1 - tlo = math.tan(lo/scale) - thi = math.tan(hi/scale) - - errlo = abs( tlo - x ) - errhi = abs( thi - x ) - - angle2 = hi - if errlo < errhi: - angle2 = lo + angle = math.atan(x) # arctangent + angle2 = round(angle*scale) # arctangent in FT_Angle units if angle2 <= 0: break @@ -68,12 +23,11 @@ for n in r: sys.stdout.write( comma + repr( int(angle2) ) ) comma = ", " - shrink = shrink * math.cos( angle2/scale) - + shrink /= math.sqrt( 1 + x*x ) print print "shrink factor = " + repr( shrink ) -print "shrink factor 2 = " + repr( shrink * (2.0**32) ) -print "expansion factor = " + repr(1/shrink) +print "shrink factor 2 = " + repr( int( shrink * (2**32) ) ) +print "expansion factor = " + repr( 1/shrink ) print "" diff --git a/freetype/src/tools/ftrandom/ftrandom.c b/freetype/src/tools/ftrandom/ftrandom.c index 4daac0dc1..7c9795711 100644 --- a/freetype/src/tools/ftrandom/ftrandom.c +++ b/freetype/src/tools/ftrandom/ftrandom.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2007, 2008 by George Williams */ +/* Copyright (C) 2005, 2007, 2008, 2013 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -184,7 +184,6 @@ { FT_Library context; FT_Face face; - int i, num; if ( FT_Init_FreeType( &context ) ) @@ -203,6 +202,9 @@ TestFace( face ); else { + int i, num; + + num = face->num_faces; FT_Done_Face( face ); @@ -327,12 +329,9 @@ FindFonts( char** fontdirs, char** extensions ) { - DIR* examples; - struct dirent* ent; - - int i, max; - char buffer[1025]; - struct stat statb; + int i, max; + char buffer[1025]; + struct stat statb; max = 0; @@ -340,6 +339,10 @@ for ( i = 0; fontdirs[i] != NULL; ++i ) { + DIR* examples; + struct dirent* ent; + + examples = opendir( fontdirs[i] ); if ( examples == NULL ) { @@ -555,7 +558,6 @@ char** argv ) { char **dirs, **exts; - char *pt, *end; int dcnt = 0, ecnt = 0, rset = false, allexts = false; int i; time_t now; @@ -567,7 +569,10 @@ for ( i = 1; i < argc; ++i ) { - pt = argv[i]; + char* pt = argv[i]; + char* end; + + if ( pt[0] == '-' && pt[1] == '-' ) ++pt; @@ -633,12 +638,21 @@ } if ( allexts ) + { + free( exts ); exts = NULL; + } else if ( ecnt == 0 ) + { + free( exts ); exts = default_ext_list; + } if ( dcnt == 0 ) + { + free( dirs ); dirs = default_dir_list; + } if ( testfile != NULL ) ExecuteTest( testfile ); /* This should never return */ diff --git a/freetype/src/tools/test_afm.c b/freetype/src/tools/test_afm.c index 00c46e97e..ead5e90c4 100644 --- a/freetype/src/tools/test_afm.c +++ b/freetype/src/tools/test_afm.c @@ -118,7 +118,7 @@ if ( argc < 2 ) - return FT_Err_Invalid_Argument; + return FT_ERR( Invalid_Argument ); error = FT_Init_FreeType( &library ); if ( error ) diff --git a/freetype/src/tools/test_bbox.c b/freetype/src/tools/test_bbox.c index e085c5b3d..64b82c384 100644 --- a/freetype/src/tools/test_bbox.c +++ b/freetype/src/tools/test_bbox.c @@ -88,6 +88,26 @@ }; + /* dummy outline #3 with bbox of [0 100 128 128] precisely */ + static FT_Vector dummy_vec_3[4] = + { + XVEC( 100.0, 127.0 ), + XVEC( 200.0, 127.0 ), + XVEC( 0.0, 136.0 ), + XVEC( 0.0, 100.0 ) + }; + + static FT_Outline dummy_outline_3 = + { + 1, + 4, + dummy_vec_3, + dummy_tag_1, + dummy_contour_1, + 0 + }; + + static void dump_outline( FT_Outline* outline ) { @@ -125,12 +145,14 @@ FT_Outline_Get_CBox( outline, &bbox ); time0 = get_time() - time0; - printf( "time = %5.2f cbox = [%.2f %.2f %.2f %.2f]\n", + printf( "time = %6.3f cbox = [%8.4f %8.4f %8.4f %8.4f]\n", ((double)time0/10000.0), XVAL( bbox.xMin ), XVAL( bbox.yMin ), XVAL( bbox.xMax ), XVAL( bbox.yMax ) ); + printf( "cbox_hex = [%08X %08X %08X %08X]\n", + bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax ); time0 = get_time(); @@ -138,15 +160,17 @@ FT_Outline_Get_BBox( outline, &bbox ); time0 = get_time() - time0; - printf( "time = %5.2f bbox = [%.2f %.2f %.2f %.2f]\n", + printf( "time = %6.3f bbox = [%8.4f %8.4f %8.4f %8.4f]\n", ((double)time0/10000.0), XVAL( bbox.xMin ), XVAL( bbox.yMin ), XVAL( bbox.xMax ), XVAL( bbox.yMax ) ); + printf( "bbox_hex = [%08X %08X %08X %08X]\n", + bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax ); } -#define REPEAT 100000L +#define REPEAT 1000000L int main( int argc, char** argv ) { @@ -155,6 +179,10 @@ printf( "outline #2\n" ); profile_outline( &dummy_outline_2, REPEAT ); + + printf( "outline #3\n" ); + profile_outline( &dummy_outline_3, REPEAT ); + return 0; } diff --git a/freetype/src/tools/test_trig.c b/freetype/src/tools/test_trig.c index 8c8a544aa..49d927e36 100644 --- a/freetype/src/tools/test_trig.c +++ b/freetype/src/tools/test_trig.c @@ -8,9 +8,8 @@ #define PI 3.14159265358979323846 #define SPI (PI/FT_ANGLE_PI) -/* the precision in 16.16 fixed float points of the checks. Expect */ -/* between 2 and 5 noise LSB bits during operations, due to */ -/* rounding errors.. */ +/* the precision in 16.16 fixed-point checks. Expect between 2 and 5 */ +/* noise LSB bits during operations, due to rounding errors.. */ #define THRESHOLD 64 static error = 0; @@ -18,14 +17,16 @@ static void test_cos( void ) { - FT_Fixed f1, f2; - double d1, d2; - int i; + int i; + for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { + FT_Fixed f1, f2; + double d2; + + f1 = FT_Cos(i); - d1 = f1/65536.0; d2 = cos( i*SPI ); f2 = (FT_Fixed)(d2*65536.0); @@ -39,18 +40,19 @@ } - static void test_sin( void ) { - FT_Fixed f1, f2; - double d1, d2; - int i; + int i; + for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { + FT_Fixed f1, f2; + double d2; + + f1 = FT_Sin(i); - d1 = f1/65536.0; d2 = sin( i*SPI ); f2 = (FT_Fixed)(d2*65536.0); @@ -67,14 +69,16 @@ static void test_tan( void ) { - FT_Fixed f1, f2; - double d1, d2; - int i; + int i; + for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 ) { + FT_Fixed f1, f2; + double d2; + + f1 = FT_Tan(i); - d1 = f1/65536.0; d2 = tan( i*SPI ); f2 = (FT_Fixed)(d2*65536.0); @@ -91,12 +95,16 @@ static void test_atan2( void ) { - FT_Fixed c2, s2; - double l, a, c1, s1; - int i, j; + int i; + for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { + FT_Fixed c2, s2; + double l, a, c1, s1; + int j; + + l = 5.0; a = i*SPI; @@ -118,16 +126,20 @@ } } + static void test_unit( void ) { - FT_Vector v; - double a, c1, s1; - FT_Fixed c2, s2; - int i; + int i; + for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { + FT_Vector v; + double a, c1, s1; + FT_Fixed c2, s2; + + FT_Vector_Unit( &v, i ); a = ( i*SPI ); c1 = cos(a); @@ -151,12 +163,15 @@ static void test_length( void ) { - FT_Vector v; - FT_Fixed l, l2; - int i; + int i; + for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { + FT_Vector v; + FT_Fixed l, l2; + + l = (FT_Fixed)(500.0*65536.0); v.x = (FT_Fixed)( l * cos( i*SPI ) ); v.y = (FT_Fixed)( l * sin( i*SPI ) ); @@ -175,19 +190,26 @@ static void test_rotate( void ) { - FT_Fixed c2, s2, c4, s4; - FT_Vector v; - double l, ra, a, c1, s1, cra, sra, c3, s3; - int i, j, rotate; + int rotate; + for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 ) { + double ra, cra, sra; + int i; + + ra = rotate*SPI; cra = cos( ra ); sra = sin( ra ); for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { + FT_Fixed c2, s2, c4, s4; + FT_Vector v; + double l, a, c1, s1, c3, s3; + + l = 500.0; a = i*SPI; |