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

« back to all changes in this revision

Viewing changes to ascii-jtex/eKanji/mksample.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
 *  mksample.c
 
3
 *    Make list of all characters of eKanji font in LaTeX form.
 
4
 *  
 
5
 *
 
6
 *  How to use this program:
 
7
 *
 
8
 *  1. Compile this program.
 
9
 *         % gcc -o mksample mksample.c
 
10
 *  2. Run this program to generate (huge) LaTeX input file.
 
11
 *         % ./mksample  > sample.tex
 
12
 *  3. Run pLaTeX to generate DVI file.
 
13
 *         % platex sample.tex
 
14
 *  4. View/Print it. For example, 
 
15
 *         % xgdvi sample.dvi 
 
16
 *
 
17
 */
 
18
 
 
19
#include <stdio.h>
 
20
 
 
21
#define MINCHAR        1
 
22
#define NCHLINE       20
 
23
#define SIZECMD  "normalsize"
 
24
 
 
25
 
 
26
int    font_type;
 
27
int    ku_from, ku_to, nchline, title;
 
28
long   maxchar;
 
29
char  *sizecmd;
 
30
int    mtype;
 
31
 
 
32
struct s_fontinfo {
 
33
  char  *fontfile;
 
34
  char  *cmd;
 
35
  long   maxchar;
 
36
};
 
37
 
 
38
#define TYPE_UNICODE    0
 
39
#define TYPE_KANGXI     1
 
40
#define TYPE_MOROHASHI  2
 
41
struct s_fontinfo  fontinfo[] =  
 
42
{
 
43
  { "ekan0010.d24", "EKU",  22999 },
 
44
  { "ekan0020.d24", "EKK",  49188 },
 
45
  { "ekan0030.d24", "EKM",  50476 },
 
46
  {  NULL,           NULL,     -1 },
 
47
};
 
48
 
 
49
 
 
50
 
 
51
 
 
52
void
 
53
parse_args(int argc, char **argv)
 
54
{
 
55
 
 
56
  mtype = TYPE_UNICODE;
 
57
  maxchar = fontinfo[mtype].maxchar;
 
58
  ku_from = 0;
 
59
  ku_to   = maxchar/100;
 
60
 
 
61
  argc--; argv++;
 
62
  while (argc > 0){
 
63
    if (strcmp(*argv, "-f") == 0){
 
64
      argc--; argv++;
 
65
      ku_from = atoi(*argv);      
 
66
    } else if (strcmp(*argv, "-t") == 0){
 
67
      argc--; argv++;
 
68
      ku_to = atoi(*argv);      
 
69
    } else if (strcmp(*argv, "-n") == 0){
 
70
      argc--; argv++;
 
71
      if ((nchline = atoi(*argv)) < 1){
 
72
        fprintf(stderr, "-n option: value must be positive.\n");
 
73
      }
 
74
    } else if (strcmp(*argv, "-s") == 0){
 
75
      argc--; argv++;
 
76
      sizecmd = *argv;
 
77
    } else if (strcmp(*argv, "-u") == 0){
 
78
      mtype = TYPE_UNICODE;
 
79
      maxchar = fontinfo[mtype].maxchar;
 
80
      ku_to   = maxchar/100;
 
81
    } else if (strcmp(*argv, "-k") == 0){
 
82
      mtype = TYPE_KANGXI;
 
83
      maxchar = fontinfo[mtype].maxchar;
 
84
      ku_to   = maxchar/100;
 
85
    } else if (strcmp(*argv, "-m") == 0){
 
86
      mtype = TYPE_MOROHASHI;
 
87
      maxchar = fontinfo[mtype].maxchar;
 
88
      ku_to   = maxchar/100;
 
89
    } else if ((strcmp(*argv, "-h") == 0)
 
90
               || (strcmp(*argv, "-help") == 0)
 
91
               || (strcmp(*argv, "--help") == 0)){
 
92
      fprintf(stderr, 
 
93
              "Usage: mksample  [-u -k -m]"
 
94
              "[-f FROM_CODE] [-t TO_CODE] [-n LINE_NCHARS] [-s SIZE_CMD]\n");
 
95
      fprintf(stderr, "  LINE_NCHARS = %d\n", NCHLINE);
 
96
      fprintf(stderr, "  SIZE_CMD = %s\n", SIZECMD);
 
97
      exit(0);
 
98
    }
 
99
    argc--; argv++;
 
100
  }
 
101
}
 
