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/>.
40 #define _(String) gettext (String)
54 #define HANDLE_ERROR(msg) \
55 if (error != AFM_SUCCESS) \
58 afm_error_to_string (error, buf); \
59 fprintf (stderr, "%s: %s: %s\n", program, msg, buf); \
65 * Prototypes for static functions.
80 * The name of the file to which font map is stored. If name is NULL,
81 * leaves output to stdout.
83 static char *fname = "font.map";
88 static struct option long_options[] =
90 {"output-file", required_argument, 0, 'p'},
91 {"help", no_argument, 0, 'h'},
92 {"version", no_argument, 0, 'V'},
101 main (int argc, char *argv[])
110 program = strrchr (argv[0], '/');
116 /* Make getopt_long() to use our modified programname. */
119 /* Internationalization. */
122 setlocale (LC_MESSAGES, "");
126 bindtextdomain (PACKAGE, LOCALEDIR);
127 textdomain (PACKAGE);
130 /* Handle arguments. */
133 int option_index = 0;
136 c = getopt_long (argc, argv, "p:h", long_options, &option_index);
146 case 'p': /* output file */
147 /* Check output file "-". */
148 if (strcmp (optarg, "-") == 0)
154 case 'V': /* version number */
155 printf ("%s for GNU %s %s\n", program, PACKAGE, VERSION);
159 case '?': /* errors in arguments */
166 /* Open output file. */
167 printf (_("file=%s\n"), fname ? fname : _("stdout"));
170 ofp = fopen (fname, "w");
175 sprintf (buf, _("%s: couldn't open output file \"%s\""),
188 error = afm_create (NULL, 0, &afm);
189 HANDLE_ERROR (_("couldn't create AFM library"));
191 for (i = optind; i < argc; i++)
193 fprintf (mfp, "%s...\n", argv[i]);
194 error = afm_open_file (afm, AFM_I_MINIMUM, argv[i], &font);
195 if (error == AFM_SUCCESS)
201 cp = strrchr (argv[i], '/');
207 sf = strrchr (argv[i], '.');
213 fprintf (ofp, "%-30s\t%.*s\n", font->global_info.FontName, len, cp);
214 (void) afm_close_font (font);
219 afm_error_to_string (error, buf);
220 fprintf (mfp, "%s: %s\n", program, buf);
239 Usage: %s [OPTION]... FILE...\n\
240 Mandatory arguments to long options are mandatory for short options too.\n\
241 -h, --help print this help and exit\n\
242 -p, --output-file=NAME print output to file NAME (default file is\n\
243 font.map). If FILE is `-', leavy output to\n\
245 -V, --version print version number\n"), program);