/** PSP helper library ***************************************/
/**                                                         **/
/**                          genfont.c                      **/
/**                                                         **/
/** This file contains a simple font converter. It converts **/
/** 'fd' format fonts (by Simon Tatham) into array          **/
/** used by the font rendering library                      **/
/**                                                         **/
/** Copyright (C) Akop Karapetyan 2007                      **/
/**     You are not allowed to distribute this software     **/
/**     commercially. Please, notify me, if you make any    **/
/**     changes to this file.                               **/
/*************************************************************/
#include <stdio.h>
#include <readline/readline.h>

int main(int argc, char* argv)
{
  char line[256];
  int i,j,c;

  int ascent = 0;
  int height = 0;
  int ascii = 0;
  int width = 0;

  scanf("height %i\n", &height);
  scanf("ascent %i\n", &ascent);

  printf("%i,%i,\n{\n", height, ascent);

  while (!feof(stdin))
  {
    if (scanf("\nchar %d\n", &ascii) < 1)
      break;

    scanf("width %d\n", &width);

    printf("  { %i, { ",width);

    for (i=0;i<height;i++)
    {
      scanf("%s", line);
      c=0;

      for (j=width;j>=0;j--)
        if (line[j]=='1')
          c|=1<<(width-j-1);

      printf("%i%s", c, (i<height-1) ? "," : "");
    }

    printf(" } }, /* ASCII %i */\n", ascii);
  }

  printf("}\n");
}