102
 
 
103
 
 
104
int
 
105
main(int argc, char **argv)
 
106
{
 
107
  int  ku, ten, i;
 
108
  
 
109
  title   = 0;
 
110
  nchline = NCHLINE;
 
111
  sizecmd = SIZECMD;
 
112
 
 
113
  parse_args(argc, argv);
 
114
 
 
115
  printf("\\documentclass[a4paper]{jarticle}\n");
 
116
  printf("\\setlength{\\topmargin}{-25mm}\n");
 
117
  printf("\\setlength{\\evensidemargin}{-10mm}\n");
 
118
  printf("\\setlength{\\oddsidemargin}{-10mm}\n");
 
119
  printf("\\setlength{\\textwidth}{180mm}\n");
 
120
  printf("\\setlength{\\textheight}{263mm}\n");
 
121
  printf("\\usepackage{ekanji}\n");
 
122
  printf("\\usepackage{array}\n");
 
123
  printf("\\renewcommand{\\arraystretch}{0.9}\n");
 
124
  printf("\\def\\CH#1{#1}\n");
 
125
  printf("\\begin{document}\n");
 
126
  if (title == 0){
 
127
    printf("\\begin{center}\n");
 
128
    printf("\\textsf{\\textbf{\\LARGE e����\\ %s \\ ʸ������}}\\\\\n",
 
129
           fontinfo[mtype].fontfile);
 
130
    printf("\\vskip 1em\n");
 
131
    printf("{\\LARGE \\verb|\\|\\texttt{%s}\\verb|{|\\textit{num}\\verb|}|}\n",
 
132
           fontinfo[mtype].cmd);
 
133
    printf("\\end{center}\n");
 
134
    printf("\\vskip 3em\n");
 
135
  }
 
136
  printf("\\%s\n", sizecmd);
 
137
 
 
138
 
 
139
  for (ku = ku_from; ku <= ku_to; ku++){
 
140
 
 
141
    printf("\\vskip 1.2em\n");
 
142
    printf("\\vbox{\n");
 
143
    printf("\\noindent\\textsf{\\textbf{%06d}}\\par\n", ku*100 + 1);
 
144
    printf("\\begin{center}");
 
145
    printf("\\begin{tabular}{|r|");
 
146
    for (i = 0; i < nchline; i++)
 
147
      printf("c");
 
148
    printf("|}\n");
 
149
    printf("\\hline\n");
 
150
    printf(" \n");
 
151
    for (i = 0; i < nchline; i++)
 
152
      printf("&\\texttt{%02d}", i+1);
 
153
    printf("\\\\\n");
 
154
    printf("\\hline\n");
 
155
    for (ten = 1; ten <= 100; ten++){
 
156
      if ((ten % nchline) == 1){
 
157
        if (ten > 1)
 
158
          printf("\\\\\n");
 
159
        printf("\\texttt{%06d}\n", ku*100 + ten);
 
160
      }
 
161
      printf(" &\\CH{\\%s{%d}}\n", fontinfo[mtype].cmd, ku*100 + ten);
 
162
    }
 
163
    while ((ten % nchline) != 1){
 
164
      printf(" &\n");
 
165
      ten++;
 
166
    }
 
167
    printf("\\\\\n");
 
168
    printf("\\hline\n");
 
169
    printf("\\end{tabular}\n");
 
170
    printf("\\end{center}");
 
171
    printf("}\n");
 
172
    printf("\n");
 
173
  }
 
174
 
 
175
  printf("\\end{document}\n");
 
176
  
 
177
  return 0;
 
178
}