changeset 645:6dd155bbfc5c

Change semantics of fontconv utility.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 15 Apr 2013 13:20:56 +0300
parents ffe0d08422c8
children cc4e6ab6120b
files fontconv.c
diffstat 1 files changed, 6 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/fontconv.c	Mon Apr 15 13:11:45 2013 +0300
+++ b/fontconv.c	Mon Apr 15 13:20:56 2013 +0300
@@ -26,7 +26,6 @@
 {
     {  0, '?', "help",     "Show this help", OPT_NONE },
     {  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', "color",    "TTF font rendering color (def: 0xFFFFFF)", OPT_ARGREQ },
 };
@@ -40,7 +39,7 @@
     {
         case 0:
             dmPrintBanner(stdout, dmProgName,
-                "[options] [sourcefile]");
+                "[options] <sourcefile.(ttf|fnt|dmf|png)> <outputfile.dmf>");
                 
             dmArgsPrintHelp(stdout, optList, optListN);
             exit(0);
@@ -50,10 +49,6 @@
             dmVerbosity++;
             break;
 
-        case 2:
-            optOutFilename = optArg;
-            break;
-
         case 3:
             {
                 int w, h;
@@ -112,6 +107,9 @@
     if (!optInFilename)
         optInFilename = currArg;
     else
+    if (optOutFilename)
+        optOutFilename = currArg;
+    else
     {
         dmError("Too many filename arguments, '%s'\n", currArg);
         return FALSE;
@@ -278,7 +276,7 @@
         exit(1);
 
     // Check arguments
-    if (!optInFilename)
+    if (!optInFilename || !optOutFilename)
     {
         dmError("Input or output file not specified!\n");
         return 1;
@@ -359,12 +357,8 @@
     }
     
     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");
 
-    if (outFile == NULL)
+    if ((outFile = dmf_create_stdio(optOutFilename, "wb")) == NULL)
     {
         dmError("Error creating file '%s', %d: %s\n",
             optInFilename, errno, strerror(errno));