From f9cd3d326142683da50bf7095a8b8985c01b13e2 Mon Sep 17 00:00:00 2001 From: kramm Date: Sat, 31 Jan 2004 21:38:49 +0000 Subject: [PATCH 1/1] moved from ../pdf2swf/font2swf.cc, rewritten. --- src/font2swf.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/font2swf.c diff --git a/src/font2swf.c b/src/font2swf.c new file mode 100644 index 0000000..6e355a7 --- /dev/null +++ b/src/font2swf.c @@ -0,0 +1,121 @@ +/* font2swf.c + + Utility for converting TrueType and Type 1 fonts to SWF. + + Part of the swftools package. + + Copyright (c) 2004 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include +#include "../lib/rfxswf.h" +#include "../lib/args.h" + +static char * filename = 0; +static char * destfilename = "output.swf"; +static int all=0; +static int verbose=0; + +static struct options_t options[] = +{ + {"a","all"}, + {"o","output"}, + {"v","verbose"}, + {"V","version"}, + {0,0} +}; +int args_callback_option(char*name,char*val) +{ + if(!strcmp(name, "V")) { + printf("font2swf - part of %s %s\n", PACKAGE, VERSION); + exit(0); + } + else if(!strcmp(name, "o")) { + destfilename = val; + return 1; + } + else if(!strcmp(name, "v")) { + verbose ++; + return 0; + } + else if(!strcmp(name, "a")) { + all = 1; + return 0; + } + else { + printf("Unknown option: -%s\n", name); + exit(1); + } + return 0; +} +int args_callback_longoption(char*name,char*val) +{ + return args_long2shortoption(options, name, val); +} +void args_callback_usage(char*name) +{ + printf("\n"); + printf("Usage: %s [...]\n", name); + printf(" OR: %s --all\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("\n"); +} +int args_callback_command(char*name,char*val) +{ + filename = name; + return 0; +} + +static void convertFont(char*infile, char*outfile) +{ + SWFFONT * font; + + font = swf_LoadFont(infile); + + swf_WriteFont(font, outfile); + swf_FontFree(font); +} + +int main(int argc, char ** argv) +{ + char cwd[128]; + getcwd(cwd, 128); + processargs(argc, argv); + if(!all && !filename) { + fprintf(stderr, "You must supply a filename.\n"); + exit(1); + } + + if(!all) { + convertFont(filename, destfilename); + return 0; + } + + /* TODO */ + printf("--all not implemented yet.\n"); + + return 0; +} + + -- 1.7.10.4