~ubuntu-branches/ubuntu/lucid/lcdf-typetools/lucid

« back to all changes in this revision

Viewing changes to cfftot1/cfftot1.cc

  • Committer: Bazaar Package Importer
  • Author(s): C.M. Connelly
  • Date: 2009-04-06 16:49:02 UTC
  • mfrom: (1.2.8 upstream) (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090406164902-9mu14sman9wo3112
Tags: 2.78-1
* New upstream release.
* t1lint: Report warnings when a font charstring command has too many
  arguments.
* Font library changes: correctly implement binary search in a couple
  places -- unexpected sizes could lead to overflow and bad behavior.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* cfftot1.cc -- driver for translating CFF fonts to Type 1 fonts
2
2
 *
3
 
 * Copyright (c) 2002-2006 Eddie Kohler
 
3
 * Copyright (c) 2002-2009 Eddie Kohler
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify it
6
6
 * under the terms of the GNU General Public License as published by the Free
71
71
    if (!error_message)
72
72
        errh->message("Usage: %s [OPTIONS] [FONTFILE [OUTPUTFILE]]", program_name);
73
73
    else
74
 
        errh->verror(ErrorHandler::ERR_ERROR, String(), error_message, val);
 
74
        errh->vxmessage(ErrorHandler::e_error, error_message, val);
75
75
    errh->message("Type %s --help for more information.", program_name);
76
76
    exit(1);
77
77
}
79
79
void
80
80
usage()
81
81
{
82
 
    printf("\
83
 
'Cfftot1' translates a PostScript font from the Compact Font Format (CFF) to\n\
 
82
    FileErrorHandler uerrh(stdout);
 
83
    uerrh.message("\
 
84
%<Cfftot1%> translates a PostScript font from the Compact Font Format (CFF) to\n\
84
85
the usual Type 1 format. The input file should be either a raw CFF font or a\n\
85
86
PostScript-flavored OpenType font. The result, which is usually written to the\n\
86
87
standard output, is written in PFB or PFA format.\n\
96
97
  -h, --help                   Print this message and exit.\n\
97
98
  -v, --version                Print version number and exit.\n\
98
99
\n\
99
 
Report bugs to <kohler@cs.ucla.edu>.\n", program_name);
 
100
Report bugs to <ekohler@gmail.com>.\n", program_name);
100
101
}
101
102
 
102
103
 
114
115
#endif
115
116
    } else if (!(f = fopen(infn, "rb")))
116
117
        errh->fatal("%s: %s", infn, strerror(errno));
117
 
  
 
118
 
118
119
    int c = getc(f);
119
120
    ungetc(c, f);
120
121
 
121
122
    Cff::Font *font = 0;
122
 
    
 
123
 
123
124
    if (c == EOF)
124
125
        errh->fatal("%s: empty file", infn);
125
126
    if (c == 1 || c == 'O') {
146
147
 
147
148
    if (errh->nerrors() > 0)
148
149
        return;
149
 
    
 
150
 
150
151
    Type1Font *font1 = create_type1_font(font, errh);
151
152
 
152
153
    if (!outfn || strcmp(outfn, "-") == 0) {
176
177
    Clp_Parser *clp =
177
178
        Clp_NewParser(argc, (const char * const *)argv, sizeof(options) / sizeof(options[0]), options);
178
179
    program_name = Clp_ProgramName(clp);
179
 
  
 
180
 
180
181
    ErrorHandler *errh = ErrorHandler::static_initialize(new FileErrorHandler(stderr, String(program_name) + ": "));
181
182
    const char *input_file = 0;
182
183
    const char *output_file = 0;
183
184
    const char *font_name = 0;
184
 
  
 
185
 
185
186
    while (1) {
186
187
        int opt = Clp_Next(clp);
187
188
        switch (opt) {
189
190
          case PFA_OPT:
190
191
            binary = false;
191
192
            break;
192
 
      
 
193
 
193
194
          case PFB_OPT:
194
195
            binary = true;
195
196
            break;
199
200
                usage_error(errh, "font name specified twice");
200
201
            font_name = clp->vstr;
201
202
            break;
202
 
            
 
203
 
203
204
          case QUIET_OPT:
204
205
            if (clp->negated)
205
206
                errh = ErrorHandler::default_handler();
206
207
            else
207
208
                errh = new SilentErrorHandler;
208
209
            break;
209
 
      
 
210
 
210
211
          case VERSION_OPT:
211
212
            printf("cfftot1 (LCDF typetools) %s\n", VERSION);
212
 
            printf("Copyright (C) 2002-2006 Eddie Kohler\n\
 
213
            printf("Copyright (C) 2002-2009 Eddie Kohler\n\
213
214
This is free software; see the source for copying conditions.\n\
214
215
There is NO warranty, not even for merchantability or fitness for a\n\
215
216
particular purpose.\n");
216
217
            exit(0);
217
218
            break;
218
 
      
 
219
 
219
220
          case HELP_OPT:
220
221
            usage();
221
222
            exit(0);
236
237
            else
237
238
                input_file = clp->vstr;
238
239
            break;
239
 
      
 
240
 
240
241
          case Clp_Done:
241
242
            goto done;
242
 
      
 
243
 
243
244
          case Clp_BadOption:
244
245
            usage_error(errh, 0);
245
246
            break;
246
 
      
 
247
 
247
248
          default:
248
249
            break;
249
 
      
 
250
 
250
251
        }
251
252
    }
252
 
  
 
253
 
253
254
  done:
254
255
    do_file(input_file, output_file, font_name, errh);
255
 
    
 
256
 
256
257
    return (errh->nerrors() == 0 ? 0 : 1);
257
258
}