2 * Create font map for AFM files.
3 * Copyright (c) 1995, 1996, 1997 Markku Rossi.
5 * Author: Markku Rossi <mtr@iki.fi>
9 * This file is part of GNU enscript.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
43 #define _(String) gettext (String)
45 #define _(String) String
60 #define HANDLE_ERROR(msg) \
61 if (error != AFM_SUCCESS) \
64 afm_error_to_string (error, buf); \
65 fprintf (stderr, "%s: %s: %s\n", program, msg, buf); \
71 * Prototypes for static functions.
86 * The name of the file to which font map is stored. If name is NULL,
87 * leaves output to stdout.
89 static char *fname = "font.map";
94 static struct option long_options[] =
96 {"output-file", required_argument, 0, 'p'},
97 {"help", no_argument, 0, 'h'},
98 {"version", no_argument, 0, 'V'},
107 main (int argc, char *argv[])
116 program = strrchr (argv[0], '/');
122 /* Make getopt_long() to use our modified programname. */
125 /* Internationalization. */
128 setlocale (LC_MESSAGES, "");
132 bindtextdomain (PACKAGE, LOCALEDIR);
133 textdomain (PACKAGE);
136 /* Handle arguments. */
139 int option_index = 0;
142 c = getopt_long (argc, argv, "p:h", long_options, &option_index);
152 case 'p': /* output file */
153 /* Check output file "-". */
154 if (strcmp (optarg, "-") == 0)
160 case 'V': /* version number */
161 printf ("%s for GNU %s %s\n", program, PACKAGE, VERSION);
165 case '?': /* errors in arguments */
172 /* Open output file. */
173 printf (_("file=%s\n"), fname ? fname : _("stdout"));
176 ofp = fopen (fname, "w");
181 sprintf (buf, _("%s: couldn't open output file \"%s\""),
194 error = afm_create (NULL, 0, &afm);
195 HANDLE_ERROR (_("couldn't create AFM library"));
197 for (i = optind; i < argc; i++)
199 fprintf (mfp, "%s...\n", argv[i]);
200 error = afm_open_file (afm, AFM_I_MINIMUM, argv[i], &font);
201 if (error == AFM_SUCCESS)
207 cp = strrchr (argv[i], '/');
213 sf = strrchr (argv[i], '.');
219 fprintf (ofp, "%-30s\t%.*s\n", font->global_info.FontName, len, cp);
220 (void) afm_close_font (font);
225 afm_error_to_string (error, buf);
226 fprintf (mfp, "%s: %s\n", program, buf);
245 Usage: %s [OPTION]... FILE...\n\
246 Mandatory arguments to long options are mandatory for short options too.\n\
247 -h, --help print this help and exit\n\
248 -p, --output-file=NAME print output to file NAME (default file is\n\
249 font.map). If FILE is `-', leavy output to\n\
251 -V, --version print version number\n"), program);