32#define _XOPEN_SOURCE 500
53#define forever for (;;)
61#define GOOD_FONTS_DIR "/usr/local/share/fonts"
180 for ( gid = 0; gid <
face->num_glyphs; gid++ )
218 if (
face->num_faces == 1 )
228 for (
i = 0;
i <
num;
i++ )
258 for (
i = 0; extensions[
i] !=
NULL;
i++ )
287 if ( ( ch1 == 0 && ch2 == 1 && ch3 == 0 && ch4 == 0 ) ||
288 ( ch1 ==
'O' && ch2 ==
'T' && ch3 ==
'T' && ch4 ==
'O' ) ||
289 ( ch1 ==
't' && ch2 ==
'r' && ch3 ==
'u' && ch4 ==
'e' ) ||
290 ( ch1 ==
't' && ch2 ==
't' && ch3 ==
'c' && ch4 ==
'f' ) )
293 item->isbinary =
true;
295 else if ( ch1 == 0x80 && ch2 ==
'\01' )
298 item->isbinary =
true;
300 else if ( ch1 ==
'%' && ch2 ==
'!' )
307 item->isascii =
true;
309 else if ( ch1 == 1 && ch2 == 0 && ch3 == 4 )
312 item->isbinary =
true;
314 else if ( ch1 ==
'S' && ch2 ==
'T' && ch3 ==
'A' && ch4 ==
'R' )
319 else if ( ch1 ==
'P' && ch2 ==
'F' && ch3 ==
'R' && ch4 ==
'0' )
322 item->isbinary =
true;
324 else if ( ( ch1 ==
'\1' && ch2 ==
'f' && ch3 ==
'c' && ch4 ==
'p' ) ||
325 ( ch1 ==
'M' && ch2 ==
'Z' ) )
328 item->isbinary =
true;
333 "Can't recognize file type of `%s', assuming binary\n",
335 item->isbinary =
true;
342 item->isbinary =
true;
360 for (
i = 0; fontdirs[
i] !=
NULL;
i++ )
370 "Can't open example font directory `%s'\n",
378 "%s/%s", fontdirs[
i], ent->
d_name );
429 if ( low - high < 0x10000L )
430 return low + ( (
random() >> 8 ) % ( high + 1 - low ) );
432 return low + (
random() % ( high + 1 - low ) );
443 unsigned int i, err_cnt;
453 newf =
fopen( newfont,
"w+" );
456 fprintf(
stderr,
"Can't create temporary output file `%s'\n",
467 for (
i = 0;
i < err_cnt;
i++ )
471 if (
item->isbinary )
473 else if (
item->isascii )
511 write( 2,
"Timeout... ", 11 );
519 static int test_num = 0;
540 if ( WIFSIGNALED (
status ) )
563 fprintf(
out,
"%s [options] -- Generate random erroneous fonts\n"
564 " and attempt to parse them with FreeType.\n\n",
name );
566 fprintf(
out,
" --all All non-directory files are assumed to be fonts.\n" );
567 fprintf(
out,
" --check-outlines Make sure we can parse the outlines of each glyph.\n" );
568 fprintf(
out,
" --dir <path> Append <path> to list of font search directories\n"
569 " (no recursive search).\n" );
570 fprintf(
out,
" --error-count <cnt> Introduce <cnt> single byte errors into each font\n"
572 fprintf(
out,
" --error-fraction <frac> Introduce <frac>*filesize single byte errors\n"
573 " into each font (default: 0.0).\n" );
574 fprintf(
out,
" --ext <ext> Add <ext> to list of extensions indicating fonts.\n" );
576 fprintf(
out,
" --nohints Turn off hinting.\n" );
577 fprintf(
out,
" --rasterize Attempt to rasterize each glyph.\n" );
578 fprintf(
out,
" --results <path> Place the created test fonts into <path>\n"
579 " (default: `results')\n" );
580 fprintf(
out,
" --size <float> Use the given font size for the tests.\n" );
581 fprintf(
out,
" --test <file> Run a single test on an already existing file.\n" );
590 fprintf(
out,
"Default font directories:\n" );
603 int dcnt = 0, ecnt = 0, rset =
false, allexts =
false;
606 char* testfile =
NULL;
609 dirs =
calloc( (
size_t)(
argc + 1 ),
sizeof (
char ** ) );
618 if (
pt[0] ==
'-' &&
pt[1] ==
'-' )
623 else if (
strcmp(
pt,
"-check-outlines" ) == 0 )
625 else if (
strcmp(
pt,
"-dir" ) == 0 )
626 dirs[dcnt++] =
argv[++
i];
627 else if (
strcmp(
pt,
"-error-count" ) == 0 )
639 else if (
strcmp(
pt,
"-error-fraction" ) == 0 )
650 if ( error_fraction < 0.0 || error_fraction > 1.0 )
652 fprintf(
stderr,
"error-fraction must be in the range [0;1]\n" );
656 else if (
strcmp(
pt,
"-ext" ) == 0 )
658 else if (
strcmp(
pt,
"-help" ) == 0 )
663 else if (
strcmp(
pt,
"-nohints" ) == 0 )
665 else if (
strcmp(
pt,
"-rasterize" ) == 0 )
667 else if (
strcmp(
pt,
"-results" ) == 0 )
669 else if (
strcmp(
pt,
"-size" ) == 0 )
678 else if (
strcmp(
pt,
"-test" ) == 0 )
679 testfile =
argv[++
i];
692 else if ( ecnt == 0 )
int strcmp(const char *String1, const char *String2)
char * strstr(char *String1, char *String2)
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
void user(int argc, const char *argv[])
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
#define FT_LOAD_NO_BITMAP
FT_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface)
FT_Done_Face(FT_Face face)
#define FT_LOAD_NO_HINTING
#define FT_IS_SCALABLE(face)
FT_Render_Glyph(FT_GlyphSlot slot, FT_Render_Mode render_mode)
FT_Done_FreeType(FT_Library library)
FT_Set_Char_Size(FT_Face face, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution)
#define ft_render_mode_normal
FT_Init_FreeType(FT_Library *alibrary)
FT_BEGIN_HEADER FT_Outline_Decompose(FT_Outline *outline, const FT_Outline_Funcs *func_interface, void *user)
static double error_fraction
static int FT_CubicTo(const FT_Vector *cp1, const FT_Vector *cp2, const FT_Vector *to, void *user)
static int check_outlines
static void abort_test(int sig)
static char * default_ext_list[]
static int copyfont(struct fontlist *item, char *newfont)
static void TestFace(FT_Face face)
static unsigned int error_count
static void FindFonts(char **fontdirs, char **extensions)
static int extmatch(char *filename, char **extensions)
static void figurefiletype(struct fontlist *item)
static void do_test(void)
static int FT_ConicTo(const FT_Vector *_cp, const FT_Vector *to, void *user)
static int getRandom(int low, int high)
static unsigned int getErrorCnt(struct fontlist *item)
static int FT_LineTo(const FT_Vector *to, void *user)
static FT_F26Dot6 font_size
static int FT_MoveTo(const FT_Vector *to, void *user)
static char * default_dir_list[]
static void ExecuteTest(char *testfont)
static char * results_dir
static FT_Outline_Funcs outlinefuncs
GLenum GLuint GLint GLenum face
GLsizeiptr const GLvoid GLenum usage
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
int __cdecl closedir(DIR *)
DIR *__cdecl opendir(const char *)
struct dirent *__cdecl readdir(DIR *)
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ double __cdecl strtod(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr)
#define sprintf(buf, format,...)
static const struct encodedExtensions exts[]
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)