summaryrefslogtreecommitdiff
path: root/fontconvert/main.c
blob: 73151f8e605fc7a165729cb3811130101ef17433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/* fontconvert -- various operations on a bitmap font.

Copyright (C) 1992, 2004 Free Software Foundation, Inc.

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, 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 "config.h"

#include "charspec.h"
#include "cmdline.h"
#include "encoding.h"
#include "font.h"
#include "libfile.h"
#include "list.h"
#include "report.h"

#include "filter.h"
#include "output-epsf.h"
#include "output-gf.h"
#include "output-tfm.h"
#include "random.h"


/* How much to adjust the baseline of output characters by.  We rely on
   this being initialized to all zeros by C.  (-baseline-adjust)  */
int baseline_adjust[MAX_CHARCODE + 1];

/* If `column_split[N]' is non-NULL, we break character N into new
   characters at each of the columns specified.  We depend on this being
   initialized to all zeros.  (-column-split)  */
int *column_split[MAX_CHARCODE + 1];

/* The names of fonts to be concatenated onto the main font in the
   output.  (-concat)  */
list_type fontname_list;

/* The resolution of the font we will read, in pixels per inch.  We
   don't deal with nonsquare pixels.  (-dpi)  */
string dpi = "300";

/* The design size which will affect both the GF and TFM output, unless
   the tfm-header `designsize' option overrides it.  (-designsize)
   `design_size_ratio' is the ratio of the input design size to the
   output design size.  */
real design_size = 0.0;
static real design_size_ratio;

/* The name of the encoding file specified by the user, and the
   structure we parse it into.  (-encoding)  */
static encoding_info_type *encoding_info = NULL;

/* If `omit[n]' is true for an element N, we throw away that character
   in that output.  (-omit)  */
static boolean omit[MAX_CHARCODE + 1];

/* An explicitly specified output filename.  (-output-file)  */
const_string output_name = NULL;

/* Says which characters we should process.  This is independent of the
   ordering in the font file.  (-range)  */
int starting_char = 0;
int ending_char = MAX_CHARCODE;

/* The variable `translate' maps character codes in the input font to
   character codes in the output; by default, maps everything to
   themselves.  (-remap)  */
charcode_type translate[MAX_CHARCODE + 1];

/* Says whether to output an EPS file for each character.  (-epsf)  */
boolean wants_epsf = false;

/* Says whether to output a GF file.  (-gf)  */
boolean wants_gf = false;

/* Says whether to output the font as plain text.  (-text)  */
boolean wants_text = false;

/* Says whether to output a TFM file.  (-tfm)  */
boolean wants_tfm = false;



static void append_concat_list (list_type *, string);
static bitmap_type column_extract (bitmap_type, unsigned, unsigned);
static void do_char (char_info_type);
static void do_split_char (char_info_type, int[]);
static string read_command_line (int, string []);
static void scan_baseline_adjust (string);
static void scan_column_split (string);
static void scan_omit_list (string);
static void scan_remap_list (string);

/* Fontconvert provides a grabbag of operations: almost every
   manipulation on bitmap fonts we found useful we threw here.  */

