src/vflmktex.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. main
  2. gen_class_deafult

   1 /* 
   2  * vflmktex.c 
   3  * - a vflibcap entry generator for TeX font mapper
   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  *dpi   = NULL;
  57 int    dpi_i = DEFAULT_KPS_DPI;
  58 
  59 #define NDIRS    64
  60 int   n_tfmf; 
  61 char  *tfm_fontdirs[NDIRS];
  62 
  63 #define NMAPS    64
  64 int n_map;
  65 char  *map_class[NMAPS];
  66 char  *map_map[NMAPS];
  67 char  *map_opt[NMAPS];
  68 
  69 char *cmdline = NULL; 
  70 
  71 int res_col[5][32] = {
  72   { 240,   
  73     240,  263,  288,  312,  346,  415,  498,  597, -1 },
  74   { 300, 
  75     329,  360,  432,  518,  622,  746,  896, 1075, 1290, 240, 270, -1 },
  76   { 400,
  77     400,  438,  480,  576,  691,  829,  995, 1194, 1433, 1720, 320, 360, -1 },
  78   { 600,   
  79     600,  657,  720,  864, 1037, 1244, 1493, 1792, 2150, 2580, 480, 540, -1 },
  80 };
  81 
  82 
  83 int 
  84 main(int argc, char **argv)
     /* [<][>][^][v][top][bottom][index][help] */
  85 {
  86   int     i;
  87   int    xargc;
  88   char **xargv;
  89 
  90   dpi = malloc(256);
  91   sprintf(dpi, "%d", dpi_i);
  92 
  93   cmdline = copy_cmdline(argc, argv);
  94 
  95   n_tfmf = 0;
  96   for (i = 0; i < NDIRS; i++){
  97     tfm_fontdirs[i] = NULL;
  98   }
  99 
 100   n_map = 0;
 101   for (i = 0; i < NMAPS; i++){
 102     map_class[i] = NULL;
 103     map_map[i] = NULL;
 104     map_opt[i] = NULL;
 105   }
 106 
 107   xargc = argc; 
 108   xargv = argv;
 109 
 110   for (xargc--,xargv++; xargc > 0; xargc--,xargv++){
 111     if ((strcmp(*xargv, "--help") == 0)
 112         || (strcmp(*xargv, "-help") == 0)){
 113       printf("vflmktex: generates vflibcap entries for TeX font mapper\n");
 114       printf("Usage: vflmktex [options]\n");
 115       printf("Options\n");
 116       printf("  -d DIR   : TFM file directory\n");
 117       printf("  -r DPI   : Default device resolution\n");
 118       printf("  -m CLASS FORMAT : Add font mapping rule\n");
 119       printf("Example: vflmkvf -d TEXMF -m type1 %%f.pfb -m gf %%f.gf\n");
 120       exit(0);
 121 
 122     } else if (strcmp(*xargv, "-d") == 0){
 123       /* font dir */
 124       if (n_tfmf == NDIRS){
 125         fprintf(stderr, "Too many Virtual Font directories\n");
 126         exit(1);
 127       }
 128       xargv++; xargc--;
 129       tfm_fontdirs[n_tfmf++] = x_strdup(*xargv);
 130 
 131     } else if (strcmp(*xargv, "-r") == 0){
 132       xargv++; xargc--;
 133       check_argc(xargc);
 134       dpi = strdup(*xargv);
 135 
 136     } else if (strcmp(*xargv, "-m") == 0){
 137       if (n_map == NMAPS){
 138         fprintf(stderr, "Too many mapfont conversion rules\n");
 139         exit(1);
 140       }
 141       xargv++; xargc--;
 142       check_argc(xargc);
 143       if (strcmp(*xargv, "any") == 0)
 144         map_class[n_map] = strdup("*");
 145       else
 146         map_class[n_map] = strdup(*xargv);
 147       xargv++; xargc--;
 148       check_argc(xargc);
 149       map_map[n_map] = strdup(*xargv);
 150       n_map++;
 151 
 152     } else {
 153       if (*xargv[0] == '-'){
 154         fprintf(stderr, "vflmktex: unknown option %s\n", *xargv);
 155         exit(1);
 156       }
 157       break;
 158 
 159     }
 160   }
 161 
 162   banner("TeX Font Mapper", "vflmktex", cmdline);
 163 
 164   gen_class_deafult();    
 165 
 166   return 0;
 167 }
 168 
 169 
 170 
 171 void
 172 gen_class_deafult(void)
     /* [<][>][^][v][top][bottom][index][help] */
 173 {
 174   int   i, j;
 175 
 176   printf("(%s %s", 
 177          VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION, FONTCLASS_NAME_TeX);
 178   printf("\n  (%s %s)", VF_CAPE_DPI, dpi);
 179   printf("\n  (%s", VF_CAPE_TEX_TFM_DIRECTORIES);
 180   for (i = 0; i < n_tfmf; i++)
 181     printf("\n       \"%s\"", tfm_fontdirs[i]);
 182   printf(")");
 183   printf("\n  (%s \".tfm\" \".ofm\")", VF_CAPE_TEX_TFM_EXTENSIONS);
 184   printf("\n  (%s", VF_CAPE_TEX_FONT_MAPPING);
 185   for (i = 0; i < n_map; i++){
 186     if (map_need_tfm(map_class[i]) == 0){
 187       printf("\n    ((%s \"%s\") *)", 
 188              map_class[i], map_map[i]);
 189     } else {
 190       printf("\n    ((%s \"%s\" %s) *)", 
 191              map_class[i], map_map[i], TEX_FONT_MAPPING_PTSIZE);
 192     }
 193   }
 194   printf(")");
 195   printf("\n  (%s 0.02)", VF_CAPE_RESOLUTION_ACCU);
 196   printf("\n  (%s", VF_CAPE_RESOLUTION_CORR);
 197   for (i = 0; res_col[i][0] > 0; i++){
 198     printf("\n    (%d  ; %d dpi devices", res_col[i][0], res_col[i][0]);
 199     printf("\n    ");
 200     for (j = 0; res_col[i][j] > 0; j++){
 201       printf(" %d", res_col[i][j]);
 202     }
 203     printf(")");
 204   }
 205   printf(")");
 206 
 207   printf(")");
 208   printf("\n");
 209   printf("\n");
 210 }

/* [<][>][^][v][top][bottom][index][help] */