... |
... |
@@ -22,6 +22,7 @@ |
22
|
22
|
#include <stdlib.h>
|
23
|
23
|
#include <limits.h>
|
24
|
24
|
|
|
25
|
+#include "common.h"
|
25
|
26
|
#include "md5.h"
|
26
|
27
|
|
27
|
28
|
#ifdef UNIX
|
... |
... |
@@ -42,6 +43,26 @@ |
42
|
43
|
static int Fail;
|
43
|
44
|
|
44
|
45
|
|
|
46
|
+ /* error messages */
|
|
47
|
+#undef FTERRORS_H_
|
|
48
|
+#define FT_ERROR_START_LIST {
|
|
49
|
+#define FT_ERRORDEF( e, v, s ) case v: str = s; break;
|
|
50
|
+#define FT_ERROR_END_LIST default: str = "unknown error"; }
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+ static void
|
|
54
|
+ Error( void )
|
|
55
|
+ {
|
|
56
|
+ const FT_String *str;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+ switch( error )
|
|
60
|
+ #include <freetype/fterrors.h>
|
|
61
|
+
|
|
62
|
+ printf( " error = 0x%04x, %s\n", error, str );
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+
|
45
|
66
|
static void
|
46
|
67
|
Usage( char* name )
|
47
|
68
|
{
|
... |
... |
@@ -60,14 +81,6 @@ |
60
|
81
|
}
|
61
|
82
|
|
62
|
83
|
|
63
|
|
- static void
|
64
|
|
- Panic( const char* message )
|
65
|
|
- {
|
66
|
|
- fprintf( stderr, "%s\n error code = 0x%04x\n", message, error );
|
67
|
|
- exit(1);
|
68
|
|
- }
|
69
|
|
-
|
70
|
|
-
|
71
|
84
|
/* Analyze X- and Y-acutance; bitmap should have positive pitch */
|
72
|
85
|
static void
|
73
|
86
|
Analyze( FT_Bitmap* bitmap )
|
... |
... |
@@ -149,7 +162,7 @@ |
149
|
162
|
int quiet = 0;
|
150
|
163
|
|
151
|
164
|
|
152
|
|
- execname = argv[0];
|
|
165
|
+ execname = ft_basename( argv[0] );
|
153
|
166
|
|
154
|
167
|
if ( argc < 3 )
|
155
|
168
|
Usage( execname );
|
... |
... |
@@ -212,8 +225,10 @@ |
212
|
225
|
|
213
|
226
|
error = FT_Init_FreeType( &library );
|
214
|
227
|
if ( error )
|
215
|
|
- Panic( "Could not create library object" );
|
216
|
|
-
|
|
228
|
+ {
|
|
229
|
+ Error();
|
|
230
|
+ exit( 1 );
|
|
231
|
+ }
|
217
|
232
|
|
218
|
233
|
/* Now check all files */
|
219
|
234
|
for ( face_index = 0, file_index = 1; file_index < argc; file_index++ )
|
... |
... |
@@ -227,14 +242,9 @@ |
227
|
242
|
|
228
|
243
|
Next_Face:
|
229
|
244
|
error = FT_New_Face( library, fname, face_index, &face );
|
230
|
|
- if ( error == FT_Err_Unknown_File_Format )
|
231
|
|
- {
|
232
|
|
- printf( " unknown format\n" );
|
233
|
|
- continue;
|
234
|
|
- }
|
235
|
|
- else if ( error )
|
|
245
|
+ if ( error )
|
236
|
246
|
{
|
237
|
|
- printf( " error = 0x%04x\n" , error );
|
|
247
|
+ Error();
|
238
|
248
|
continue;
|
239
|
249
|
}
|
240
|
250
|
|
... |
... |
@@ -243,7 +253,10 @@ |
243
|
253
|
|
244
|
254
|
error = FT_Set_Char_Size( face, ptsize << 6, ptsize << 6, 72, 72 );
|
245
|
255
|
if ( error )
|
246
|
|
- Panic( "Could not set character size" );
|
|
256
|
+ {
|
|
257
|
+ Error();
|
|
258
|
+ goto Finalize;
|
|
259
|
+ }
|
247
|
260
|
|
248
|
261
|
fi = first_index > 0 ? first_index : 0;
|
249
|
262
|
li = last_index < (unsigned int)face->num_glyphs ?
|
... |
... |
@@ -258,7 +271,8 @@ |
258
|
271
|
error = FT_Load_Glyph( face, id, load_flags );
|
259
|
272
|
if ( error )
|
260
|
273
|
{
|
261
|
|
- printf( "%5u: error = 0x%04x\n", id, error );
|
|
274
|
+ printf( "%5u:", id );
|
|
275
|
+ Error();
|
262
|
276
|
Fail++;
|
263
|
277
|
continue;
|
264
|
278
|
}
|
... |
... |
@@ -266,7 +280,15 @@ |
266
|
280
|
if ( quiet )
|
267
|
281
|
continue;
|
268
|
282
|
|
269
|
|
- FT_Render_Glyph( face->glyph, render_mode );
|
|
283
|
+ printf( "%5u:", id );
|
|
284
|
+
|
|
285
|
+ error = FT_Render_Glyph( face->glyph, render_mode );
|
|
286
|
+ if ( error && error != FT_Err_Cannot_Render_Glyph )
|
|
287
|
+ {
|
|
288
|
+ Error();
|
|
289
|
+ Fail++;
|
|
290
|
+ continue;
|
|
291
|
+ }
|
270
|
292
|
|
271
|
293
|
FT_Bitmap_Init( &bitmap );
|
272
|
294
|
|
... |
... |
@@ -274,11 +296,11 @@ |
274
|
296
|
error = FT_Bitmap_Convert( library, &face->glyph->bitmap, &bitmap, 1 );
|
275
|
297
|
if ( error )
|
276
|
298
|
{
|
277
|
|
- printf( "%5u: error = 0x%04x\n", id, error );
|
|
299
|
+ Error();
|
278
|
300
|
continue;
|
279
|
301
|
}
|
280
|
302
|
else
|
281
|
|
- printf( "%5u: %3ux%-4u ", id, bitmap.width, bitmap.rows );
|
|
303
|
+ printf( " %3ux%-4u ", bitmap.width, bitmap.rows );
|
282
|
304
|
|
283
|
305
|
Analyze( &bitmap );
|
284
|
306
|
Checksum( &bitmap );
|
... |
... |
@@ -295,6 +317,8 @@ |
295
|
317
|
else
|
296
|
318
|
printf( " %d fails.\n", Fail );
|
297
|
319
|
|
|
320
|
+ Finalize:
|
|
321
|
+
|
298
|
322
|
if ( ++face_index == face->num_faces )
|
299
|
323
|
face_index = 0;
|
300
|
324
|
|