int
main (int argc, string argv[])
{
  int code;
  bitmap_font_type f;
  string *first_element;
  string font_name;
  unsigned this_font;
  unsigned char_count = 0;

  /* Use Kpathsea path searching. */
  kpse_set_progname (argv[0]);

  /* Initialize the character code translation array before parsing the
     command line, since we probably will not be told to remap every
     character.  */
  for (code = 0; code <= MAX_CHARCODE; code++)
    translate[code] = code;

  /* Initialize the list of fonts to do to have one empty element at the
     beginning, which we will fill in with the main font name.  */
  fontname_list = list_init ();
  first_element = LIST_TAPPEND (&fontname_list, string);

  /* Read all the arguments.  */
  font_name = read_command_line (argc, argv);

  /* Put the main font name in the list.  */
  *first_element = font_name;

  /* If no output name was specified on the command line, use the root
     part of the input name.  We've already removed the suffix in
     `read_command_line'.  */
  if (output_name == NULL)
    output_name = basename (font_name);

  if (wants_gf && wants_tfm && find_suffix (output_name) != NULL)
    FATAL ("The GF and TFM output files' suffixes can't be the same");

  /* Open the main font specially, since we need to know some basic
     information for most of the output formats.  We don't need to close
     it again, as opening a font twice does no harm.  */
  f = get_bitmap_font (font_name, atou (dpi));

  if (wants_epsf)
    epsf_start_output (output_name);
  if (wants_gf)
    gf_start_output (font_name, output_name, dpi,
                     BITMAP_FONT_COMMENT (f));
  if (wants_tfm)
    tfm_start_output (font_name, output_name, design_size,
		      BITMAP_FONT_DESIGN_SIZE (f));


  /* Have to do this after `tfm_start_output', as it needs to know if
     design_size is set or not.  */
  if (design_size == 0.0)
    design_size = BITMAP_FONT_DESIGN_SIZE (f);

  design_size_ratio = BITMAP_FONT_DESIGN_SIZE (f) / design_size;

  /* Go through each input font.  */
  for (this_font = 0; this_font < LIST_SIZE (fontname_list); this_font++)
    {
      string font_name = *(string *) LIST_ELT (fontname_list, this_font);
      f = get_bitmap_font (font_name, atou (dpi));

      if (wants_tfm)
        tfm_start_font (font_name);

      REPORT1 ("(%s", BITMAP_FONT_FILENAME (f));

      /* The main loop: convert each character.  */
      for (code = starting_char; code <= ending_char; code++)
        {
          char_info_type *c = get_char (font_name, code);

          if (c == NULL) continue;

          REPORT2 ("%c[%u", ++char_count % 8 ? ' ' : '\n', code);

          if (omit[code])
            REPORT (" omit");
          else
            {
              /* If this character isn't supposed to split, just output it.
                 Otherwise, output each of the pieces after splitting.  */
              if (column_split[code] == NULL)
                do_char (*c);
              else
                do_split_char (*c, column_split[code]);
            }

          REPORT ("]");
        }

      close_font (font_name);
      REPORT (")\n");
    }

  if (wants_epsf)
    epsf_finish_output ();

  /* We must finish the TFM output before GF, because `gf_finish_output'
     might want to open a TFM file -- and we can only have one TFM file
     open at a time.  (Because we haven't rewritten the TFM library.)  */
  if (wants_tfm)
    tfm_finish_output ();

  if (wants_gf)
    gf_finish_output (design_size, atof (dpi));

  return 0;
}

/* Output the character in whatever forms have been requested.  */

static void
do_char (char_info_type c)
{
  static boolean char_done_p[MAX_CHARCODE + 1];

  charcode_type original_code = CHARCODE (c);

  /* Do the character code translation.  */
  charcode_type code = CHARCODE (c) = translate[original_code];

  if (char_done_p[code])
    {
      WARNING1 ("Character %d already output", CHARCODE (c));
      return;
    }

  char_done_p[code] = true;

  if (filter_passes > 0)
    filter_bitmap (CHAR_BITMAP (c));

  if (random_max > 0.0)
    {
      bounding_box_type adjust_bb;
      randomize_bitmap (&CHAR_BITMAP (c), &adjust_bb);
      CHAR_MIN_ROW (c) -= MIN_ROW (adjust_bb);
      CHAR_MAX_ROW (c) += MAX_ROW (adjust_bb);
      CHAR_MIN_COL (c) -= MIN_COL (adjust_bb);
      CHAR_MAX_COL (c) += MAX_COL (adjust_bb);
    }

  /* If the `baseline_adjust' value is positive, the baseline should
     move up, i.e., we subtract from the height and add to the depth.
     But since the depth is represented as the minimum row, which can be
     negative, we must subtract from it to make it ``larger''.  */
  CHAR_MIN_ROW (c) -= baseline_adjust[code];
  CHAR_MAX_ROW (c) -= baseline_adjust[code];

  /* Text output is already implemented in the library.  */
  if (wants_text)
    {
      puts ("\f");
      print_char (stdout, c);
    }

  if (wants_epsf)
    epsf_output_char (c);

  if (wants_gf)
    gf_output_char (c, design_size_ratio);

  if (wants_tfm)
    tfm_output_char (c, atof (dpi));

  if (original_code != code)
    REPORT1 ("->%u", code);

    /* Free the space here, instead of in the caller, since we may
       change the bitmap.  */
    free_bitmap (&CHAR_BITMAP (c));
}


