summaryrefslogtreecommitdiff
path: root/systems/msdos/jemtex2/fontable.c
blob: 6868f6e3b6761a009e89b1d33023f027c8191409 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* -mt -f -A -K -G -O -w */
/* Compile with Turbo-C 2.0 */
/*
  This program generates Japanese font tables

  Author: Francois Jalbert
              '
  Date: November 1990

  Version: 1.0

  Date: April 1991

  Version: 2.0

  Modifications: - Added four kanjis.
                 - Run-time parameters now supplied.
                 - Extension is .JEM now.
                 - Page format changed slightly.
                 - Symbols now centered within tables.
                 - Switched to \clearpage since better for tables.
*/

#include <stdio.h>
#ifdef __TURBOC__
#include <process.h>
#endif

/* Highest Bitmap number in JIS24 */
#define BitmapMax  7806
/* Highest font number */
#define FontMax    60
/* Number of symbols in a font */
#define SymbolMax  128
#define SymbolMax1 127

void FontTable(FILE *OutFile)
{
  int Bitmap;
  int Font;
  int Symbol;
  unsigned char EUC1,EUC2;

  fprintf(OutFile,"%%JEM2TEX /NoSpace /NoPercent /LaTeX /EUC /Extended /3.0\n");
  fprintf(OutFile,"%%\n");
  fprintf(OutFile,"\\documentstyle[12pt]{article}\n");
  fprintf(OutFile,"\\pagestyle{plain}\n");
  fprintf(OutFile,"\\setlength{\\oddsidemargin}{-0.5in} %%0.5in margin left-right\n");
  fprintf(OutFile,"\\setlength{\\textwidth}{7.5in} %%8.5in-2*0.5in\n");
  fprintf(OutFile,"\\setlength{\\topmargin}{-0.25in} %%0.75in margin top-bottom\n");
  fprintf(OutFile,"\\setlength{\\textheight}{9.4in} %%11.0in-2*0.75in\n");
  fprintf(OutFile,"\\setlength{\\footskip}{0.1in}\n");
  fprintf(OutFile,"\\setlength{\\footheight}{0.1in}\n");
  fprintf(OutFile,"\\setlength{\\headheight}{0pt}\n");
  fprintf(OutFile,"\\setlength{\\headsep}{0pt}\n");
  fprintf(OutFile,"\\setlength{\\topskip}{0pt}\n");
  fprintf(OutFile,"\\setlength{\\parindent}{0pt}\n");
  fprintf(OutFile,"\\setlength{\\tabcolsep}{4pt}\n");
  fprintf(OutFile,"\\renewcommand{\\baselinestretch}{0.85}\n");
  fprintf(OutFile,"\\begin{document}\n");
  fprintf(OutFile,"\\begin{Large}\n");
  fprintf(OutFile,"\n");
  fprintf(OutFile,"\\vspace*{\\fill}\n");
  fprintf(OutFile,"\n");
  if (ferror(OutFile)) exit(1);
  for (Bitmap=0 ; Bitmap<=BitmapMax ; Bitmap++) {
    Symbol=Bitmap % SymbolMax;
    Font=Bitmap / SymbolMax;
    EUC1=(unsigned char)((Bitmap-1)/94);
    EUC2=(unsigned char)((Bitmap-1)-94*(int)EUC1);
    EUC1=EUC1+(unsigned char)'\xA1';
    EUC2=EUC2+(unsigned char)'\xA1';
    if (!Symbol) {
      fprintf(OutFile,"\\begin{table}[h]\n");
      fprintf(OutFile," \\centering\n");
      fprintf(OutFile," \\begin{tabular}{r|cccccccccccccccc|l}\n");
      fprintf(OutFile,
              "  Code & \\multicolumn{16}{c|}{Characters} & EUC \\\\ \\hline\n");
      if (ferror(OutFile)) exit(1);
    }
    switch (Symbol % 16) {
      case 0: fprintf(OutFile,"%6d ",Symbol);
              if (ferror(OutFile)) exit(1);
              break;
      case 5: case 10: case 15: fprintf(OutFile,"       ");
                                if (ferror(OutFile)) exit(1);
                                break;
    } 
    if (Bitmap) {
      fprintf(OutFile,"&%c%c",EUC1,EUC2);
      if (ferror(OutFile)) exit(1);
      switch (Symbol % 16) {
        case 4: case 9: case 14: fprintf(OutFile,"\n"); 
                                 if (ferror(OutFile)) exit(1);
                                 break;
        default:if ((Symbol % 16)==15) {
                  fprintf(OutFile,"& %d,%d",EUC1,EUC2);
                  if ( (Symbol!=SymbolMax1) && (Bitmap!=BitmapMax) )
                    fprintf(OutFile," \\\\");
                  fprintf(OutFile,"\n");
                  if (ferror(OutFile)) exit(1);
                }
                else
                  if (Bitmap==BitmapMax) {
                    fprintf(OutFile,"\n");
                    if (ferror(OutFile)) exit(1);
                  }
                break;
      } 
    }
    else {
      fprintf(OutFile,"&  ");
      if (ferror(OutFile)) exit(1);
    }
    if ( (Symbol==SymbolMax1) || (Bitmap==BitmapMax) ) {
      fprintf(OutFile," \\end{tabular}\n");
      fprintf(OutFile,"\\caption{Font {\\tt kanji%c%c} (%d--%d).}\n",
              ('a'+(Font/8)),('a'+(Font % 8)),(Bitmap-Symbol),Bitmap);
      fprintf(OutFile,"\\end{table}\n");
      fprintf(OutFile,"\n");
      if (ferror(OutFile)) exit(1);
      if (Bitmap==BitmapMax) {
        fprintf(OutFile,"\\vspace*{\\fill}\n");
        fprintf(OutFile,"\n");
        if (ferror(OutFile)) exit(1);
      }
      else
        if ((Font % 3)==2) { 
          fprintf(OutFile,"\\vspace*{\\fill}\n");
          fprintf(OutFile,"\n");
          fprintf(OutFile,"\\clearpage\n");
          fprintf(OutFile,"\n");
          fprintf(OutFile,"\\vspace*{\\fill}\n");
          fprintf(OutFile,"\n");
          if (ferror(OutFile)) exit(1);
        }
    }
  }
  fprintf(OutFile,"\\end{Large}\n");
  fprintf(OutFile,"\\end{document}\n");
  if (ferror(OutFile)) exit(1);
}

main()
{
  FILE *OutFile;

  printf("\n");
  printf("Japanese Font Tables Generation Program.\n");/*To make Borland happy*/
  printf("Version 2.0 Copyright F. Jalbert 1991.\n");
  printf("\n");
  if (ferror(stdout)) exit(1);

  printf("Creating Japanese file fontable.jem");
  if ((OutFile=fopen("fontable.jem","wt"))==NULL) exit(1);
  printf(".\n");
  if (ferror(stdout)) exit(1);

  printf("Generating font tables");
  #ifndef __TURBOC__
  printf("\n");
  #endif
  FontTable(OutFile);
  printf(".\n");
  if (ferror(stdout)) exit(1);

  printf("Closing Japanese file fontable.jem");
  if (fclose(OutFile)==EOF) exit(1);
  printf(".\n");
  printf("\n");
  if (ferror(stdout)) exit(1);

  printf("Japanese font tables generation completed.\n");
  printf("\n");
  if (ferror(stdout)) exit(1);

  return(0);
}