~ubuntu-branches/ubuntu/precise/vflib3/precise

« back to all changes in this revision

Viewing changes to src/vflmkvf.c

  • Committer: Bazaar Package Importer
  • Author(s): Masayuki Hatta
  • Date: 2002-04-15 12:10:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020415121024-cann32wucyfbq22f
Tags: upstream-3.6.12
ImportĀ upstreamĀ versionĀ 3.6.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * vflmkvf.c 
 
3
 * - a vflibcap entry generator for TeX VF files
 
4
 *
 
5
 * - This program prints vflibcap entries to standard output.
 
6
 *
 
7
 * - Useful for generating vflibcap for TeX DVI drivers
 
8
 *
 
9
 *
 
10
 * by Hirotsugu Kakugawa
 
11
 *
 
12
 *  10 May 2001
 
13
 */
 
14
/*
 
15
 * Copyright (C) 2001  Hirotsugu Kakugawa. 
 
16
 * All rights reserved.
 
17
 *
 
18
 * This program is free software; you can redistribute it and/or modify
 
19
 * it under the terms of the GNU General Public License as published by
 
20
 * the Free Software Foundation; either version 2, or (at your option)
 
21
 * any later version.
 
22
 * 
 
23
 * This program is distributed in the hope that it will be useful,
 
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
26
 * GNU General Public License for more details.
 
27
 * 
 
28
 * You should have received a copy of the GNU General Public License
 
29
 * along with this program; if not, write to the Free Software
 
30
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
 
31
 */
 
32
 
 
33
 
 
34
#include "config.h"
 
35
#include "with.h"
 
36
#include <stdio.h>
 
37
#include <stdlib.h>
 
38
#include <ctype.h>
 
39
#include <unistd.h>
 
40
#include <sys/param.h>
 
41
#include <sys/time.h>
 
42
 
 
43
#include  "VFlib-3_6.h"
 
44
#include  "VFsys.h"
 
45
#include  "vflibcap.h"
 
46
#include  "texfonts.h"
 
47
#include  "vf.h"
 
48
#include  "fsearch.h"
 
49
#include  "vflmklib.h"
 
50
 
 
51
 
 
52
 
 
53
void  gen_class_deafult(void);
 
54
 
 
55
 
 
56
char  *mode  = DEFAULT_KPS_MODE;
 
57
char  *dpi   = NULL;
 
58
int    dpi_i = DEFAULT_KPS_DPI;
 
59
 
 
60
#define NDIRS    64
 
61
int   n_vff; 
 
62
char  *vf_fontdirs[NDIRS];
 
63
 
 
64
#define NMAPS    64
 
65
int n_map;
 
66
char  *map_class[NMAPS];
 
67
char  *map_map[NMAPS];
 
68
char  *map_opt[NMAPS];
 
69
 
 
70
char *cmdline = NULL; 
 
71
char *glyph_style = TEX_GLYPH_STYLE_FILL_STR;
 
72
char *open_style  = TEX_OPEN_STYLE_TRY_STR;
 
73
 
 
74
 
 
75
 
 
76
int 
 
77
main(int argc, char **argv)
 
