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
|
%% This LabTeX, v 0.9
% written by: Alan Hoenig, summer 1991-summer 1992.
% Bitnet: ajhjj@cunyvm
% Mail: 17 Bay Avenue, Huntington, NY 11743, USA
%
% This is file LABTEX.MF. You will also need the file LABTEX.TEX, as
% well as TeX, Metafont, and their support programs.
%
% Here's how to use the Metafont part of the labtex macros.
%
% You will create a font source file with each character being a figure
% that you want. Before the `mode_setup;' command, enter the line
% input labtex;
% so Metafont will know the meaning of the macros you'll be using.
%
% In the course of creating your figure, you will define the points
% which serve as the anchors for the labels. After all these have been
% defined, and before the `endchar;' command, enter
% labtex(point list);
% where <point list> is the list of points. If you'd like, use
% `beginfig' and `endfig' as synonyms for `beginchar' and `endchar'.
%
% When Metafont creates your font, create the packed pixel file, move
% the pk file and the tfm file to the usual place on your hard disk,
% and prepare to create your TeX source file. See the comments in
% labtex.tex to see what to do next.
%
numeric chars[];
vardef lab@#=(x_@#, y_@#) enddef;
def clearx_y_=save x_, y_ enddef;
def char_init(expr c)= %
clearx_y_;
i:=c; chars[i]=1;
enddef;
extra_beginchar:=extra_beginchar&"char_init(charcode)";
numeric running_label_amt; running_label_amt=0;
numeric xx_[], yy_[]; % to store the kerns for ligtable
numeric lpf[]; % to store labels per fig
def char_fin=
i:=0;
forever:
exitif not known x_[i];
i:=i+1; endfor
%for j=0 upto i-1: show "X",x_[j], "Y",y_[j]; endfor
label_amt:=i;
for i:=0 upto label_amt-1:
xx_[running_label_amt +i]=x_[i];
yy_[running_label_amt +i]=y_[i]; endfor
lpf[charcode]=label_amt;
running_label_amt:=running_label_amt+label_amt;
enddef;
extra_endchar:=extra_endchar&"char_fin";
% fpf=figures per font
def fillfont= % to define all chars not yet defined
% and to create ligtable
show "Now filling font. Patience, please.";
last_char=255;
for i=0 upto last_char: % need MF2!
% show i, chars[i];
if not known chars[i]: beginchar(i,0,0,0); endchar;
if not known fpf: fpf=i; fi fi
endfor
% ligtable machinations only done if at least one label in at least
% one fig.
if known lpf[1]:
doligtable; fi
enddef;
def doligtable=
ligtable 0: 0 kern xx_0/hppp
for i=1 upto running_label_amt-1: , i kern xx_[i]/hppp endfor;
ligtable 1: 0 kern yy_0/hppp
for i=1 upto running_label_amt-1: , i kern yy_[i]/hppp endfor;
ligtable 2: 0 kern lpf0
for i=1 upto fpf: , i kern lpf[i] endfor;
enddef;
vardef labtex(text t)= % t is a list of pair names
save I; I=0; % I is a counter
for $=t: lab[I]=$; I:=I+1; endfor
enddef;
let beginfig=beginchar;
let endfig=endchar;
inner end, bye; let savedend=end; let savedbye=bye;
boolean filledfont; filledfont=false;
def end= if not filledfont: filledfont:=true; fillfont; fi
savedend;
enddef;
let bye=end;
outer end, bye;
endinput;
|