fixed bug in jpeg2000 decoding
[swftools.git] / src / font2swf.c
index 6e355a7..972f294 100644 (file)
@@ -30,15 +30,18 @@ static char * filename = 0;
 static char * destfilename = "output.swf";
 static int all=0;
 static int verbose=0;
+static char * fontname = 0;
+static char config_flashtype = 0;
 
-static struct options_t options[] =
-{
- {"a","all"},
- {"o","output"},
- {"v","verbose"},
- {"V","version"},
- {0,0}
+static struct options_t options[] = {
+{"h", "help"},
+{"v", "verbose"},
+{"T", "flashtype"},
+{"o", "output"},
+{"V", "version"},
+{0,0}
 };
+
 int args_callback_option(char*name,char*val)
 {
     if(!strcmp(name, "V")) {
@@ -53,6 +56,14 @@ int args_callback_option(char*name,char*val)
        verbose ++;
        return 0;
     }
+    else if(!strcmp(name, "T")) {
+       config_flashtype=1;
+       return 0;
+    }
+    else if(!strcmp(name, "n")) {
+       fontname = val;
+       return 1;
+    }
     else if(!strcmp(name, "a")) {
        all = 1;
        return 0;
@@ -67,22 +78,23 @@ int args_callback_longoption(char*name,char*val)
 {
     return args_long2shortoption(options, name, val);
 }
-void args_callback_usage(char*name)
-{    
+void args_callback_usage(char *name)
+{
     printf("\n");
-    printf("Usage: %s <font> [...]\n", name);
-    printf("   OR: %s --all\n", name);
+    printf("Usage: %s <fontfile>\n", name);
     printf("\n");
-    printf("Options:\n");
-    printf("\t-h , --help\t\t Print help and exit\n");
-    printf("\t-o , --output filename\t set output filename\n");
-    printf("\t-a , --all\t\tGenerate a set of standard fonts into the current directory\n");
-    printf("\t-v , --verbose\t\t Be more verbose\n");
-    printf("\t-V , --version\t\t Print program version and exit\n");
+    printf("-h , --help                    Print short help message and exit\n");
+    printf("-v , --verbose                 Be verbose. Use more than one -v for greater effect.\n");
+    printf("-o , --output <filename>       Write output to file <filename>.\n");
+    printf("-V , --version                 Print version info and exit\n");
     printf("\n");
 }
 int args_callback_command(char*name,char*val)
 {
+    if(filename) {
+        fprintf(stderr, "Please specify only one font\n");
+        exit(1);
+    }
     filename = name;
     return 0;
 }
@@ -91,7 +103,11 @@ static void convertFont(char*infile, char*outfile)
 {
     SWFFONT * font;
     
-    font = swf_LoadFont(infile);
+    font = swf_LoadFont(infile, config_flashtype);
+    swf_FontCreateAlignZones(font);
+
+    if(fontname)
+        font->name = strdup(fontname);
 
     swf_WriteFont(font, outfile);
     swf_FontFree(font);