78
{
 
79
  int     i;
 
80
  int    xargc;
 
81
  char **xargv;
 
82
 
 
83
  dpi = malloc(256);
 
84
  sprintf(dpi, "%d", dpi_i);
 
85
 
 
86
  cmdline = copy_cmdline(argc, argv);
 
87
 
 
88
  n_vff = 0;
 
89
  for (i = 0; i < NDIRS; i++){
 
90
    vf_fontdirs[i] = NULL;
 
91
  }
 
92
 
 
93
  n_map = 0;
 
94
  for (i = 0; i < NMAPS; i++){
 
95
    map_class[i] = NULL;
 
96
    map_map[i] = NULL;
 
97
    map_opt[i] = NULL;
 
98
  }
 
99
 
 
100
  xargc = argc; 
 
101
  xargv = argv;
 
102
 
 
103
  for (xargc--,xargv++; xargc > 0; xargc--,xargv++){
 
104
    if ((strcmp(*xargv, "--help") == 0)
 
105
        || (strcmp(*xargv, "-help") == 0)){
 
106
      printf("vflmkvf: generates vflibcap entries for TeX Virtual Fonts\n");
 
107
      printf("Usage: vflmkvf [options]\n");
 
108
      printf("Options\n");
 
109
      printf("  -d DIR   : Virtual Font file directory\n");
 
110
      printf("  -r DPI   : Default device resolution\n");
 
111
      printf("  -n MODE  : Device mode name for kpathsea\n");
 
112
      printf("  -g STYLE : Glyph style, 'fill' (default) or 'empty'\n");
 
113
      printf("  -o STYLE : Font open style, 'try', 'require', or 'non'\n");
 
114
      printf("  -m CLASS FORMAT : Add mapping rule\n");
 
115
      printf("Example: vflmkvf -d TEXMF -m type1 %%f.pfb -m gf .gf -g fill\n");
 
116
      exit(0);
 
117
 
 
118
    } else if (strcmp(*xargv, "-d") == 0){
 
119
      /* font dir */
 
120
      if (n_vff == NDIRS){
 
121
        fprintf(stderr, "Too many Virtual Font directories\n");
 
122
        exit(1);
 
123
      }
 
124
      xargv++; xargc--;
 
125
      check_argc(xargc);
 
126
      vf_fontdirs[n_vff++] = x_strdup(*xargv);
 
127
 
 
128
    } else if (strcmp(*xargv, "-r") == 0){
 
129
      xargv++; xargc--;
 
130
      check_argc(xargc);
 
131
      dpi = strdup(*xargv);
 
132
 
 
133
    } else if (strcmp(*xargv, "-n") == 0){
 
134
      /* mode */
 
135
      xargv++; xargc--;
 
136
      check_argc(xargc);
 
137
      mode = x_strdup(*xargv);
 
138
 
 
139
    } else if (strcmp(*xargv, "-m") == 0){
 
140
      if (n_map == NMAPS){
 
141
        fprintf(stderr, "Too many mapfont conversion rules\n");
 
142
        exit(1);
 
143
      }
 
144
      xargv++; xargc--;
 
145
      check_argc(xargc);
 
146
      if (strcmp(*xargv, "any") == 0)
 
147
        map_class[n_map] = strdup("*");
 
148
      else
 
149
        map_class[n_map] = strdup(*xargv);
 
150
      xargv++; xargc--;
 
151
      check_argc(xargc);
 
152
      map_map[n_map] = strdup(*xargv);
 
153
      n_map++;
 
154
 
 
155
    } else if (strcmp(*xargv, "-g") == 0){
 
156
      xargv++; xargc--;
 
157
      check_argc(xargc);
 
158
      if ((strcmp(*xargv, TEX_GLYPH_STYLE_FILL_STR) != 0)
 
159
          && (strcmp(*xargv, TEX_GLYPH_STYLE_EMPTY_STR) != 0)){
 
160
        fprintf(stderr, "Unknown glyph style name: %s\n", *xargv);
 
161
        fprintf(stderr, "(Must be '%s' or '%s'. Default is '%s'.\n", 
 
162
                TEX_GLYPH_STYLE_FILL_STR, TEX_GLYPH_STYLE_EMPTY_STR,
 
163
                glyph_style);
 
164
        exit(1);
 
165
      }
 
166
      glyph_style = strdup(*xargv);
 
167
 
 
168
    } else if (strcmp(*xargv, "-o") == 0){
 
169
      xargv++; xargc--;
 
170
      check_argc(xargc);
 
171
      if ((strcmp(*xargv, TEX_OPEN_STYLE_TRY_STR) != 0)
 
172
          && (strcmp(*xargv, TEX_OPEN_STYLE_REQUIRE_STR) != 0)
 
173
          && (strcmp(*xargv, TEX_OPEN_STYLE_NONE_STR) != 0)){
 
174
        fprintf(stderr, "Unknown open style name: %s\n", *xargv);
 
175
        fprintf(stderr, "(Must be '%s', '%s' or '%s'. Default is '%s'.\n", 
 
176
                TEX_OPEN_STYLE_TRY_STR,
 
177
                TEX_OPEN_STYLE_REQUIRE_STR,
 
178
                TEX_OPEN_STYLE_NONE_STR,
 
179
                open_style);
 
180
        exit(1);
 
181
      }
 
182
      open_style = strdup(*xargv);
 
183
 
 
184
    } else {
 
185
      if (*xargv[0] == '-'){
 
186
        fprintf(stderr, "vflmkvf: unknown option %s\n", *xargv);
 
187
        exit(1);
 
188
      }
 
189
      break;
 
190
 
 
191
    }
 
192
  }
 
193
 
 
194
  banner("Virtual Font", "vflmkvf", cmdline);
 
195
 
 
196
  gen_class_deafult();    
 
197
 
 
198
  return 0;
 
199
}
 
200
 
 
201
 
 
202
 
 
203
void
 
204
gen_class_deafult(void)
 
205
{
 
206
  int   i;
 
207
 
 
208
  printf("(%s %s", 
 
209
         VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION, FONTCLASS_NAME_VF);
 
210
  printf("\n  (%s", VF_CAPE_FONT_DIRECTORIES);
 
211
  for (i = 0; i < n_vff; i++)
 
212
    printf("\n       \"%s\"", vf_fontdirs[i]);
 
213
  printf(")");
 
214
  printf("\n  (%s %s)", VF_CAPE_DPI, dpi);
 
215
  printf("\n  (%s \".vf\" \".ovf\")", VF_CAPE_EXTENSIONS);
 
216
  printf("\n  (%s \"%s\")", VF_CAPE_TEX_OPEN_STYLE, open_style);
 
217
  printf("\n  (%s \"%s\")", VF_CAPE_TEX_GLYPH_STYLE, glyph_style);
 
218
  printf("\n  (%s", VF_CAPE_TEX_FONT_MAPPING);
 
219
  for (i = 0; i < n_map; i++){
 
220
    if (map_need_tfm(map_class[i]) == 0){
 
221
      printf("\n    ((%s \"%s\") *)", 
 
222
             map_class[i], map_map[i]);
 
223
    } else {
 
224
      printf("\n    ((%s \"%s\" %s) *)", 
 
225
             map_class[i], map_map[i], TEX_FONT_MAPPING_PTSIZE);
 
226
    }
 
227
  }
 
228
  printf(")");
 
229
  printf(")\n");
 
230
  printf("\n");
 
231
}
 
232