[AD] small exfont patch..

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


.. simply checking if the font loaded successfully, else it crashes when
run from the wrong directory. Already applied.

-- 
Elias Pschernig
Index: examples/exfont.c
===================================================================
RCS file: /cvsroot/alleg/allegro/examples/exfont.c,v
retrieving revision 1.1
diff -u -p -r1.1 exfont.c
--- examples/exfont.c	31 Mar 2005 21:15:55 -0000	1.1
+++ examples/exfont.c	5 Apr 2005 11:09:47 -0000
@@ -35,16 +35,14 @@ int main(void)
    /* clear the screen to white */
    clear_to_color(screen, makecol(255, 255, 255));
 
-   /* you don't need to do this, but on some platforms (eg. Windows) things
-    * will be drawn more quickly if you always acquire the screen before
-    * trying to draw onto it.
-    */
-   acquire_screen();
-   
    /* We will use the lower case letters from Allegro's normal font and the
     * uppercase letters from the font in unifont.dat
     */
    f1 = load_font("unifont.dat", NULL, NULL);
+   if (!f1) {
+      allegro_message("Cannot find unifont.dat in current directory.\n");
+      return 1;
+   }
 
    /* Extract character ranges */
    f2 = extract_font_range(font, ' ', 'A'-1);
@@ -61,6 +59,12 @@ int main(void)
    destroy_font(f4);
    destroy_font(f5);
 
+   /* you don't need to do this, but on some platforms (eg. Windows) things
+    * will be drawn more quickly if you always acquire the screen before
+    * trying to draw onto it.
+    */
+   acquire_screen();
+
    /* write some text to the screen with black letters and transparent background */
    textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1);
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/