diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-09-13 10:10:45 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-09-13 10:10:45 +0000 |
commit | a8951d1db45ca51c96ffa2c431777eb37c8a2f94 (patch) | |
tree | bcaa37c326975a1771aaf85bb9a2675127f22729 /Build/source/libs/freetype2/freetype-src/src/tools | |
parent | 873f349d7e0ae42e35ccf4d96fce5a6cfa685fe6 (diff) |
freetype 2.7.0
git-svn-id: svn://tug.org/texlive/trunk@42052 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/tools')
3 files changed, 145 insertions, 67 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile index 2e619299cdf..24dc49c5639 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile @@ -5,7 +5,12 @@ TOP_DIR ?= ../../.. OBJ_DIR ?= $(TOP_DIR)/objs -# The setup below is for gcc on a Unix-like platform. +# The setup below is for gcc on a Unix-like platform, +# where FreeType has been set up to create a static library +# (which is the default). + +VPATH = $(OBJ_DIR) \ + $(OBJ_DIR)/.libs SRC_DIR = $(TOP_DIR)/src/tools/ftrandom @@ -20,16 +25,21 @@ WFLAGS = -Wmissing-prototypes \ -Wchar-subscripts \ -Wsequence-point CFLAGS = $(WFLAGS) \ - -g \ - -I $(TOP_DIR)/include + -g +INCLUDES = -I $(TOP_DIR)/include +LDFLAGS = LIBS = -lm \ - -L $(OBJ_DIR) \ - -lfreetype \ - -lz + -lz \ + -lpng \ + -lbz2 \ + -lharfbuzz all: $(OBJ_DIR)/ftrandom -$(OBJ_DIR)/ftrandom: $(SRC_DIR)/ftrandom.c $(OBJ_DIR)/libfreetype.a - $(CC) -o $(OBJ_DIR)/ftrandom $(CFLAGS) $(SRC_DIR)/ftrandom.c $(LIBS) +$(OBJ_DIR)/ftrandom.o: $(SRC_DIR)/ftrandom.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< + +$(OBJ_DIR)/ftrandom: $(OBJ_DIR)/ftrandom.o libfreetype.a + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) # EOF diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README index 71bf05323da..7c610864b6a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README @@ -1,48 +1,69 @@ ftrandom --------- +======== This program expects a set of directories containing good fonts, and a set of extensions of fonts to be tested. It will randomly pick a font, copy it, -introduce and error and then test it. +introduce an error and then test it. -The FreeType tests are quite basic: +The FreeType tests are quite basic; for each erroneous font ftrandom - For each erroneous font it - forks off a new tester; - initializes the library; - opens each font in the file; - loads each glyph; - (optionally reviewing the contours of the glyph) - (optionally rasterizing) - closes the face. + . forks off a new tester, + . initializes the library, + . opens each font in the file, + . loads each glyph, + . optionally reviews the contours of the glyph, + . optionally rasterizes the glyph, and + . closes the face. -If the tester exits with a signal, or takes longer than 20 seconds then -ftrandom saves the erroneous font and continues. If the tester exits -normally or with an error, then the superstructure removes the test font and -continues. +If a tester takes longer than 20 seconds, ftrandom saves the erroneous font +and continues. If the tester exits normally or with an error, then the +superstructure removes the test font and continues. -Arguments are: + +Command line options +-------------------- --all Test every font in the directory(ies) no matter - what its extension (some CID-keyed fonts have no - extension). - --check-outlines Call FT_Outline_Decompose on each glyph. + what its extension. + --check-outlines Call `FT_Outline_Decompose' on each glyph. --dir <dir> Append <dir> to the list of directories to search - for good fonts. + for good fonts. No recursive search. --error-count <cnt> Introduce <cnt> single-byte errors into the - erroneous fonts. + erroneous fonts (default: 1). --error-fraction <frac> Multiply the file size of the font by <frac> and introduce that many errors into the erroneous - font file. - --ext <ext> Add <ext> to the set of font types tested. Known - extensions are `ttf', `otf', `ttc', `cid', `pfb', - `pfa', `bdf', `pcf', `pfr', `fon', `otb', and - `cff'. + font file. <frac> should be in the range [0;1] + (default: 0.0). + --ext <ext> Add <ext> to the set of font types tested. --help Print out this list of options. --nohints Specify FT_LOAD_NO_HINTING when loading glyphs. - --rasterize Call FT_Render_Glyph as well as loading it. + --rasterize Call `FT_Render_Glyph' as well as loading it. --result <dir> This is the directory in which test files are placed. --test <file> Run a single test on a pre-generated testcase. - Done in the current process so it can be debugged - more easily. + This is done in the current process so it can be + debugged more easily. + +The default font extensions tested by ftrandom are + + .ttf .otf .ttc .cid .pfb .pfa .bdf .pcf .pfr .fon .otb .cff + +The default font directory is controlled by the macro `GOOD_FONTS_DIR' in +the source code (and can be thus specified during compilation); its default +value is + + /usr/local/share/fonts + +The default result directory is `results' (in the current directory). + + +Compilation +----------- + +Two possible solutions. + +. Run ftrandom within a debugging tool like `valgrind' to catch various + memory issues. + +. Compile FreeType with sanitizer flags as provided by gcc or clang, for + example, then link it with ftrandom. diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c index 9a5b632673c..ff311690927 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c @@ -29,6 +29,9 @@ /* This file is now part of the FreeType library */ +#define _XOPEN_SOURCE 500 /* for `kill', `strdup', `random', and `srandom' */ + + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -38,7 +41,6 @@ #include <sys/wait.h> #include <unistd.h> #include <dirent.h> -#include <math.h> #include <signal.h> #include <time.h> @@ -56,7 +58,7 @@ static int rasterize = false; static char* results_dir = "results"; -#define GOOD_FONTS_DIR "/home/wl/freetype-testfonts" +#define GOOD_FONTS_DIR "/usr/local/share/fonts" static char* default_dir_list[] = { @@ -81,28 +83,31 @@ NULL }; - static int error_count = 1; - static int error_fraction = 0; + static unsigned int error_count = 1; + static double error_fraction = 0.0; static FT_F26Dot6 font_size = 12 * 64; static struct fontlist { char* name; - int len; + long len; unsigned int isbinary: 1; unsigned int isascii: 1; unsigned int ishex: 1; } *fontlist; - static int fcnt; + static unsigned int fcnt; static int FT_MoveTo( const FT_Vector *to, void *user ) { + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -111,6 +116,9 @@ FT_LineTo( const FT_Vector *to, void *user ) { + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -120,6 +128,10 @@ const FT_Vector *to, void *user ) { + FT_UNUSED( _cp ); + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -130,6 +142,11 @@ const FT_Vector *to, void *user ) { + FT_UNUSED( cp1 ); + FT_UNUSED( cp2 ); + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -147,8 +164,8 @@ static void TestFace( FT_Face face ) { - int gid; - int load_flags = FT_LOAD_DEFAULT; + unsigned int gid; + int load_flags = FT_LOAD_DEFAULT; if ( check_outlines && @@ -202,7 +219,7 @@ TestFace( face ); else { - int i, num; + long i, num; num = face->num_faces; @@ -215,6 +232,8 @@ } } + FT_Done_FreeType( context ); + exit( 0 ); } @@ -329,9 +348,10 @@ FindFonts( char** fontdirs, char** extensions ) { - int i, max; - char buffer[1025]; - struct stat statb; + int i; + unsigned int max; + char buffer[1025]; + struct stat statb; max = 0; @@ -392,13 +412,13 @@ } - static int + static unsigned int getErrorCnt( struct fontlist* item ) { - if ( error_count == 0 && error_fraction == 0 ) + if ( error_count == 0 && error_fraction == 0.0 ) return 0; - return error_count + ceil( error_fraction * item->len ); + return error_count + (unsigned int)( error_fraction * item->len ); } @@ -417,10 +437,10 @@ copyfont( struct fontlist* item, char* newfont ) { - static char buffer[8096]; - FILE *good, *new; - int len; - int i, err_cnt; + static char buffer[8096]; + FILE *good, *new; + size_t len; + unsigned int i, err_cnt; good = fopen( item->name, "r" ); @@ -446,7 +466,7 @@ err_cnt = getErrorCnt( item ); for ( i = 0; i < err_cnt; ++i ) { - fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET ); + fseek( new, getRandom( 0, (int)( item->len - 1 ) ), SEEK_SET ); if ( item->isbinary ) putc( getRandom( 0, 0xFF ), new ); @@ -484,6 +504,8 @@ static void abort_test( int sig ) { + FT_UNUSED( sig ); + /* If a time-out happens, then kill the child */ kill( child_pid, SIGFPE ); write( 2, "Timeout... ", 11 ); @@ -493,7 +515,7 @@ static void do_test( void ) { - int i = getRandom( 0, fcnt - 1 ); + int i = getRandom( 0, (int)( fcnt - 1 ) ); static int test_num = 0; char buffer[1024]; @@ -534,22 +556,42 @@ usage( FILE* out, char* name ) { + char** d = default_dir_list; + char** e = default_ext_list; + + fprintf( out, "%s [options] -- Generate random erroneous fonts\n" " and attempt to parse them with FreeType.\n\n", name ); fprintf( out, " --all All non-directory files are assumed to be fonts.\n" ); fprintf( out, " --check-outlines Make sure we can parse the outlines of each glyph.\n" ); - fprintf( out, " --dir <path> Append <path> to list of font search directories.\n" ); - fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font.\n" ); + fprintf( out, " --dir <path> Append <path> to list of font search directories\n" + " (no recursive search).\n" ); + fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font\n" + " (default: 1)\n" ); fprintf( out, " --error-fraction <frac> Introduce <frac>*filesize single byte errors\n" - " into each font.\n" ); + " into each font (default: 0.0).\n" ); fprintf( out, " --ext <ext> Add <ext> to list of extensions indicating fonts.\n" ); fprintf( out, " --help Print this.\n" ); fprintf( out, " --nohints Turn off hinting.\n" ); fprintf( out, " --rasterize Attempt to rasterize each glyph.\n" ); - fprintf( out, " --results <dir> Directory in which to place the test fonts.\n" ); + fprintf( out, " --results <path> Place the created test fonts into <path>\n" + " (default: `results')\n" ); fprintf( out, " --size <float> Use the given font size for the tests.\n" ); fprintf( out, " --test <file> Run a single test on an already existing file.\n" ); + fprintf( out, "\n" ); + + fprintf( out, "Default font extensions:\n" ); + fprintf( out, " " ); + while ( *e ) + fprintf( out, " .%s", *e++ ); + fprintf( out, "\n" ); + + fprintf( out, "Default font directories:\n" ); + fprintf( out, " " ); + while ( *d ) + fprintf( out, " %s", *d++ ); + fprintf( out, "\n" ); } @@ -564,8 +606,8 @@ char* testfile = NULL; - dirs = calloc( argc + 1, sizeof ( char ** ) ); - exts = calloc( argc + 1, sizeof ( char ** ) ); + dirs = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) ); + exts = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) ); for ( i = 1; i < argc; ++i ) { @@ -585,9 +627,9 @@ else if ( strcmp( pt, "-error-count" ) == 0 ) { if ( !rset ) - error_fraction = 0; + error_fraction = 0.0; rset = true; - error_count = strtol( argv[++i], &end, 10 ); + error_count = (unsigned int)strtoul( argv[++i], &end, 10 ); if ( *end != '\0' ) { fprintf( stderr, "Bad value for error-count: %s\n", argv[i] ); @@ -605,6 +647,11 @@ fprintf( stderr, "Bad value for error-fraction: %s\n", argv[i] ); exit( 1 ); } + if ( error_fraction < 0.0 || error_fraction > 1.0 ) + { + fprintf( stderr, "error-fraction must be in the range [0;1]\n" ); + exit( 1 ); + } } else if ( strcmp( pt, "-ext" ) == 0 ) exts[ecnt++] = argv[++i]; @@ -658,7 +705,7 @@ ExecuteTest( testfile ); /* This should never return */ time( &now ); - srandom( now ); + srandom( (unsigned int)now ); FindFonts( dirs, exts ); mkdir( results_dir, 0755 ); |