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 * Enscript 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 3 of the License, or
14 * (at your option) any later version.
16 * Enscript 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 Enscript. If not, see <http://www.gnu.org/licenses/>.
41 #define _(String) gettext (String)
43 #define _(String) String
58 #define HANDLE_ERROR(msg) \
59 if (error != AFM_SUCCESS) \
62 afm_error_to_string (error, buf); \
63 fprintf (stderr, "%s: %s: %s\n", program, msg, buf); \
69 * Prototypes for static functions.
84 * The name of the file to which font map is stored. If name is NULL,
85 * leaves output to stdout.
87 static char *fname = "font.map";
92 static struct option long_options[] =
94 {"output-file", required_argument, 0, 'p'},
95 {"help", no_argument, 0, 'h'},
96 {"version", no_argument, 0, 'V'},
105 main (int argc, char *argv[])
114 program = strrchr (argv[0], '/');
120 /* Make getopt_long() to use our modified programname. */
123 /* Internationalization. */
126 setlocale (LC_MESSAGES, "");
130 bindtextdomain (PACKAGE, LOCALEDIR);
131 textdomain (PACKAGE);
134 /* Handle arguments. */
137 int option_index = 0;
140 c = getopt_long (argc, argv, "p:h", long_options, &option_index);
150 case 'p': /* output file */
151 /* Check output file "-". */
152 if (strcmp (optarg, "-") == 0)
158 case 'V': /* version number */
159 printf ("%s for GNU %s %s\n", program, PACKAGE, VERSION);
163 case '?': /* errors in arguments */
170 /* Open output file. */
171 printf (_("file=%s\n"), fname ? fname : _("stdout"));
174 ofp = fopen (fname, "w");
179 sprintf (buf, _("%s: couldn't open output file \"%s\""),
192 error = afm_create (NULL, 0, &afm);
193 HANDLE_ERROR (_("couldn't create AFM library"));
195 for (i = optind; i < argc; i++)
197 fprintf (mfp, "%s...\n", argv[i]);
198 error = afm_open_file (afm, AFM_I_MINIMUM, argv[i], &font);
199 if (error == AFM_SUCCESS)
205 cp = strrchr (argv[i], '/');
211 sf = strrchr (argv[i], '.');
217 fprintf (ofp, "%-30s\t%.*s\n", font->global_info.FontName, len, cp);
218 (void) afm_close_font (font);
223 afm_error_to_string (error, buf);
224 fprintf (mfp, "%s: %s\n", program, buf);
243 Usage: %s [OPTION]... FILE...\n\
244 Mandatory arguments to long options are mandatory for short options too.\n\
245 -h, --help print this help and exit\n\
246 -p, --output-file=NAME print output to file NAME (default file is\n\
247 font.map). If FILE is `-', leavy output to\n\
249 -V, --version print version number\n"), program);