summaryrefslogtreecommitdiff
path: root/language/sanskrit/sktdefs.mf
blob: e7f405d8bc041a5d2c7a149029b6f51a54ac1a2a (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
%
% SKTDEFS.MF
%
% Revision 1.0 1996/02/13 Charles Wikner wikner@nacdh4.nac.ac.za
% Revision 2.0 1996/11/27 Charles Wikner wikner@nacdh4.nac.ac.za
% Revision 2.1 1997/02/11 Charles Wikner wikner@nacdh4.nac.ac.za
%
% Copyright 1996 & 2002 Charles Wikner
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
% Make pen adjustments here.
%
  thin_weight := 2;                % factor to increase thin pen stroke
  penwd# := cap#/pen_scale;          % width of horizontal or vertical pen stroke
  penht# := penwd#;                  % ht = wd, at this stage anyway!
    thin# := (penwd#/6.5cosd(45))*thin_weight;     % pen stroke width at 135-deg
      thick# := (pen_ratio*6.25thin#)/thin_weight; % pen stroke width at 45-deg
%
  ht# := cap#;                       % character height at horizontal line
  wd# := charwd_scale*ht#;           % character width - nominal reference
%

define_pixels(penwd,penht,wd);
define_whole_pixels(ht);
define_blacker_pixels(thin,thick);
smoothing := 0;

font_slant := slant;
font_quad wd#;                % specifies width of `em'
font_x_height cap#;           % specifies height of `ex'
font_normal_space := .75wd#;  % inter-word spacing
font_normal_stretch := .5wd#; % glue for inter-word spacing
font_normal_shrink  := .2wd#; % glue for inter-word spacing

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        P E N   D E F I N I T I O N S                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear_pen_memory;

pickup pencircle xscaled thick yscaled thin rotated (pen_rot);
  main_pen := savepen; 

if unknown squarepen :
  capsule_def (squarepen) makepen (unitsquare shifted (-.5,-.5) 
  scaled thick rotated 135);
fi

if unknown penoffsquare :
  capsule_def (penoffsquare) makepen (unitsquare shifted (0,-.5));
fi

pickup penoffsquare xscaled (.8thick) yscaled (1.4thin) rotated pen_rot;
  mpen135 := savepen; 

pickup penoffsquare xscaled (.8thick) yscaled (1.4thin) rotated (pen_rot-180);
  mpen315 := savepen; 

pickup penoffsquare xscaled (.8thin) yscaled (1.4thick) rotated (pen_rot+90);
  mpen225 := savepen; 

pickup penoffsquare xscaled (.8thin) yscaled (1.4thick) rotated (pen_rot-90);
  mpen45 := savepen; 

pickup pencircle xscaled .667thick yscaled thin rotated (pen_rot);
  sub_pen := savepen; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        M A C R O S                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

def mdraw expr p =
  pickup main_pen;
  draw p;
  cullit
enddef;

def bedraw expr p =
  picture savedpicture; savedpicture = currentpicture; clearit;
  pickup main_pen;
  draw p;
  cullit;
  trim (point 0 of p, 180+angle direction 0 of p);
  trim (point infinity of p, angle direction infinity of p);
  cullit;
  addto currentpicture also savedpicture
enddef;

def bdraw expr p =
  picture savedpicture; savedpicture = currentpicture; clearit;
  pickup main_pen;
  draw p;
  cullit;
  trim (point 0 of p, 180+angle direction 0 of p);
  cullit;
  addto currentpicture also savedpicture
enddef;

def edraw expr p =
  picture savedpicture; savedpicture = currentpicture; clearit;
  pickup main_pen;
  draw p;
  cullit;
  trim (point infinity of p, angle direction infinity of p);
  cullit;
  addto currentpicture also savedpicture
enddef;

vardef trim (expr z, theta) =
    if (theta <= 0) : alpha := (theta + 360) ;
    else : alpha := theta;
    fi    
    if ((alpha < 120) or (alpha > 330)) : pickup mpen45;
    elseif ((alpha >= 120) and (alpha <= 150)) : pickup mpen135;
    elseif ((alpha >= 300) and (alpha <= 330)) : pickup mpen315;
    else : pickup mpen225;
    fi
  undrawdot z;
enddef;

def vector (expr z, length, theta) =
  z--z shifted (length * cosd theta, length * sind theta)
enddef;

def putdot expr z =
  pickup squarepen; drawdot z;
enddef;

def empty =
    pickup pencircle; 
    draw (12W,0)--(12W,12H)--(0,0)--(12W,0)--(0,12H)--(12W,12H);
    draw (0,0)--(0,12H);
enddef;

% sdraw = mdraw with sub-pen
def sdraw expr p =
  pickup sub_pen;
  draw p;
  cullit
enddef;

% sbdraw = bdraw with subpen
def sbdraw expr p =
  picture savedpicture; savedpicture = currentpicture; clearit;
  pickup sub_pen;
  draw p;
  cullit;
  trim (point 0 of p, 180+angle direction 0 of p);
  cullit;
  addto currentpicture also savedpicture
enddef;

% sedraw = edraw with subpen
def sedraw expr p =
  picture savedpicture; savedpicture = currentpicture; clearit;
  pickup sub_pen;
  draw p;
  cullit;
  trim (point infinity of p, angle direction infinity of p);
  cullit;
  addto currentpicture also savedpicture
enddef;

% sbedraw = bedraw with subpen
def sbedraw expr p =
  picture savedpicture; savedpicture = currentpicture; clearit;
  pickup sub_pen;
  draw p;
  cullit;
  trim (point 0 of p, 180+angle direction 0 of p);
  trim (point infinity of p, angle direction infinity of p);
  cullit;
  addto currentpicture also savedpicture
enddef;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        M A G I C    N U M B E R S                                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

def H  := ht/12 enddef;
def W  := H     enddef; % used to be wd/12, but because angles used in
                        % defining pen movements would also need to change
                        % with aspect ratio, it is simpler to work with a
                        % fixed grid and then use TRANSFORMATION to scale 
                        % the x-axis.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        F I N I S                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

currenttransform:=identity xscaled (wd#/ht#) slanted slant;