recovery: change font for menus to be an image

Instead of representing the font used for menus and log messages in
the recovery binary, load it from a resource PNG image.  This allows
different devices to substitute their own font images.

Change-Id: Ib36b86db3d01298aa7ae2b62a26ca29e6ef18014
diff --git a/minui/graphics.c b/minui/graphics.c
index 747b2db..ba68a95 100644
--- a/minui/graphics.c
+++ b/minui/graphics.c
@@ -30,7 +30,6 @@
 
 #include <pixelflinger/pixelflinger.h>
 
-#include "font_10x18.h"
 #include "minui.h"
 
 #if defined(RECOVERY_BGRA)
@@ -47,7 +46,7 @@
 #define NUM_BUFFERS 2
 
 typedef struct {
-    GGLSurface texture;
+    GGLSurface* texture;
     unsigned cwidth;
     unsigned cheight;
     unsigned ascent;
@@ -230,12 +229,14 @@
     GRFont *font = gr_font;
     unsigned off;
 
+    if (!font->texture) return x;
+
     x += overscan_offset_x;
     y += overscan_offset_y;
 
     y -= font->ascent;
 
-    gl->bindTexture(gl, &font->texture);
+    gl->bindTexture(gl, font->texture);
     gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
     gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
     gl->texGeni(gl, GGL_T, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
@@ -322,31 +323,21 @@
 
 static void gr_init_font(void)
 {
-    GGLSurface *ftex;
-    unsigned char *bits, *rle;
-    unsigned char *in, data;
-
     gr_font = calloc(sizeof(*gr_font), 1);
-    ftex = &gr_font->texture;
 
-    bits = malloc(font.width * font.height);
-
-    ftex->version = sizeof(*ftex);
-    ftex->width = font.width;
-    ftex->height = font.height;
-    ftex->stride = font.width;
-    ftex->data = (void*) bits;
-    ftex->format = GGL_PIXEL_FORMAT_A_8;
-
-    in = font.rundata;
-    while((data = *in++)) {
-        memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f);
-        bits += (data & 0x7f);
+    int res = res_create_surface("font", (void**)&(gr_font->texture));
+    if (res != 0) {
+        printf("failed to read font: res=%d\n", res);
+        gr_font->texture = NULL;
+        return;
     }
 
-    gr_font->cwidth = font.cwidth;
-    gr_font->cheight = font.cheight;
-    gr_font->ascent = font.cheight - 2;
+    // interpret the grayscale as alpha
+    gr_font->texture->format = GGL_PIXEL_FORMAT_A_8;
+
+    gr_font->cwidth = gr_font->texture->width / 96;
+    gr_font->cheight = gr_font->texture->height;
+    gr_font->ascent = gr_font->cheight - 2;
 }
 
 int gr_init(void)