src/vflmkttf.c

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

FUNCTIONS

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

   1 /* 
   2  * vflmkttf.c 
   3  * - a vflibcap entry generator for TrueType fonts
   4  *
   5  * - This program prints vflibcap entries to standard output.
   6  *
   7  *
   8  * by Hirotsugu Kakugawa
   9  *
  10  *  15 May 2001
  11  */
  12 /*
  13  * Copyright (C) 2001  Hirotsugu Kakugawa. 
  14  * All rights reserved.
  15  *
  16  * This program is free software; you can redistribute it and/or modify
  17  * it under the terms of the GNU General Public License as published by
  18  * the Free Software Foundation; either version 2, or (at your option)
  19  * any later version.
  20  * 
  21  * This program is distributed in the hope that it will be useful,
  22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24  * GNU General Public License for more details.
  25  * 
  26  * You should have received a copy of the GNU General Public License
  27  * along with this program; if not, write to the Free Software
  28  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
  29  */
  30 
  31 
  32 #include "config.h"
  33 #include "with.h"
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <ctype.h>
  37 #include <unistd.h>
  38 #ifdef HAVE_STRING_H
  39 #include <string.h>
  40 #endif
  41 #include <sys/param.h>
  42 #include <sys/time.h>
  43 
  44 #include  "VFlib-3_6.h"
  45 #include  "VFsys.h"
  46 #include  "vflibcap.h"
  47 #include  "ttf.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_dirs; 
  61 char  *ttf_fontdirs[NDIRS];
  62 
  63 char  *platform = "microsoft";
  64 
  65 char *cmdline = NULL; 
  66 
  67 
  68 
  69 int 
  70 main(int argc, char **argv)
     /* [<][>][^][v][top][bottom][index][help] */
  71 {
  72   int     i;
  73   int    xargc;
  74   char **xargv;
  75 
  76   dpi = malloc(256);
  77   sprintf(dpi, "%d", dpi_i);
  78 
  79   cmdline = copy_cmdline(argc, argv);
  80 
  81   n_dirs = 0;
  82   for (i = 0; i < NDIRS; i++){
  83     ttf_fontdirs[i] = NULL;
  84   }
  85 
  86   xargc = argc; 
  87   xargv = argv;
  88 
  89   for (xargc--,xargv++; xargc > 0; xargc--,xargv++){
  90     if ((strcmp(*xargv, "--help") == 0)
  91         || (strcmp(*xargv, "-help") == 0)){
  92       printf("vflmkttf: generates vflibcap entries for TrueType fonts\n");
  93       printf("Usage: vflmkttf [options]\n");
  94       printf("Options\n");
  95       printf("  -d DIR   : PK font file directory\n");
  96       printf("  -r DPI   : Default device resolution\n");
  97       printf("  -p PLAT  : Default platform id\n");
  98 
  99       printf("Example: vflmkttf -d TEXMF -d /usr/local/share/fonts// \n");
 100       exit(0);
 101 
 102     } else if (strcmp(*xargv, "-d") == 0){
 103       /* font dir */
 104       if (n_dirs == NDIRS){
 105         fprintf(stderr, "Too many TrueType font directories\n");
 106         exit(1);
 107       }
 108       xargv++; xargc--;
 109       check_argc(xargc);
 110       ttf_fontdirs[n_dirs++] = x_strdup(*xargv);
 111 
 112     } else if (strcmp(*xargv, "-r") == 0){
 113       xargv++; xargc--;
 114       check_argc(xargc);
 115       dpi = strdup(*xargv);
 116 
 117     } else if (strcmp(*xargv, "-p") == 0){
 118       xargv++; xargc--;
 119       check_argc(xargc);
 120       platform = strdup(*xargv);
 121 
 122     } else {
 123       if (*xargv[0] == '-'){
 124         fprintf(stderr, "vflmkttf: unknown option %s\n", *xargv);
 125         exit(1);
 126       }
 127       break;
 128 
 129     }
 130   }
 131 
 132   banner("TrueType", "vflmkttf", cmdline);
 133 
 134   gen_class_deafult();    
 135 
 136   return 0;
 137 }
 138 
 139 
 140 
 141 void
 142 gen_class_deafult(void)
     /* [<][>][^][v][top][bottom][index][help] */
 143 {
 144   int   i;
 145 
 146   printf("(%s %s", 
 147          VF_CAPE_VFLIBCAP_CLASS_DEFAULT_DEFINITION, FONTCLASS_NAME);
 148   printf("\n  (%s", VF_CAPE_FONT_DIRECTORIES);
 149   for (i = 0; i < n_dirs; i++)
 150     printf("\n       \"%s\"", ttf_fontdirs[i]);
 151   printf(")");
 152   printf("\n  (%s \"%s\")", VF_CAPE_TTF_PLATFORM_ID, platform);
 153   printf("\n  (%s %s)", VF_CAPE_DPI, dpi);
 154   printf(")\n");
 155   printf("\n");
 156 }
 157 

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