/* main -- main function Copyright (C) 1998, 1999 Dieter Baron This file is part of ttftot42, to use TrueType fonts in PostScript. The author can be contacted at 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include "t42.h" #include "config.h" char *prg; char version_string[] = PACKAGE " " VERSION "\n\ Copyright (C) 1999 Dieter Baron\n" PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n\ You may redistribute copies of " PACKAGE "\n\ under the terms of the GNU General Public License.\n\ For more information about these matters, see the files named COPYING.\n"; char usage_string[] = "\ Usage: %s [-hVafnNcF] [-o file] [-e encoding] ttf-file ...\n"; char help_string[] = "\ \n\ -h, --help display this help message\n\ -V, --version display version number\n\ \n\ -a, --afm write afm file\n\ -f, --font write t42 file\n\ -n, --name print FontName to standard output\n\ -N, --filename print FontName and file name to standard output\n\ -o, --output FILE output to FILE\n\ -c, --stdout output to standard output\n\ -e, --encoding ENC encoding to use (std, pdf, latin1)\n\ -F, --full include full TrueType font file (not yet implemented)\n\ \n\ Report bugs to .\n"; #define OPTIONS "hVafnNo:ce:F" struct option options[] = { { "help", 0, 0, 'h' }, { "version", 0, 0, 'V' }, { "name", 0, 0, 'n' }, { "afm", 0, 0, 'a' }, { "font", 0, 0, 'f' }, { "name", 0, 0, 'n' }, { "filename", 0, 0, 'N' }, { "output", 1, 0, 'o' }, { "stdout", 0, 0, 'c' }, { "encoding", 1, 0, 'e' }, { "full", 0, 0, 'F' }, { NULL, 0, 0, 0 } }; char *substext(char *fname, char *ext, char *newext); int main(int argc, char **argv) { extern int opterr, optind; extern char *optarg; struct encoding *enc; int err, i; int c, what, full, cat; char *outfile; font *f; FILE *fout; char *fontfile; prg = argv[0]; cat = full = what = 0; enc = &encoding[0]; outfile = NULL; opterr = 0; while ((c=getopt_long(argc, argv, OPTIONS, options, 0)) != EOF) { switch (c) { case 'f': what |= WHAT_FONT; break; case 'a': what |= WHAT_AFM; break; case 'n': what |= WHAT_NAME; break; case 'N': what |= WHAT_FILE; break; case 'F': full = 1; break; case 'e': for (i=0; ifont_name); if (what & WHAT_FILE) { #if 0 if (!outfile) outfile = substext(basename(fontfile), ".ttf", ".t42"); printf("/%s\t(%s) ;\n", f->font_name, outfile); outfile = NULL; #endif printf("%s\t%s\n", f->font_name, outfile ? outfile : basename(fontfile)); } close_font(f); } done(); exit(err); } char * substext(char *fname, char *ext, char *newext) { static char b[8192]; int l, el; l = strlen(fname); el = strlen(ext); if (strcasecmp(fname+l-el, ext) == 0) { strncpy(b, fname, l-el); strcpy(b+l-el, newext); } else { strcpy(b, fname); strcpy(b+l, newext); } return b; }