Commits:
-
201a6bc2
by Alexei Podtelezhnikov at 2022-10-24T23:26:17-04:00
* src/ftview.c (Render_Stroke): Render bitmaps without stroking.
-
000d4ede
by Alexei Podtelezhnikov at 2022-10-25T00:12:36-04:00
[ftview] Improve error tracking.
* src/ftcommon.c (FTDemo_Error_String): Spin off new function from...
(PanicZ): ... this function.
* src/ftcommon.h (FTDemo_Error_String): Declare it.
* src/ftview.c (Process_Error): Count and track persistent errors.
(Render_*): Use it.
(main): Report the persistent error code and description.
3 changed files:
Changes:
src/ftcommon.c
... |
... |
@@ -25,12 +25,6 @@ |
25
|
25
|
#include <freetype/ftmodapi.h>
|
26
|
26
|
|
27
|
27
|
|
28
|
|
- /* error messages */
|
29
|
|
-#undef FTERRORS_H_
|
30
|
|
-#define FT_ERROR_START_LIST {
|
31
|
|
-#define FT_ERRORDEF( e, v, s ) case v: str = s; break;
|
32
|
|
-#define FT_ERROR_END_LIST default: str = "unknown error"; }
|
33
|
|
-
|
34
|
28
|
#include "common.h"
|
35
|
29
|
#include "strbuf.h"
|
36
|
30
|
#include "ftcommon.h"
|
... |
... |
@@ -72,17 +66,30 @@ |
72
|
66
|
#endif /* NODEBUG */
|
73
|
67
|
|
74
|
68
|
|
75
|
|
- /* PanicZ */
|
76
|
|
- void
|
77
|
|
- PanicZ( const char* message )
|
|
69
|
+ /* error messages */
|
|
70
|
+#undef FTERRORS_H_
|
|
71
|
+#define FT_ERROR_START_LIST {
|
|
72
|
+#define FT_ERRORDEF( e, v, s ) case v: str = s; break;
|
|
73
|
+#define FT_ERROR_END_LIST default: str = "unknown error"; }
|
|
74
|
+
|
|
75
|
+ const FT_String*
|
|
76
|
+ FTDemo_Error_String( FT_Error err )
|
78
|
77
|
{
|
79
|
78
|
const FT_String *str;
|
80
|
79
|
|
81
|
|
-
|
82
|
|
- switch( error )
|
|
80
|
+ switch ( err )
|
83
|
81
|
#include <freetype/fterrors.h>
|
84
|
82
|
|
85
|
|
- fprintf( stderr, "%s\n error = 0x%04x, %s\n", message, error, str );
|
|
83
|
+ return str;
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+ /* PanicZ */
|
|
88
|
+ void
|
|
89
|
+ PanicZ( const char* message )
|
|
90
|
+ {
|
|
91
|
+ fprintf( stderr, "%s\n error = 0x%04x, %s\n", message, error,
|
|
92
|
+ FTDemo_Error_String( error ) );
|
86
|
93
|
exit( 1 );
|
87
|
94
|
}
|
88
|
95
|
|
src/ftcommon.h
... |
... |
@@ -47,6 +47,10 @@ |
47
|
47
|
#endif
|
48
|
48
|
|
49
|
49
|
|
|
50
|
+ const FT_String*
|
|
51
|
+ FTDemo_Error_String( FT_Error err );
|
|
52
|
+
|
|
53
|
+
|
50
|
54
|
/*************************************************************************/
|
51
|
55
|
/*************************************************************************/
|
52
|
56
|
/***** *****/
|
src/ftview.c
... |
... |
@@ -106,6 +106,7 @@ |
106
|
106
|
int offset; /* as selected by the user */
|
107
|
107
|
int topleft; /* as displayed by ftview */
|
108
|
108
|
int num_fails;
|
|
109
|
+ int err_fails;
|
109
|
110
|
int preload;
|
110
|
111
|
|
111
|
112
|
int lcd_filter;
|
... |
... |
@@ -115,7 +116,7 @@ |
115
|
116
|
} status = { 1,
|
116
|
117
|
"", DIM, NULL, RENDER_MODE_ALL,
|
117
|
118
|
72, 48, 1, 0.04, 0.04, 0.02, 0.22,
|
118
|
|
- 0, 0, 0, 0, 0,
|
|
119
|
+ 0, 0, 0, 0, 0, 0,
|
119
|
120
|
FT_LCD_FILTER_DEFAULT, { 0x08, 0x4D, 0x56, 0x4D, 0x08 }, 2 };
|
120
|
121
|
|
121
|
122
|
|
... |
... |
@@ -156,6 +157,18 @@ |
156
|
157
|
}
|
157
|
158
|
|
158
|
159
|
|
|
160
|
+ static void
|
|
161
|
+ Process_Error()
|
|
162
|
+ {
|
|
163
|
+ status.num_fails++;
|
|
164
|
+
|
|
165
|
+ if ( status.err_fails == 0 )
|
|
166
|
+ status.err_fails = error;
|
|
167
|
+ if ( status.err_fails != error )
|
|
168
|
+ status.err_fails = -1;
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+
|
159
|
172
|
static int
|
160
|
173
|
Render_Stroke( int num_indices,
|
161
|
174
|
int offset )
|
... |
... |
@@ -191,70 +204,72 @@ |
191
|
204
|
|
192
|
205
|
for ( i = offset; i < num_indices; i++ )
|
193
|
206
|
{
|
194
|
|
- FT_UInt glyph_idx;
|
|
207
|
+ FT_UInt glyph_idx;
|
|
208
|
+ FT_Glyph glyph;
|
195
|
209
|
|
196
|
210
|
|
197
|
211
|
glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)i );
|
198
|
212
|
|
199
|
213
|
error = FT_Load_Glyph( face, glyph_idx,
|
200
|
214
|
handle->load_flags | FT_LOAD_NO_BITMAP );
|
|
215
|
+ if ( error )
|
|
216
|
+ goto Next;
|
201
|
217
|
|
202
|
|
- if ( !error && slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
203
|
|
- {
|
204
|
|
- FT_Glyph glyph;
|
205
|
|
-
|
206
|
|
-
|
207
|
|
- error = FT_Get_Glyph( slot, &glyph );
|
208
|
|
- if ( error )
|
209
|
|
- goto Next;
|
|
218
|
+ error = FT_Get_Glyph( slot, &glyph );
|
|
219
|
+ if ( error )
|
|
220
|
+ goto Next;
|
210
|
221
|
|
|
222
|
+ if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
|
223
|
+ {
|
211
|
224
|
error = FT_Glyph_Stroke( &glyph, handle->stroker, 1 );
|
212
|
225
|
if ( error )
|
213
|
226
|
{
|
214
|
227
|
FT_Done_Glyph( glyph );
|
215
|
228
|
goto Next;
|
216
|
229
|
}
|
|
230
|
+ }
|
217
|
231
|
|
218
|
|
- width = slot->advance.x ? slot->advance.x >> 6
|
219
|
|
- : size->metrics.y_ppem / 2;
|
220
|
|
-
|
221
|
|
- if ( X_TOO_LONG( x + width, display ) )
|
222
|
|
- {
|
223
|
|
- x = start_x;
|
224
|
|
- y += step_y;
|
|
232
|
+ width = slot->advance.x ? slot->advance.x >> 6
|
|
233
|
+ : size->metrics.y_ppem / 2;
|
225
|
234
|
|
226
|
|
- if ( Y_TOO_LONG( y, display ) )
|
227
|
|
- {
|
228
|
|
- FT_Done_Glyph( glyph );
|
229
|
|
- break;
|
230
|
|
- }
|
231
|
|
- }
|
|
235
|
+ if ( X_TOO_LONG( x + width, display ) )
|
|
236
|
+ {
|
|
237
|
+ x = start_x;
|
|
238
|
+ y += step_y;
|
232
|
239
|
|
233
|
|
- /* extra space between glyphs */
|
234
|
|
- x++;
|
235
|
|
- if ( slot->advance.x == 0 )
|
|
240
|
+ if ( Y_TOO_LONG( y, display ) )
|
236
|
241
|
{
|
237
|
|
- grFillRect( display->bitmap, x, y - width, width, width,
|
238
|
|
- display->warn_color );
|
239
|
|
- x += width;
|
|
242
|
+ FT_Done_Glyph( glyph );
|
|
243
|
+ break;
|
240
|
244
|
}
|
|
245
|
+ }
|
241
|
246
|
|
242
|
|
- error = FTDemo_Draw_Glyph( handle, display, glyph, &x, &y );
|
|
247
|
+ /* extra space between glyphs */
|
|
248
|
+ x++;
|
|
249
|
+ if ( slot->advance.x == 0 )
|
|
250
|
+ {
|
|
251
|
+ grFillRect( display->bitmap, x, y - width, width, width,
|
|
252
|
+ display->warn_color );
|
|
253
|
+ x += width;
|
|
254
|
+ }
|
243
|
255
|
|
244
|
|
- if ( error )
|
245
|
|
- goto Next;
|
246
|
|
- else
|
247
|
|
- FT_Done_Glyph( glyph );
|
|
256
|
+ error = FTDemo_Draw_Glyph( handle, display, glyph, &x, &y );
|
248
|
257
|
|
249
|
|
- if ( !have_topleft )
|
250
|
|
- {
|
251
|
|
- have_topleft = 1;
|
252
|
|
- status.topleft = i;
|
253
|
|
- }
|
254
|
|
- }
|
|
258
|
+ if ( error )
|
|
259
|
+ goto Next;
|
255
|
260
|
else
|
|
261
|
+ FT_Done_Glyph( glyph );
|
|
262
|
+
|
|
263
|
+ if ( !have_topleft )
|
|
264
|
+ {
|
|
265
|
+ have_topleft = 1;
|
|
266
|
+ status.topleft = i;
|
|
267
|
+ }
|
|
268
|
+
|
|
269
|
+ continue;
|
|
270
|
+
|
256
|
271
|
Next:
|
257
|
|
- status.num_fails++;
|
|
272
|
+ Process_Error();
|
258
|
273
|
}
|
259
|
274
|
|
260
|
275
|
return i - 1;
|
... |
... |
@@ -398,7 +413,7 @@ |
398
|
413
|
continue;
|
399
|
414
|
|
400
|
415
|
Next:
|
401
|
|
- status.num_fails++;
|
|
416
|
+ Process_Error();
|
402
|
417
|
}
|
403
|
418
|
|
404
|
419
|
return i - 1;
|
... |
... |
@@ -589,7 +604,7 @@ |
589
|
604
|
continue;
|
590
|
605
|
|
591
|
606
|
Next:
|
592
|
|
- status.num_fails++;
|
|
607
|
+ Process_Error();
|
593
|
608
|
}
|
594
|
609
|
|
595
|
610
|
return i - 1;
|
... |
... |
@@ -674,7 +689,7 @@ |
674
|
689
|
continue;
|
675
|
690
|
|
676
|
691
|
Next:
|
677
|
|
- status.num_fails++;
|
|
692
|
+ Process_Error();
|
678
|
693
|
}
|
679
|
694
|
|
680
|
695
|
return -1;
|
... |
... |
@@ -784,7 +799,7 @@ |
784
|
799
|
continue;
|
785
|
800
|
|
786
|
801
|
Next:
|
787
|
|
- status.num_fails++;
|
|
802
|
+ Process_Error();
|
788
|
803
|
}
|
789
|
804
|
}
|
790
|
805
|
|
... |
... |
@@ -1891,7 +1906,13 @@ |
1891
|
1906
|
} while ( Process_Event() == 0 );
|
1892
|
1907
|
|
1893
|
1908
|
printf( "Execution completed successfully.\n" );
|
1894
|
|
- printf( "Fails = %d\n", status.num_fails );
|
|
1909
|
+ if ( status.num_fails )
|
|
1910
|
+ {
|
|
1911
|
+ printf( "Fail count = %d, ", status.num_fails );
|
|
1912
|
+ printf( status.err_fails == -1 ? "various errors\n"
|
|
1913
|
+ : "Error code = 0x%02X (%s)\n",
|
|
1914
|
+ status.err_fails, FTDemo_Error_String( status.err_fails ) );
|
|
1915
|
+ }
|
1895
|
1916
|
|
1896
|
1917
|
FTDemo_Display_Done( display );
|
1897
|
1918
|
FTDemo_Done( handle );
|
|