/* Output the character C in pieces, the division points being the
   columns in SPLIT.  */

static void
do_split_char (char_info_type c, int split[])
{
  unsigned last_col = 0;
  unsigned n_split = 0;

  REPORT (" (");

  /* We exit the loop after splitting the last character.  */
  while (true)
    {
      int diff;
      char_info_type split_char = c;
      int this_col = *split++;
      unsigned split_col = this_col != -1
                           ? this_col : BITMAP_WIDTH (CHAR_BITMAP (c));

      /* Change the character code of this piece.  */
      CHARCODE (split_char) += n_split;

      REPORT1 ("%u", CHARCODE (split_char));

      /* Take the chunk from the big bitmap.  */
      CHAR_BITMAP (split_char)
        = column_extract (CHAR_BITMAP (c), last_col, split_col);

      /* Move the right column over.  */
      diff = BITMAP_WIDTH (CHAR_BITMAP (c))
             - BITMAP_WIDTH (CHAR_BITMAP (split_char));
      CHAR_MAX_COL (split_char) -= diff;
      CHAR_SET_WIDTH (split_char) -= diff;

      /* Output it.  */
      do_char (split_char);

      /* Exit the loop if we just output the last piece.  */
      if (this_col == -1)
        break;

      n_split++;
      last_col = this_col;
      REPORT (",");
    }

  REPORT (")");
  free_bitmap (&CHAR_BITMAP (c));
}

/* Return the part of the bitmap SOURCE that lies between the columns
   START and FINISH - 1, inclusive.  */

static bitmap_type
column_extract (bitmap_type source, unsigned start, unsigned finish)
{
  unsigned this_row;
  dimensions_type d = { BITMAP_HEIGHT (source), finish - start };
  bitmap_type answer = new_bitmap (d);

  /* Move to the given starting column.  */
  BITMAP_BITS (source) += start;

  for (this_row = 0; this_row < BITMAP_HEIGHT (source); this_row++)
    {
      one_byte *answer_row = BITMAP_ROW (answer, this_row);

      memcpy (answer_row, BITMAP_BITS (source), BITMAP_WIDTH (answer));
      BITMAP_BITS (source) += BITMAP_WIDTH (source);
    }

  return answer;
}

/* Reading the options.  */

/* This is defined in version.c.  */
extern string version_string;

#define USAGE "Options:\n\
<font_name> should be a filename, possibly with a resolution, e.g.,\n\
  `cmr10' or `cmr10.300'.\n"						\
  GETOPT_USAGE								\
"baseline-adjust <char1>:<integer1>,<char2>:<integer2>,...: move the baseline\n\
  of each <char> by the corresponding <integer>.  A positive number\n\
  moves the baseline up, a negative one down.\n\
column-split <char>@<column1>,...,<columnN>: split the character with\n\
  code <char> (before remapping) before each of the <column>s, producing n\n\
  new characters, with codes <char>, <char> + 1, ..., <char> + n, whose\n\
  bitmaps go from 0 to <column1> - 1 (inclusive), then <column1> to\n\
  <column2> - 1, ..., from <columnN> to the bitmap width.\n\
  Give the <column>s in bitmap coordinates, i.e., starting at zero.\n\
  To split more than one character, give this option for each.\n\
concat <font_name>,<font_name>,...: concatenate the main input font with\n\
  the given <font_name>s; if a character code exists in more than one\n\
  font, it's the first occurrence that counts.\n\
