Index: pwntcha/trunk/src/authimage.c
===================================================================
--- pwntcha/trunk/src/authimage.c	(revision 445)
+++ pwntcha/trunk/src/authimage.c	(revision 448)
@@ -19,11 +19,8 @@
 #include "common.h"
 
-#define FONTNAME "font_authimage.png"
-static struct image *font = NULL;
-
 /* Main function */
 char *decode_authimage(struct image *img)
 {
-    char *all = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    static struct font *font = NULL;
     char *result;
     struct image *tmp;
@@ -32,12 +29,8 @@
     if(!font)
     {
-        char fontname[BUFSIZ];
-        sprintf(fontname, "%s/%s", share, FONTNAME);
-        font = image_load(fontname);
+        font = font_load_fixed("font_authimage.png",
+                               "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
         if(!font)
-        {
-            fprintf(stderr, "cannot load font %s\n", fontname);
             exit(-1);
-        }
     }
 
@@ -46,5 +39,5 @@
     memset(result, '\0', 7);
 
-    /* half the captchas are inverse video; we set them back to normal */
+    /* double the captcha size for better accuracy in the rotation */
     tmp = image_dup(img);
     filter_scale(tmp, 2.0);
@@ -52,9 +45,10 @@
     filter_equalize(tmp, r * 3 / 4);
     filter_smooth(tmp);
+    filter_equalize(tmp, 220);
 
     for(i = 0; i < 6; i++)
     {
         int mindiff = INT_MAX, minch = -1, ch;
-        for(ch = 0; ch < 36; ch++)
+        for(ch = 0; ch < font->size; ch++)
         {
             int diff = 0;
@@ -67,6 +61,5 @@
                     newy = 33.0 - (x + 6 * i) * 18.0 / 34.0 + y * 42.0 / 6.0 + 0.5;
                     getpixel(tmp, newx, newy, &r, &g, &b);
-                    getpixel(font, x + 6 * ch, y, &r2, &g, &b);
-                    r = (r < 220) ? 0 : 255;
+                    getpixel(font->img, x + 6 * ch, y, &r2, &g, &b);
                     diff += (r - r2) * (r - r2);
                 }
@@ -78,5 +71,5 @@
             }
         }
-        result[i] = all[minch];
+        result[i] = font->glyphs[minch].c;
     }
 
