changeset 579:f87446a81887

Remove C source output mode, it is useless.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 12 Apr 2013 04:52:56 +0300
parents cf5d44b36851
children 999ac54c8f29
files fontconv.c
diffstat 1 files changed, 6 insertions(+), 165 deletions(-) [+]
line wrap: on
line diff
--- a/fontconv.c	Fri Apr 12 04:44:25 2013 +0300
+++ b/fontconv.c	Fri Apr 12 04:52:56 2013 +0300
@@ -14,17 +14,9 @@
 #include "dmtext.h"
 #include "dmresw.h"
 
-enum
-{
-    OFMT_DMFONT,
-    OFMT_C
-};
+char    *optInFilename = NULL, *optOutFilename = NULL;
 
-char    *optInFilename = NULL, *optOutFilename = NULL,
-        *optOutName = NULL;
-
-int     optOutFormat = OFMT_DMFONT,
-        optSplitWidth = 8,
+int     optSplitWidth = 8,
         optSplitHeight = 8;
 
 
@@ -34,8 +26,6 @@
     {  1, 'v', "verbose",  "Be more verbose", OPT_NONE },
     {  2, 'o', "output",   "Output file (default stdout)", OPT_ARGREQ },
     {  3, 's', "size",     "Set glyph dimensions (-s WxH) for image->font conversion", OPT_ARGREQ },
-    {  4, 'C', "csource",  "DMFONT as C source", OPT_NONE },
-    {  5, 'n', "name",     "Variable name prefix for C output", OPT_ARGREQ },
 };
 
 const int optListN = sizeof(optList) / sizeof(optList[0]);
@@ -83,14 +73,6 @@
             }
             break;
 
-        case 4:
-            optOutFormat = OFMT_C;
-            break;
-
-        case 5:
-            optOutName = optArg;
-            break;
-
         default:
             dmError("Unknown argument '%s'.\n", currArg);
             return FALSE;
@@ -114,128 +96,6 @@
 }
 
 
-static int dm_csrc_ferror(DMResource * f)
-{
-    return f->error;
-}
-
-
-static int dm_csrc_fputc(int v, DMResource * f)
-{
-    if (f->dataSize++ >= 16)
-    {
-        fprintf(f->fh, "\n");
-        f->dataSize = 0;
-    }
-    fprintf(f->fh, "%3d,", v);
-    f->error = dmGetErrno();
-    return 1;
-}
-
-
-static size_t dm_csrc_fwrite(void *ptr, size_t size, size_t nmemb, DMResource * f)
-{
-    size_t n;
-    Uint8 *p = (Uint8 *) ptr;
-    for (n = 0; n < size * nmemb; n++, p++)
-    {
-        if (f->dataSize++ >= 16)
-        {
-            fprintf(f->fh, "\n");
-            f->dataSize = 0;
-        }
-        fprintf(f->fh, "%3d,", *p);
-    }
-    f->error = dmGetErrno();
-    return nmemb;
-}
-
-
-static int dm_csrc_fopen(DMResource * f)
-{
-    fprintf(f->fh,
-    "const Uint8 %s[] = {\n", (char *) f->data
-    );
-    return DMERR_OK;
-}
-
-
-static void dm_csrc_fclose(DMResource * f)
-{
-    if (f->fh != NULL)
-    {
-        fprintf(f->fh,
-        "\n};\n"
-        "const unsigned int %s_size = sizeof(%s) / sizeof(%s[0]);\n",
-        (char *)f->data, (char *)f->data, (char *)f->data
-        );
-        fclose(f->fh);
-        f->fh = NULL;
-    }
-}
-
-
-DMResourceOps dfCSourceFileOps =
-{
-    dm_csrc_ferror,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    dm_csrc_fputc,
-    NULL,
-    dm_csrc_fwrite,
-
-    dm_csrc_fopen,
-    dm_csrc_fclose,
-    NULL
-};
-
-
-DMResource * dmf_create_csrc(const char *filename, const char *name)
-{
-    DMResource *handle = dmres_new(NULL, filename, 0, 0);
-    if (handle == NULL)
-        return NULL;
-
-    handle->fops = &dfCSourceFileOps;
-
-    handle->fh = fopen(filename, "w");
-    handle->error = dmGetErrno();
-    handle->data = (Uint8 *) dm_strdup(name);
-    
-    if (handle->fh != NULL)
-    {
-        handle->fops->fopen(handle);
-        dmres_ref(handle);
-        return handle;
-    }
-    else
-    {
-        dmres_free(handle);
-        return NULL;
-    }
-}
-
-
-DMResource * dmf_create_csrc_stream(FILE *fh, const char *name)
-{
-    DMResource *handle = dmres_new(NULL, NULL, 0, 0);
-    if (handle == NULL)
-        return NULL;
-
-    handle->fops = &dfCSourceFileOps;
-
-    handle->fh = fh;
-    handle->error = dmGetErrno();
-    handle->data = (Uint8 *) dm_strdup(name);
-    handle->fops->fopen(handle);
-    dmres_ref(handle);
-    return handle;
-}
-
-
 int dmCreateBitmapFontFromImage(SDL_Surface *image, int width, int height, DMBitmapFont **pfont)
 {
     int nglyph, xc, yc, xglyphs, yglyphs;
@@ -474,30 +334,11 @@
         goto error_exit;
     }
     
-    if (optOutFormat == OFMT_DMFONT)
-    {
-        dmMsg(1, "Outputting a DMFONT format bitmap font.\n");
-        if (optOutFilename == NULL)
-            outFile = dmf_create_stdio_stream(stdout);
-        else
-            outFile = dmf_create_stdio(optOutFilename, "wb");
-    }
+    dmMsg(1, "Outputting a DMFONT format bitmap font.\n");
+    if (optOutFilename == NULL)
+        outFile = dmf_create_stdio_stream(stdout);
     else
-    if (optOutFormat == OFMT_C)
-    {
-        if (optOutName == NULL)
-        {
-            dmError("C source output selected, but variable name not specified.\n");
-            goto error_exit;
-        }
-
-        dmMsg(1, "Outputting a DMFONT format bitmap font as C source file.\n");
-
-        if (optOutFilename == NULL)
-            outFile = dmf_create_csrc_stream(stdout, optOutName);
-        else
-            outFile = dmf_create_csrc(optOutFilename, optOutName);
-    }
+        outFile = dmf_create_stdio(optOutFilename, "wb");
 
     if (outFile == NULL)
     {