designsize <real>: use this as the design size for both the GF and TFM\n\
  output files, if any, unless overridden by `designsize' in the\n\
  `tfm-header' option.\n\
dpi <unsigned>: use a resolution of <unsigned>; default is 300.\n\
encoding <filename>: read encoding information for the character specs\n\
  from `<filename>.enc'; there is no default.  Must come before any\n\
  options which use character specs.\n\
epsf: output each character as an Encapsulated PostScript file named\n\
  <font_name>-<code>.eps, where <code> is the character code in decimal.\n\
filter-passes <unsigned>: do the filtering this many times on each\n\
  character; default is 0.\n\
filter-size <unsigned>: half the size of the filter cell, i.e., a side\n\
  is this number * 2 + 1; default is 1.\n\
filter-threshold <real>: if the average of the pixels in the filter cell\n\
  is greater than this, change the pixel; default is .5.\n\
fontdimens <fontdimen>:<real>,<fontdimen>:<real>,...: assign each <real>\n\
  to the corresponding <fontdimen> when outputting a TFM file.  A\n\
  <fontdimen> can be either one of the standard names (in either upper\n\
  or lowercase), or a number between 1 and 30.  Each <real> is taken to\n\
  be in points (except in the case of the <fontdimen> `slant' (parameter\n\
  1), which is a dimensionless number).\n\
gf: write a GF file to `<font_name>.<dpi>gf'.  If this would overwrite the\n\
  input file, write to `x<font_name>.<dpi>gf' instead.\n\
help: print this message.\n\
omit <char1>,<char2>,...: omit the characters with the given codes or names\n\
  (before remapping) from the output.\n\
output-file <filename>: use <filename> as the output filename if it has\n\
   a suffix, and as the base of the output files if it doesn't.  It\n\
   cannot have a suffix if using the `epsf' option, or both the `gf' and the\n\
   `tfm' option.  Default is the base part of the input font name.\n\
random <real>: move each pixel a (uniformly) random distance between\n\
   -<real> and <real> in both x and y; default is 0.\n\
random-threshold <real>: if randomizing, do not move pixels with\n\
  probability <real>; default is 0.2.\n\
range <char1>-<char2>: only process characters between <char1> and\n\
  <char2> in the input font, inclusive.\n\
remap <char1>:<char2>,<char1>:<char2>,...: for each pair, make the input\n\
  character with code <char1> have code <char2> in the output.\n\
text: output the font to stdout as plain text, using `*'s and ` 's.\n\
tfm: write a TFM file to `<font_name>.tfm'.  If this would overwrite the\n\
  input file, write to `x<font_name>.tfm' instead.\n\
tfm-header: <header-item>:<value>,<header-item>:<value>,...: assign each\n\
  <value> to the corresponding <header-item> when outputting a TFM file.\n\
  A <header-item> is one of `checksum', `designsize' or `codingscheme',\n\
  with casefolding. `checksum' requires an unsigned integer,\n\
  `designsize' a real, with 1.0 <= designsize < 2048, and `codingscheme'\n\
  a string of length less than 40 containing no parens or commas.\n\
verbose: print brief progress reports on stdout.\n\
version: print the version number of this program.\n\
"

/* We return the name of the font to process.  */

static string
read_command_line (int argc, string argv[])
{
  int g;   /* `getopt' return code.  */
  int option_index;
  boolean explicit_dpi = false;
  boolean printed_version = false;
  struct option long_options[]
    = { { "baseline-adjust",	1, 0, 0 },
        { "column-split",	1, 0, 0 },
        { "concat",		1, 0, 0 },
        { "designsize",	1, 0, 0 },
        { "dpi",		1, (int *) &explicit_dpi, 1 },
        { "encoding",		1, 0, 0 },
        { "epsf",		0, (int *) &wants_epsf, 1 },
        { "filter-passes",	1, 0, 0 },
        { "filter-size",	1, 0, 0 },
        { "filter-threshold",	1, 0, 0 },
        { "fontdimens",		1, 0, 0 },
        { "gf",			0, (int *) &wants_gf, 1 },
        { "help",		0, 0, 0 },
        { "omit",		1, 0, 0 },
        { "output-file",	1, 0, 0 },
        { "random",		1, 0, 0 },
        { "random-threshold",	1, 0, 0 },
        { "range",		1, 0, 0 },
        { "remap",		1, 0, 0 },
        { "text",		0, (int *) &wants_text, 1 },
        { "tfm",		0, (int *) &wants_tfm, 1 },
        { "tfm-header",		1, 0, 0 },
        { "verbose",		0, (int *) &verbose, 1 },
        { "version",		0, (int *) &printed_version, 1 },
        { 0, 0, 0, 0 } };

  while (true)
    {
      g = getopt_long_only (argc, argv, "", long_options, &option_index);

      if (g == EOF)
        break;

      if (g == '?')
        exit (1);  /* Unknown option.  */

      assert (g == 0); /* We have no short option names.  */

      if (ARGUMENT_IS ("baseline-adjust"))
        scan_baseline_adjust (optarg);

      else if (ARGUMENT_IS ("column-split"))
        scan_column_split (optarg);

      else if (ARGUMENT_IS ("concat"))
        append_concat_list (&fontname_list, optarg);

      else if (ARGUMENT_IS ("designsize"))
        {
          design_size = atof (optarg);
          TFM_CHECK_DESIGN_SIZE (design_size);
        }

      else if (ARGUMENT_IS ("dpi"))
        dpi = optarg;

      else if (ARGUMENT_IS ("encoding"))
	{
          if (encoding_info == NULL)
            encoding_info = XTALLOC1 (encoding_info_type);
	  *encoding_info = read_encoding_file (optarg);
	}

      else if (ARGUMENT_IS ("filter-passes"))
        filter_passes = atou (optarg);

      else if (ARGUMENT_IS ("filter-size"))
        filter_size = atou (optarg);

      else if (ARGUMENT_IS ("filter-threshold"))
        {
          filter_threshold = atof (optarg);
          if (filter_threshold <= 0.0)
            FATAL1 ("The filter threshold should be positive, not %f",
                    filter_threshold);
        }

      else if (ARGUMENT_IS ("fontdimens"))
        fontdimens = optarg;

      else if (ARGUMENT_IS ("help"))
        {
          fprintf (stderr, "Usage: %s [options] <font_name>.\n", argv[0]);
          fprintf (stderr, USAGE);
          exit (0);
        }

      else if (ARGUMENT_IS ("omit"))
        scan_omit_list (optarg);

      else if (ARGUMENT_IS ("output-file"))
        output_name = optarg;

      else if (ARGUMENT_IS ("range"))
        GET_RANGE (optarg, starting_char, ending_char);

      else if (ARGUMENT_IS ("random"))
        random_max = atof (optarg);

      else if (ARGUMENT_IS ("random-threshold"))
        random_threshold = atof (optarg);

      else if (ARGUMENT_IS ("remap"))
        scan_remap_list (optarg);

      else if (ARGUMENT_IS ("text"))
        report_file = stderr;

      else if (ARGUMENT_IS ("tfm-header"))
        tfm_header = optarg;

      else if (ARGUMENT_IS ("version"))
        printf ("%s.\n", version_string);

      /* Else it was just a flag; getopt has already done the assignment.  */
    }

  FINISH_COMMAND_LINE ();
}

/* The string S specifies baseline adjustments for individual
   characters: `<charcode>:<adjustment>,...'.  We set the element
   <charcode> of the global array `baseline_adjust' to the <adjustment>.  */

static void
scan_baseline_adjust (string s)
{
  string spec;

  for (spec = strtok (s, ARG_SEP); spec != NULL; spec = strtok (NULL, ARG_SEP))
    {
      string code;
      string adjust = strchr (spec, ':');

      if (adjust == NULL)
        FATAL1 ("Baseline adjustments look like `<code>:<integer>', not `%s'",
                spec);

      code = substring (spec, 0, adjust - spec - 1);

      baseline_adjust[xparse_charspec (code, encoding_info)]
        = atoi (adjust + 1);
    }
}


/* The string S says how to split a single character into multiple
   characters: `<charcode>@<column1>,...<columnN>'.  We set the element
   <charcode> of the global array `column_split' to the list of the
   integers.  */

static void
scan_column_split (string s)
{
  string code;
  string column_list = strchr (s, '@');

  if (column_list == NULL)
    FATAL1 ("Column splits look like `<code>@<column>,<column>,...', not `%s'",
      s);

  code = substring (s, 0, column_list - s - 1);

  column_split[xparse_charspec (code, encoding_info)]
    = scan_unsigned_list (column_list + 1);
}


/* The string S is a list of font names, separated by commas.  We append
   each onto CONCAT_LIST.  */

static void
append_concat_list (list_type *concat_list, string s)
{
  string name;

  /* The main routine must initialize CONCAT_LIST before we are called.  */
  assert (concat_list != NULL && LIST_SIZE (*concat_list) > 0);

  for (name = strtok (s, ARG_SEP); name != NULL; name = strtok (NULL, ARG_SEP))
    {
      string *new = LIST_TAPPEND (concat_list, string);
      *new = name;
    }
}


/* The string L is a list of character codes separated by commas; we
   omit those characters in the output.  Here, we parse the list and set
   elements of the global array `omit' according to what we find.  */

static void
scan_omit_list (string l)
{
  string map;

  for (map = strtok (l, ARG_SEP); map != NULL; map = strtok (NULL, ARG_SEP))
    {
      charcode_type code = xparse_charspec (map, encoding_info);
      omit[code] = true;
    }
}


/* The string L is a list of remappings to apply, in the form
   <code1>:<code2>,<code1>:<code2>,...  where <code1> is a character
   code in the original font, and <code2> is the character code to write
   it as.  No checking for remappings to or from the same character is
   done here.

   We set elements of the global array `translate' according to what we
   find.  */

static void
scan_remap_list (string l)
{
  string map; /* A single remapping.  */

  for (map = strtok (l, ARG_SEP); map != NULL; map = strtok (NULL, ARG_SEP))
    {
      one_byte original, target;
      string original_str, target_str;
      unsigned length = strlen (map);

      /* Ignore empty mappings, as in `a:b,,c:d'.  */
      if (length == 0)
        continue;

      else if (length < 3)
        {
          WARNING1 ("Mapping `%s' too short to be valid", map);
          continue;
        }

      else if (*map == ':')
        { /* Must have form `::<code>'.  */
          original_str = ":";
          if (*(map + 1) != ':')
            {
              WARNING1 ("Mapping `%s' doesn't have form `<code>:<code>'", map);
              continue;
            }
          target_str = map + 2;
        }

      else if (*(map + length - 1) == ':')
        { /* Must have form `<code>::'.  */
          target_str = ":";
          if (*(map + length - 2) != ':')
            {
              WARNING1 ("Mapping `%s' doesn't have form `<code>:<code>'", map);
              continue;
            }
          original_str = substring (map, 0, length - 3);
        }

      else
        { /* Must have form `<code>:<code>'.  */
          target_str = strchr (map, ':');
          if (target_str == NULL)
            {
              WARNING1 ("Mapping `%s' doesn't have form `<code>:<code>'", map);
              continue;
            }
          target_str++;
          original_str = substring (map, 0, target_str - 2 - map);
        }

      original = xparse_charspec (original_str, encoding_info);
      target = xparse_charspec (target_str, encoding_info);
      translate[original] = target;
    }
}



/* xx use the macro instead */
/*string
finish_command_line()						
{
  do									
    {									
      if (printed_version && optind == argc) exit (0);			

      if (optind + 1 == argc && *argv[optind] != 0)			
        {								
          FIND_CMDLINE_DPI ();						
          return MAYBE_REMOVE_SUFFIX (argv[optind]);			
        }								
      else								
        {								
          fprintf (stderr, "Usage: %s [options] <font_name>.\n", argv[0]);
          fprintf (stderr, "(%s.)\n", optind == argc ? "Missing <font_name>"
                                      : "Too many <font_name>s");	
          fputs ("For more information, use ``-help''.\n", stderr);	
          exit (1);							
        }								
      return NULL;
    }									
  while (0)
}
*/